Message ID | 20250224212051.1756517-8-viro@zeniv.linux.org.uk (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [01/21] procfs: kill ->proc_dops | expand |
On Mon, Feb 24, 2025 at 09:20:38PM +0000, Al Viro wrote: > No need to mess with ->d_op at all. Note that ->d_delete that always > returns 1 is equivalent to having DCACHE_DONTCACHE in ->d_flags. > Later the same thing will be placed into ->s_d_flags of the filesystems > where we want that behaviour for all dentries; then the check in > simple_lookup() will at least get unlikely() slapped on it. > > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> > --- Reviewed-by: Christian Brauner <brauner@kernel.org> > fs/libfs.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/fs/libfs.c b/fs/libfs.c > index 929bef0fecbd..b15a2148714e 100644 > --- a/fs/libfs.c > +++ b/fs/libfs.c > @@ -75,9 +75,11 @@ struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, unsigned > { > if (dentry->d_name.len > NAME_MAX) > return ERR_PTR(-ENAMETOOLONG); > - if (!dentry->d_op) > - d_set_d_op(dentry, &simple_dentry_operations); > - > + if (!(dentry->d_flags & DCACHE_DONTCACHE)) { > + spin_lock(&dentry->d_lock); > + dentry->d_flags |= DCACHE_DONTCACHE; > + spin_unlock(&dentry->d_lock); > + } > if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) > return NULL; > > -- > 2.39.5 >
diff --git a/fs/libfs.c b/fs/libfs.c index 929bef0fecbd..b15a2148714e 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -75,9 +75,11 @@ struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, unsigned { if (dentry->d_name.len > NAME_MAX) return ERR_PTR(-ENAMETOOLONG); - if (!dentry->d_op) - d_set_d_op(dentry, &simple_dentry_operations); - + if (!(dentry->d_flags & DCACHE_DONTCACHE)) { + spin_lock(&dentry->d_lock); + dentry->d_flags |= DCACHE_DONTCACHE; + spin_unlock(&dentry->d_lock); + } if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) return NULL;
No need to mess with ->d_op at all. Note that ->d_delete that always returns 1 is equivalent to having DCACHE_DONTCACHE in ->d_flags. Later the same thing will be placed into ->s_d_flags of the filesystems where we want that behaviour for all dentries; then the check in simple_lookup() will at least get unlikely() slapped on it. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> --- fs/libfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)