Re: [PATCH 16/20] sysfs: Propagate renames to the vfs on demand

From: Tejun Heo
Date: Thu May 21 2009 - 05:41:47 EST


Eric W. Biederman wrote:
> From: Eric W. Biederman <ebiederm@xxxxxxxxxxxx>
>
> By teaching sysfs_revalidate to hide a dentry for
> a sysfs_dirent if the sysfs_dirent has been renamed,
> and by teaching sysfs_lookup to return the original
> dentry if the sysfs dirent has been renamed. I can
> show the results of renames correctly without having to
> update the dcache during the directory rename.
>
> This massively simplifies the rename logic allowing a lot
> of weird sysfs special cases to be removed along with
> a lot of now unnecesary helper code.
>
> Signed-off-by: Eric W. Biederman <ebiederm@xxxxxxxxxxxxxxxxxx>

It's probably a good idea to cc Al Viro?

> @@ -311,6 +270,14 @@ static int sysfs_dentry_revalidate(struct dentry *dentry, struct nameidata *nd)
> if (sd->s_flags & SYSFS_FLAG_REMOVED)
> goto out_bad;
>
> + /* The sysfs dirent has been moved? */
> + if (dentry->d_parent->d_fsdata != sd->s_parent)
> + goto out_bad;
> +
> + /* The sysfs dirent has been renamed */
> + if (strcmp(dentry->d_name.name, sd->s_name) != 0)
> + goto out_bad;
> +
> mutex_unlock(&sysfs_mutex);
> out_valid:
> return 1;
> @@ -318,6 +285,12 @@ 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.
> + *
> + * If this is a dentry that has simply been renamed we
> + * use d_drop to remove it from the dcache lookup on it's
^^^^
its

> + * old parent. If this dentry persists later when a lookup
> + * is performed at it's new name the dentry will be readded
^^^^
its

Other than the above comment changes,

Acked-by: Tejun Heo <tj@xxxxxxxxxx>

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/