]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/nfs/super.c
nfs: Convert to separately allocated bdi
[mirror_ubuntu-bionic-kernel.git] / fs / nfs / super.c
index 6bca17883b9368865253103b2df3f26320430d2d..8d97aa70407e487b32400f7937db3a276d1edc2e 100644 (file)
@@ -531,39 +531,32 @@ static void nfs_show_mountd_netid(struct seq_file *m, struct nfs_server *nfss,
                                  int showdefaults)
 {
        struct sockaddr *sap = (struct sockaddr *) &nfss->mountd_address;
+       char *proto = NULL;
 
-       seq_printf(m, ",mountproto=");
        switch (sap->sa_family) {
        case AF_INET:
                switch (nfss->mountd_protocol) {
                case IPPROTO_UDP:
-                       seq_printf(m, RPCBIND_NETID_UDP);
+                       proto = RPCBIND_NETID_UDP;
                        break;
                case IPPROTO_TCP:
-                       seq_printf(m, RPCBIND_NETID_TCP);
+                       proto = RPCBIND_NETID_TCP;
                        break;
-               default:
-                       if (showdefaults)
-                               seq_printf(m, "auto");
                }
                break;
        case AF_INET6:
                switch (nfss->mountd_protocol) {
                case IPPROTO_UDP:
-                       seq_printf(m, RPCBIND_NETID_UDP6);
+                       proto = RPCBIND_NETID_UDP6;
                        break;
                case IPPROTO_TCP:
-                       seq_printf(m, RPCBIND_NETID_TCP6);
+                       proto = RPCBIND_NETID_TCP6;
                        break;
-               default:
-                       if (showdefaults)
-                               seq_printf(m, "auto");
                }
                break;
-       default:
-               if (showdefaults)
-                       seq_printf(m, "auto");
        }
+       if (proto || showdefaults)
+               seq_printf(m, ",mountproto=%s", proto ?: "auto");
 }
 
 static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
@@ -2322,18 +2315,17 @@ inline void nfs_initialise_sb(struct super_block *sb)
                sb->s_blocksize = nfs_block_bits(server->wsize,
                                                 &sb->s_blocksize_bits);
 
-       sb->s_bdi = &server->backing_dev_info;
-
        nfs_super_set_maxbytes(sb, server->maxfilesize);
 }
 
 /*
  * Finish setting up an NFS2/3 superblock
  */
-void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
+int nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
 {
        struct nfs_parsed_mount_data *data = mount_info->parsed;
        struct nfs_server *server = NFS_SB(sb);
+       int ret;
 
        sb->s_blocksize_bits = 0;
        sb->s_blocksize = 0;
@@ -2351,13 +2343,21 @@ void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info)
        }
 
        nfs_initialise_sb(sb);
+
+       ret = super_setup_bdi_name(sb, "%u:%u", MAJOR(server->s_dev),
+                                  MINOR(server->s_dev));
+       if (ret)
+               return ret;
+       sb->s_bdi->ra_pages = server->rpages * NFS_MAX_READAHEAD;
+       return 0;
+
 }
 EXPORT_SYMBOL_GPL(nfs_fill_super);
 
 /*
  * Finish setting up a cloned NFS2/3/4 superblock
  */
-void nfs_clone_super(struct super_block *sb, struct nfs_mount_info *mount_info)
+int nfs_clone_super(struct super_block *sb, struct nfs_mount_info *mount_info)
 {
        const struct super_block *old_sb = mount_info->cloned->sb;
        struct nfs_server *server = NFS_SB(sb);
@@ -2377,6 +2377,11 @@ void nfs_clone_super(struct super_block *sb, struct nfs_mount_info *mount_info)
        }
 
        nfs_initialise_sb(sb);
+
+       sb->s_bdi = bdi_get(old_sb->s_bdi);
+       sb->s_iflags |= SB_I_DYNBDI;
+
+       return 0;
 }
 
 static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
@@ -2529,11 +2534,6 @@ static void nfs_get_cache_cookie(struct super_block *sb,
 }
 #endif
 
-static int nfs_bdi_register(struct nfs_server *server)
-{
-       return bdi_register_dev(&server->backing_dev_info, server->s_dev);
-}
-
 int nfs_set_sb_security(struct super_block *s, struct dentry *mntroot,
                        struct nfs_mount_info *mount_info)
 {
@@ -2601,17 +2601,14 @@ struct dentry *nfs_fs_mount_common(struct nfs_server *server,
                nfs_free_server(server);
                server = NULL;
        } else {
-               error = nfs_bdi_register(server);
-               if (error) {
-                       mntroot = ERR_PTR(error);
-                       goto error_splat_super;
-               }
                server->super = s;
        }
 
        if (!s->s_root) {
                /* initial superblock/root creation */
-               mount_info->fill_super(s, mount_info);
+               error = mount_info->fill_super(s, mount_info);
+               if (error)
+                       goto error_splat_super;
                nfs_get_cache_cookie(s, mount_info->parsed, mount_info->cloned);
        }