Skip to content

Commit 9024b4c

Browse files
author
Al Viro
committed
d_alloc_pseudo(): move setting ->d_op there from the (sole) caller
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent f2824db commit 9024b4c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

fs/dcache.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1890,9 +1890,15 @@ struct dentry *d_alloc_cursor(struct dentry * parent)
18901890
*/
18911891
struct dentry *d_alloc_pseudo(struct super_block *sb, const struct qstr *name)
18921892
{
1893+
static const struct dentry_operations anon_ops = {
1894+
.d_dname = simple_dname
1895+
};
18931896
struct dentry *dentry = __d_alloc(sb, name);
1894-
if (likely(dentry))
1897+
if (likely(dentry)) {
18951898
dentry->d_flags |= DCACHE_NORCU;
1899+
if (!sb->s_d_op)
1900+
d_set_d_op(dentry, &anon_ops);
1901+
}
18961902
return dentry;
18971903
}
18981904

fs/file_table.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,13 @@ struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt,
329329
const char *name, int flags,
330330
const struct file_operations *fops)
331331
{
332-
static const struct dentry_operations anon_ops = {
333-
.d_dname = simple_dname
334-
};
335332
struct qstr this = QSTR_INIT(name, strlen(name));
336333
struct path path;
337334
struct file *file;
338335

339336
path.dentry = d_alloc_pseudo(mnt->mnt_sb, &this);
340337
if (!path.dentry)
341338
return ERR_PTR(-ENOMEM);
342-
if (!mnt->mnt_sb->s_d_op)
343-
d_set_d_op(path.dentry, &anon_ops);
344339
path.mnt = mntget(mnt);
345340
d_instantiate(path.dentry, inode);
346341
file = alloc_file(&path, flags, fops);

0 commit comments

Comments
 (0)