make d_set_d_op() static

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.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2025-02-23 20:18:15 -05:00
parent a97dc087da
commit 691fb82ca6
3 changed files with 14 additions and 4 deletions

View File

@ -1256,3 +1256,14 @@ an extra reference to new mount - it should be returned with refcount 1.
If your filesystem sets the default dentry_operations, use set_default_d_op() If your filesystem sets the default dentry_operations, use set_default_d_op()
rather than manually setting sb->s_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.

View File

@ -1821,8 +1821,9 @@ struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name)
struct dentry *dentry = __d_alloc(sb, name); struct dentry *dentry = __d_alloc(sb, name);
if (likely(dentry)) { if (likely(dentry)) {
dentry->d_flags |= DCACHE_NORCU; dentry->d_flags |= DCACHE_NORCU;
/* d_op_flags(&anon_ops) is 0 */
if (!dentry->d_op) if (!dentry->d_op)
d_set_d_op(dentry, &anon_ops); dentry->d_op = &anon_ops;
} }
return dentry; return dentry;
} }
@ -1864,7 +1865,7 @@ static unsigned int d_op_flags(const struct dentry_operations *op)
return flags; 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); unsigned int flags = d_op_flags(op);
WARN_ON_ONCE(dentry->d_op); WARN_ON_ONCE(dentry->d_op);
@ -1873,7 +1874,6 @@ void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op)
if (flags) if (flags)
dentry->d_flags |= 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) void set_default_d_op(struct super_block *s, const struct dentry_operations *ops)
{ {

View File

@ -237,7 +237,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_drop(struct dentry *dentry); extern void d_drop(struct dentry *dentry);
extern void d_delete(struct dentry *); extern void d_delete(struct dentry *);
extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op);
/* allocate/de-allocate */ /* allocate/de-allocate */
extern struct dentry * d_alloc(struct dentry *, const struct qstr *); extern struct dentry * d_alloc(struct dentry *, const struct qstr *);