Message ID | 20250224212051.1756517-9-viro@zeniv.linux.org.uk (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [01/21] procfs: kill ->proc_dops | expand |
On Tue, 25 Feb 2025, Al Viro wrote: > Convert the last user (d_alloc_pseudo()) and be done with that. > Any out-of-tree filesystem using it should switch to d_splice_alias_ops() > or, better yet, check whether it really needs to have ->d_op vary among > its dentries. > > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> > --- > Documentation/filesystems/porting.rst | 11 +++++++++++ > fs/dcache.c | 5 ++--- > include/linux/dcache.h | 1 - > 3 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst > index 004cd69617a2..61b5771dde53 100644 > --- a/Documentation/filesystems/porting.rst > +++ b/Documentation/filesystems/porting.rst > @@ -1164,3 +1164,14 @@ magic. > > If your filesystem sets the default dentry_operations, use set_default_d_op() > rather than manually setting sb->s_d_op. > + > +--- > + > +**mandatory** > + > +d_set_d_op() is no longer exported (or public, for that matter); _if_ > +your filesystem really needed that, make use of d_splice_alias_ops() > +to have them set. Better yet, think hard whether you need different > +->d_op for different dentries - if not, just use set_default_d_op() > +at mount time and be done with that. Currently procfs is the only > +thing that really needs ->d_op varying between dentries. > diff --git a/fs/dcache.c b/fs/dcache.c > index a4795617c3db..29db27228d97 100644 > --- a/fs/dcache.c > +++ b/fs/dcache.c > @@ -1796,7 +1796,7 @@ struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name) > if (likely(dentry)) { > dentry->d_flags |= DCACHE_NORCU; > if (!dentry->d_op) > - d_set_d_op(dentry, &anon_ops); > + dentry->d_op = &anon_ops; This is safe because d_op_flags(anon_ops) is zero so there is no need to update dentry->d_flags. I wonder if that deserves a comment. Thanks, NeilBrown > } > return dentry; > } > @@ -1837,7 +1837,7 @@ static unsigned int d_op_flags(const struct dentry_operations *op) > return flags; > } > > -void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) > +static void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) > { > unsigned int flags = d_op_flags(op); > WARN_ON_ONCE(dentry->d_op); > @@ -1846,7 +1846,6 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) > if (flags) > dentry->d_flags |= flags; > } > -EXPORT_SYMBOL(d_set_d_op); > > void set_default_d_op(struct super_block *s, const struct dentry_operations *ops) > { > diff --git a/include/linux/dcache.h b/include/linux/dcache.h > index e8cf1d0fdd08..5a03e85f92a4 100644 > --- a/include/linux/dcache.h > +++ b/include/linux/dcache.h > @@ -242,7 +242,6 @@ extern void d_instantiate_new(struct dentry *, struct inode *); > extern void __d_drop(struct dentry *dentry); > extern void d_drop(struct dentry *dentry); > extern void d_delete(struct dentry *); > -extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op); > > /* allocate/de-allocate */ > extern struct dentry * d_alloc(struct dentry *, const struct qstr *); > -- > 2.39.5 > >
On Mon, Feb 24, 2025 at 09:20:39PM +0000, Al Viro wrote: > Convert the last user (d_alloc_pseudo()) and be done with that. > Any out-of-tree filesystem using it should switch to d_splice_alias_ops() > or, better yet, check whether it really needs to have ->d_op vary among > its dentries. > > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> > --- Reviewed-by: Christian Brauner <brauner@kernel.org> > Documentation/filesystems/porting.rst | 11 +++++++++++ > fs/dcache.c | 5 ++--- > include/linux/dcache.h | 1 - > 3 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst > index 004cd69617a2..61b5771dde53 100644 > --- a/Documentation/filesystems/porting.rst > +++ b/Documentation/filesystems/porting.rst > @@ -1164,3 +1164,14 @@ magic. > > If your filesystem sets the default dentry_operations, use set_default_d_op() > rather than manually setting sb->s_d_op. > + > +--- > + > +**mandatory** > + > +d_set_d_op() is no longer exported (or public, for that matter); _if_ > +your filesystem really needed that, make use of d_splice_alias_ops() > +to have them set. Better yet, think hard whether you need different > +->d_op for different dentries - if not, just use set_default_d_op() > +at mount time and be done with that. Currently procfs is the only > +thing that really needs ->d_op varying between dentries. > diff --git a/fs/dcache.c b/fs/dcache.c > index a4795617c3db..29db27228d97 100644 > --- a/fs/dcache.c > +++ b/fs/dcache.c > @@ -1796,7 +1796,7 @@ struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name) > if (likely(dentry)) { > dentry->d_flags |= DCACHE_NORCU; > if (!dentry->d_op) > - d_set_d_op(dentry, &anon_ops); > + dentry->d_op = &anon_ops; > } > return dentry; > } > @@ -1837,7 +1837,7 @@ static unsigned int d_op_flags(const struct dentry_operations *op) > return flags; > } > > -void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) > +static void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) > { > unsigned int flags = d_op_flags(op); > WARN_ON_ONCE(dentry->d_op); > @@ -1846,7 +1846,6 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) > if (flags) > dentry->d_flags |= flags; > } > -EXPORT_SYMBOL(d_set_d_op); > > void set_default_d_op(struct super_block *s, const struct dentry_operations *ops) > { > diff --git a/include/linux/dcache.h b/include/linux/dcache.h > index e8cf1d0fdd08..5a03e85f92a4 100644 > --- a/include/linux/dcache.h > +++ b/include/linux/dcache.h > @@ -242,7 +242,6 @@ extern void d_instantiate_new(struct dentry *, struct inode *); > extern void __d_drop(struct dentry *dentry); > extern void d_drop(struct dentry *dentry); > extern void d_delete(struct dentry *); > -extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op); > > /* allocate/de-allocate */ > extern struct dentry * d_alloc(struct dentry *, const struct qstr *); > -- > 2.39.5 >
diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst index 004cd69617a2..61b5771dde53 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1164,3 +1164,14 @@ magic. If your filesystem sets the default dentry_operations, use set_default_d_op() rather than manually setting sb->s_d_op. + +--- + +**mandatory** + +d_set_d_op() is no longer exported (or public, for that matter); _if_ +your filesystem really needed that, make use of d_splice_alias_ops() +to have them set. Better yet, think hard whether you need different +->d_op for different dentries - if not, just use set_default_d_op() +at mount time and be done with that. Currently procfs is the only +thing that really needs ->d_op varying between dentries. diff --git a/fs/dcache.c b/fs/dcache.c index a4795617c3db..29db27228d97 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1796,7 +1796,7 @@ struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name) if (likely(dentry)) { dentry->d_flags |= DCACHE_NORCU; if (!dentry->d_op) - d_set_d_op(dentry, &anon_ops); + dentry->d_op = &anon_ops; } return dentry; } @@ -1837,7 +1837,7 @@ static unsigned int d_op_flags(const struct dentry_operations *op) return flags; } -void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) +static void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) { unsigned int flags = d_op_flags(op); WARN_ON_ONCE(dentry->d_op); @@ -1846,7 +1846,6 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op) if (flags) dentry->d_flags |= flags; } -EXPORT_SYMBOL(d_set_d_op); void set_default_d_op(struct super_block *s, const struct dentry_operations *ops) { diff --git a/include/linux/dcache.h b/include/linux/dcache.h index e8cf1d0fdd08..5a03e85f92a4 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -242,7 +242,6 @@ extern void d_instantiate_new(struct dentry *, struct inode *); extern void __d_drop(struct dentry *dentry); extern void d_drop(struct dentry *dentry); extern void d_delete(struct dentry *); -extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op); /* allocate/de-allocate */ extern struct dentry * d_alloc(struct dentry *, const struct qstr *);
Convert the last user (d_alloc_pseudo()) and be done with that. Any out-of-tree filesystem using it should switch to d_splice_alias_ops() or, better yet, check whether it really needs to have ->d_op vary among its dentries. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> --- Documentation/filesystems/porting.rst | 11 +++++++++++ fs/dcache.c | 5 ++--- include/linux/dcache.h | 1 - 3 files changed, 13 insertions(+), 4 deletions(-)