mount_pseudo(): drop 'name' argument, switch to d_make_root()
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 20 May 2019 12:44:57 +0000 (13:44 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 25 May 2019 21:59:24 +0000 (17:59 -0400)
Once upon a time we used to set ->d_name of e.g. pipefs root
so that d_path() on pipes would work.  These days it's
completely pointless - dentries of pipes are not even connected
to pipefs root.  However, mount_pseudo() had set the root
dentry name (passed as the second argument) and callers
kept inventing names to pass to it.  Including those that
didn't *have* any non-root dentries to start with...

All of that had been pointless for about 8 years now; it's
time to get rid of that cargo-culting...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
17 files changed:
arch/ia64/kernel/perfmon.c
drivers/dax/super.c
drivers/gpu/drm/drm_drv.c
drivers/misc/cxl/api.c
drivers/scsi/cxlflash/ocxl_hw.c
drivers/virtio/virtio_balloon.c
fs/aio.c
fs/anon_inodes.c
fs/block_dev.c
fs/btrfs/tests/btrfs-tests.c
fs/libfs.c
fs/nsfs.c
fs/pipe.c
include/linux/fs.h
mm/z3fold.c
mm/zsmalloc.c
net/socket.c

index 7a969f4c3534d3d2b2802e4b561202af0cdbf008..a30da6f2c28effbe41da08594465e2d2c7b07a2d 100644 (file)
@@ -602,7 +602,7 @@ static const struct dentry_operations pfmfs_dentry_operations;
 static struct dentry *
 pfmfs_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data)
 {
-       return mount_pseudo(fs_type, "pfm:", NULL, &pfmfs_dentry_operations,
+       return mount_pseudo(fs_type, NULL, &pfmfs_dentry_operations,
                        PFMFS_MAGIC);
 }
 
index 35f051efaf35d17c4656239c4e39688720a0dc06..f83814eea5ad218e59caa765d6eba9166303a3ce 100644 (file)
@@ -440,7 +440,7 @@ static const struct super_operations dax_sops = {
 static struct dentry *dax_mount(struct file_system_type *fs_type,
                int flags, const char *dev_name, void *data)
 {
-       return mount_pseudo(fs_type, "dax:", &dax_sops, NULL, DAXFS_MAGIC);
+       return mount_pseudo(fs_type, &dax_sops, NULL, DAXFS_MAGIC);
 }
 
 static struct file_system_type dax_fs_type = {
index 8b44ac9a92ae440065faced2a8e102b42358bbc7..48365c62a190ae18333eaaa015721634a906eeb3 100644 (file)
@@ -535,11 +535,7 @@ static struct vfsmount *drm_fs_mnt;
 static struct dentry *drm_fs_mount(struct file_system_type *fs_type, int flags,
                                   const char *dev_name, void *data)
 {
-       return mount_pseudo(fs_type,
-                           "drm:",
-                           NULL,
-                           NULL,
-                           0x010203ff);
+       return mount_pseudo(fs_type, NULL, NULL, 0x010203ff);
 }
 
 static struct file_system_type drm_fs_type = {
index a59c7af798736cf77a1b9f6385946257628a6277..1f2b0535a8cfd39b522a3de7f8d6097f8c03406b 100644 (file)
@@ -40,8 +40,7 @@ static struct vfsmount *cxl_vfs_mount;
 static struct dentry *cxl_fs_mount(struct file_system_type *fs_type, int flags,
                                const char *dev_name, void *data)
 {
-       return mount_pseudo(fs_type, "cxl:", NULL, NULL,
-                       CXL_PSEUDO_FS_MAGIC);
+       return mount_pseudo(fs_type, NULL, NULL, CXL_PSEUDO_FS_MAGIC);
 }
 
 static struct file_system_type cxl_fs_type = {
index 31cfdf2c8c303d36f71a9e7f3ef5eb31017d2930..38e1fbd2b406ab6eaa84620cd41f26d6bc3fb5d3 100644 (file)
@@ -48,8 +48,7 @@ static struct dentry *ocxlflash_fs_mount(struct file_system_type *fs_type,
                                         int flags, const char *dev_name,
                                         void *data)
 {
-       return mount_pseudo(fs_type, "ocxlflash:", NULL, NULL,
-                           OCXLFLASH_FS_MAGIC);
+       return mount_pseudo(fs_type, NULL, NULL, OCXLFLASH_FS_MAGIC);
 }
 
 static struct file_system_type ocxlflash_fs_type = {
index 554d1a98d1934d34d9711373aaa74dd82e0847ed..62bafc4f2662c07bfa54b6cd3e92b5de76b1210d 100644 (file)
@@ -761,8 +761,7 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
 static struct dentry *balloon_mount(struct file_system_type *fs_type,
                int flags, const char *dev_name, void *data)
 {
-       return mount_pseudo(fs_type, "balloon-kvm:", NULL, NULL,
-                               BALLOON_KVM_MAGIC);
+       return mount_pseudo(fs_type, NULL, NULL, BALLOON_KVM_MAGIC);
 }
 
 static struct file_system_type balloon_fs = {
index 3490d1fa0e16f4f1f189727661e18696ab3a7a08..09bc35fa68103f2df6bc0e41f99cc64da0aa0dcf 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -252,8 +252,7 @@ static struct file *aio_private_file(struct kioctx *ctx, loff_t nr_pages)
 static struct dentry *aio_mount(struct file_system_type *fs_type,
                                int flags, const char *dev_name, void *data)
 {
-       struct dentry *root = mount_pseudo(fs_type, "aio:", NULL, NULL,
-                                          AIO_RING_MAGIC);
+       struct dentry *root = mount_pseudo(fs_type, NULL, NULL, AIO_RING_MAGIC);
 
        if (!IS_ERR(root))
                root->d_sb->s_iflags |= SB_I_NOEXEC;
index 91262c34b797c3932680640b3643fe360a643b97..644d0837aafe0b7c0963c157e460cc0f8e578de1 100644 (file)
@@ -41,8 +41,8 @@ static const struct dentry_operations anon_inodefs_dentry_operations = {
 static struct dentry *anon_inodefs_mount(struct file_system_type *fs_type,
                                int flags, const char *dev_name, void *data)
 {
-       return mount_pseudo(fs_type, "anon_inode:", NULL,
-                       &anon_inodefs_dentry_operations, ANON_INODE_FS_MAGIC);
+       return mount_pseudo(fs_type, NULL, &anon_inodefs_dentry_operations,
+                           ANON_INODE_FS_MAGIC);
 }
 
 static struct file_system_type anon_inode_fs_type = {
index 0f7552a87d5447c118d1873f8249eeaa73321457..3143da7b099812135772c2c50b39a55fb0ffdecb 100644 (file)
@@ -837,7 +837,7 @@ static struct dentry *bd_mount(struct file_system_type *fs_type,
        int flags, const char *dev_name, void *data)
 {
        struct dentry *dent;
-       dent = mount_pseudo(fs_type, "bdev:", &bdev_sops, NULL, BDEVFS_MAGIC);
+       dent = mount_pseudo(fs_type, &bdev_sops, NULL, BDEVFS_MAGIC);
        if (!IS_ERR(dent))
                dent->d_sb->s_iflags |= SB_I_CGROUPWB;
        return dent;
index 9238fd4f1734082a37e8e54f324818ab792e18bc..6da54323eaf8124116193fc558eab72daaed3c56 100644 (file)
@@ -36,7 +36,7 @@ static struct dentry *btrfs_test_mount(struct file_system_type *fs_type,
                                       int flags, const char *dev_name,
                                       void *data)
 {
-       return mount_pseudo(fs_type, "btrfs_test:", &btrfs_test_super_ops,
+       return mount_pseudo(fs_type, &btrfs_test_super_ops,
                            NULL, BTRFS_TEST_MAGIC);
 }
 
index 4b59b1816efbaf31fb6e4cd831363e06c7b6bb3b..030e545f586eaa3a21f7e5509f31aa83d0343793 100644 (file)
@@ -239,14 +239,12 @@ static const struct super_operations simple_super_operations = {
  * Common helper for pseudo-filesystems (sockfs, pipefs, bdev - stuff that
  * will never be mountable)
  */
-struct dentry *mount_pseudo_xattr(struct file_system_type *fs_type, char *name,
+struct dentry *mount_pseudo_xattr(struct file_system_type *fs_type,
        const struct super_operations *ops, const struct xattr_handler **xattr,
        const struct dentry_operations *dops, unsigned long magic)
 {
        struct super_block *s;
-       struct dentry *dentry;
        struct inode *root;
-       struct qstr d_name = QSTR_INIT(name, strlen(name));
 
        s = sget_userns(fs_type, NULL, set_anon_super, SB_KERNMOUNT|SB_NOUSER,
                        &init_user_ns, NULL);
@@ -271,13 +269,9 @@ struct dentry *mount_pseudo_xattr(struct file_system_type *fs_type, char *name,
        root->i_ino = 1;
        root->i_mode = S_IFDIR | S_IRUSR | S_IWUSR;
        root->i_atime = root->i_mtime = root->i_ctime = current_time(root);
-       dentry = __d_alloc(s, &d_name);
-       if (!dentry) {
-               iput(root);
+       s->s_root = d_make_root(root);
+       if (!s->s_root)
                goto Enomem;
-       }
-       d_instantiate(dentry, root);
-       s->s_root = dentry;
        s->s_d_op = dops;
        s->s_flags |= SB_ACTIVE;
        return dget(s->s_root);
index e3bf08c5af4114b88a26f507c3679a3418ed40c5..b3c49ddc0f859be3c76792c0adbe7455e10fe82c 100644 (file)
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -261,7 +261,7 @@ static const struct super_operations nsfs_ops = {
 static struct dentry *nsfs_mount(struct file_system_type *fs_type,
                        int flags, const char *dev_name, void *data)
 {
-       return mount_pseudo(fs_type, "nsfs:", &nsfs_ops,
+       return mount_pseudo(fs_type, &nsfs_ops,
                        &ns_dentry_operations, NSFS_MAGIC);
 }
 static struct file_system_type nsfs = {
index 41065901106b09d4365ebc13ee6cfa7b6465339b..99a023730e6f04125c612dc8b4c74c041013d4a1 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1185,7 +1185,7 @@ static const struct super_operations pipefs_ops = {
 static struct dentry *pipefs_mount(struct file_system_type *fs_type,
                         int flags, const char *dev_name, void *data)
 {
-       return mount_pseudo(fs_type, "pipe:", &pipefs_ops,
+       return mount_pseudo(fs_type, &pipefs_ops,
                        &pipefs_dentry_operations, PIPEFS_MAGIC);
 }
 
index f7fdfe93e25d3e94cc4bc7b053ead12667607cc9..b06251dd429f7450d902a20ff2da1c02a0508cc8 100644 (file)
@@ -2257,18 +2257,18 @@ struct super_block *sget(struct file_system_type *type,
                        int (*test)(struct super_block *,void *),
                        int (*set)(struct super_block *,void *),
                        int flags, void *data);
-extern struct dentry *mount_pseudo_xattr(struct file_system_type *, char *,
+extern struct dentry *mount_pseudo_xattr(struct file_system_type *,
                                         const struct super_operations *ops,
                                         const struct xattr_handler **xattr,
                                         const struct dentry_operations *dops,
                                         unsigned long);
 
 static inline struct dentry *
-mount_pseudo(struct file_system_type *fs_type, char *name,
+mount_pseudo(struct file_system_type *fs_type,
             const struct super_operations *ops,
             const struct dentry_operations *dops, unsigned long magic)
 {
-       return mount_pseudo_xattr(fs_type, name, ops, NULL, dops, magic);
+       return mount_pseudo_xattr(fs_type, ops, NULL, dops, magic);
 }
 
 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
index 0b14daf930a84016ab054b4a2e2acc5965ffa2c4..abeb5bcbea573bf97bc26933a36c936b65dfa038 100644 (file)
@@ -242,7 +242,7 @@ static inline void free_handle(unsigned long handle)
 static struct dentry *z3fold_do_mount(struct file_system_type *fs_type,
                                int flags, const char *dev_name, void *data)
 {
-       return mount_pseudo(fs_type, "z3fold:", NULL, NULL, 0x33);
+       return mount_pseudo(fs_type, NULL, NULL, 0x33);
 }
 
 static struct file_system_type z3fold_fs = {
index d9f831f6362500cef94432bc2c95ac09a9429910..ef230be8c03ec6a59cb2eeec8c600c8dd6de756b 100644 (file)
@@ -1817,7 +1817,7 @@ static void lock_zspage(struct zspage *zspage)
 static struct dentry *zs_mount(struct file_system_type *fs_type,
                                int flags, const char *dev_name, void *data)
 {
-       return mount_pseudo(fs_type, "zsmalloc:", NULL, NULL, ZSMALLOC_MAGIC);
+       return mount_pseudo(fs_type, NULL, NULL, ZSMALLOC_MAGIC);
 }
 
 static struct file_system_type zsmalloc_fs = {
index 472fbefa5d9bbf080f96d6f1b88748fb056733a8..c86679584eeddf61e8302528954c18585b05d645 100644 (file)
@@ -362,7 +362,7 @@ static const struct xattr_handler *sockfs_xattr_handlers[] = {
 static struct dentry *sockfs_mount(struct file_system_type *fs_type,
                         int flags, const char *dev_name, void *data)
 {
-       return mount_pseudo_xattr(fs_type, "socket:", &sockfs_ops,
+       return mount_pseudo_xattr(fs_type, &sockfs_ops,
                                  sockfs_xattr_handlers,
                                  &sockfs_dentry_operations, SOCKFS_MAGIC);
 }