Re: [PATCH 06/20] sysfs: Use dentry_ops instead of directly playing with the dcache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tejun Heo <tj@xxxxxxxxxx> writes:

>> +static int sysfs_dentry_revalidate(struct dentry *dentry, struct nameidata *nd)
>> +{
>> +	struct sysfs_dirent *sd = dentry->d_fsdata;
>> +	int is_dir;
>> +
>> +	mutex_lock(&sysfs_mutex);
>> +
>> +	/* The sysfs dirent has been deleted */
>> +	if (sd->s_flags & SYSFS_FLAG_REMOVED)
>> +		goto out_bad;
>> +
>> +	mutex_unlock(&sysfs_mutex);
>> +out_valid:
>> +	return 1;
>> +out_bad:
>> +	/* Remove the dentry from the dcache hashes.
>> +	 * If this is a deleted dentry we use d_drop instead of d_delete
>> +	 * so sysfs doesn't need to cope with negative dentries.
>> +	 */
>> +	is_dir = (sysfs_type(sd) == SYSFS_DIR);
>> +	mutex_unlock(&sysfs_mutex);
>> +	if (is_dir) {
>> +		/* If we have submounts we must allow the vfs caches
>> +		 * to lie about the state of the filesystem to prevent
>> +		 * leaks and other nasty things.
>> +		 */
>> +		if (have_submounts(dentry))
>> +			goto out_valid;
>> +		shrink_dcache_parent(dentry);
>> +	}
>> +	d_drop(dentry);
>> +	return 0;
>> +}
>
> Ummm... what happens if sysfs recreates those identical nodes again
> while the old dentries are lingering?  The dead ones will linger till
> the submounts are gone and then look ups after that will show the new
> ones, right?

Yep.  On the vfs level.  The sysfs dirent tree will reflect what is
going on with the hardware.

This is a vfs misfeature, that I hope someday we will get fixed.
But for now it is better not to leak mount points.  Especially
since no one actually mounts things on sysfs.

Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux