nsfs: use d_make_root()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 18 Nov 2023 21:50:29 +0000 (16:50 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 25 Nov 2023 07:49:43 +0000 (02:49 -0500)
Normally d_make_root() is used to create the root dentry of superblock;
here we use it for a different purpose, but... idiomatic or not, we
need the same operation.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/nsfs.c

index 9a4b228d42fa8c27b61efe34464084c579c5bc71..34e1e3e36733da8ed12de3582123638095f30fab 100644 (file)
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -90,12 +90,9 @@ slow:
        inode->i_fop = &ns_file_operations;
        inode->i_private = ns;
 
-       dentry = d_alloc_anon(mnt->mnt_sb);
-       if (!dentry) {
-               iput(inode);
+       dentry = d_make_root(inode);    /* not the normal use, but... */
+       if (!dentry)
                return -ENOMEM;
-       }
-       d_instantiate(dentry, inode);
        dentry->d_fsdata = (void *)ns->ops;
        d = atomic_long_cmpxchg(&ns->stashed, 0, (unsigned long)dentry);
        if (d) {