NFS: Only initialize the ACL client in the v3 case
authorBryan Schumaker <bjschuma@netapp.com>
Mon, 30 Jul 2012 20:05:19 +0000 (16:05 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Mon, 30 Jul 2012 23:05:54 +0000 (19:05 -0400)
v2 and v4 don't use it, so I create two new nfs_rpc_ops functions to
initialize the ACL client only when we are using v3.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/Makefile
fs/nfs/client.c
fs/nfs/internal.h
fs/nfs/nfs3client.c [new file with mode: 0644]
fs/nfs/nfs3proc.c
fs/nfs/nfs4client.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4super.c
fs/nfs/proc.c
fs/nfs/super.c
include/linux/nfs_xdr.h

index 66dd3075e5db6189f2575518e5849e39566cfb3b..7ca0125da65ec973208442f98670a19ace4ea198 100644 (file)
@@ -10,7 +10,7 @@ nfs-y                         := client.o dir.o file.o getroot.o inode.o super.o \
                           dns_resolve.o cache_lib.o
 nfs-$(CONFIG_ROOT_NFS) += nfsroot.o
 nfs-$(CONFIG_NFS_V2)   += nfs2super.o proc.o nfs2xdr.o
-nfs-$(CONFIG_NFS_V3)   += nfs3super.o nfs3proc.o nfs3xdr.o
+nfs-$(CONFIG_NFS_V3)   += nfs3super.o nfs3client.o nfs3proc.o nfs3xdr.o
 nfs-$(CONFIG_NFS_V3_ACL)       += nfs3acl.o
 nfs-$(CONFIG_NFS_V4)   += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
                           nfs4super.o nfs4file.o delegation.o idmap.o \
index 462de24482b47066ab5e364d4e1227a22bbe407c..1f2908287cba43a82c6debdfb056d785f521c7a6 100644 (file)
@@ -83,22 +83,6 @@ struct rpc_stat nfs_rpcstat = {
        .program                = &nfs_program
 };
 
-
-#ifdef CONFIG_NFS_V3_ACL
-static struct rpc_stat         nfsacl_rpcstat = { &nfsacl_program };
-static const struct rpc_version *nfsacl_version[] = {
-       [3]                     = &nfsacl_version3,
-};
-
-const struct rpc_program nfsacl_program = {
-       .name                   = "nfsacl",
-       .number                 = NFS_ACL_PROGRAM,
-       .nrvers                 = ARRAY_SIZE(nfsacl_version),
-       .version                = nfsacl_version,
-       .stats                  = &nfsacl_rpcstat,
-};
-#endif  /* CONFIG_NFS_V3_ACL */
-
 static struct nfs_subversion *find_nfs_version(unsigned int version)
 {
        struct nfs_subversion *nfs;
@@ -695,36 +679,6 @@ static int nfs_start_lockd(struct nfs_server *server)
        return 0;
 }
 
-/*
- * Initialise an NFSv3 ACL client connection
- */
-#ifdef CONFIG_NFS_V3_ACL
-static void nfs_init_server_aclclient(struct nfs_server *server)
-{
-       if (server->nfs_client->rpc_ops->version != 3)
-               goto out_noacl;
-       if (server->flags & NFS_MOUNT_NOACL)
-               goto out_noacl;
-
-       server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3);
-       if (IS_ERR(server->client_acl))
-               goto out_noacl;
-
-       /* No errors! Assume that Sun nfsacls are supported */
-       server->caps |= NFS_CAP_ACLS;
-       return;
-
-out_noacl:
-       server->caps &= ~NFS_CAP_ACLS;
-}
-#else
-static inline void nfs_init_server_aclclient(struct nfs_server *server)
-{
-       server->flags &= ~NFS_MOUNT_NOACL;
-       server->caps &= ~NFS_CAP_ACLS;
-}
-#endif
-
 /*
  * Create a general RPC client
  */
@@ -874,8 +828,6 @@ static int nfs_init_server(struct nfs_server *server,
        server->mountd_protocol = data->mount_server.protocol;
 
        server->namelen  = data->namlen;
-       /* Create a client RPC handle for the NFSv3 ACL management interface */
-       nfs_init_server_aclclient(server);
        dprintk("<-- nfs_init_server() = 0 [new %p]\n", clp);
        return 0;
 
@@ -1108,8 +1060,7 @@ void nfs_free_server(struct nfs_server *server)
  * Create a version 2 or 3 volume record
  * - keyed on server and FSID
  */
-struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data,
-                                    struct nfs_fh *mntfh,
+struct nfs_server *nfs_create_server(struct nfs_mount_info *mount_info,
                                     struct nfs_subversion *nfs_mod)
 {
        struct nfs_server *server;
@@ -1126,7 +1077,7 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data,
                goto error;
 
        /* Get a client representation */
-       error = nfs_init_server(server, data, nfs_mod);
+       error = nfs_init_server(server, mount_info->parsed, nfs_mod);
        if (error < 0)
                goto error;
 
@@ -1135,13 +1086,13 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data,
        BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
 
        /* Probe the root fh to retrieve its FSID */
-       error = nfs_probe_fsinfo(server, mntfh, fattr);
+       error = nfs_probe_fsinfo(server, mount_info->mntfh, fattr);
        if (error < 0)
                goto error;
        if (server->nfs_client->rpc_ops->version == 3) {
                if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN)
                        server->namelen = NFS3_MAXNAMLEN;
-               if (!(data->flags & NFS_MOUNT_NORDIRPLUS))
+               if (!(mount_info->parsed->flags & NFS_MOUNT_NORDIRPLUS))
                        server->caps |= NFS_CAP_READDIRPLUS;
        } else {
                if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN)
@@ -1149,7 +1100,7 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data,
        }
 
        if (!(fattr->valid & NFS_ATTR_FATTR)) {
-               error = server->nfs_client->rpc_ops->getattr(server, mntfh, fattr);
+               error = nfs_mod->rpc_ops->getattr(server, mount_info->mntfh, fattr);
                if (error < 0) {
                        dprintk("nfs_create_server: getattr error = %d\n", -error);
                        goto error;
@@ -1210,8 +1161,6 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
                        flavor);
        if (error < 0)
                goto out_free_server;
-       if (!IS_ERR(source->client_acl))
-               nfs_init_server_aclclient(server);
 
        /* probe the filesystem info for this server filesystem */
        error = nfs_probe_fsinfo(server, fh, fattr_fsinfo);
index 3364eccd17efb628823e5aa155baa797d92d02ff..2151bafd55b4ddaf619afab155feca7ade308761 100644 (file)
@@ -187,13 +187,11 @@ extern struct nfs_client *nfs4_find_client_ident(struct net *, int);
 extern struct nfs_client *
 nfs4_find_client_sessionid(struct net *, const struct sockaddr *,
                                struct nfs4_sessionid *);
-extern struct nfs_server *nfs_create_server(
-                                       const struct nfs_parsed_mount_data *,
-                                       struct nfs_fh *,
+extern struct nfs_server *nfs_create_server(struct nfs_mount_info *,
                                        struct nfs_subversion *);
 extern struct nfs_server *nfs4_create_server(
-                                       const struct nfs_parsed_mount_data *,
-                                       struct nfs_fh *);
+                                       struct nfs_mount_info *,
+                                       struct nfs_subversion *);
 extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *,
                                                      struct nfs_fh *);
 extern void nfs_free_server(struct nfs_server *server);
@@ -225,6 +223,13 @@ static inline void nfs_fs_proc_exit(void)
 int nfs_sockaddr_match_ipaddr(const struct sockaddr *, const struct sockaddr *);
 #endif
 
+/* nfs3client.c */
+#ifdef CONFIG_NFS_V3
+struct nfs_server *nfs3_create_server(struct nfs_mount_info *, struct nfs_subversion *);
+struct nfs_server *nfs3_clone_server(struct nfs_server *, struct nfs_fh *,
+                                    struct nfs_fattr *, rpc_authflavor_t);
+#endif
+
 /* callback_xdr.c */
 extern struct svc_version nfs4_callback_version1;
 extern struct svc_version nfs4_callback_version4;
diff --git a/fs/nfs/nfs3client.c b/fs/nfs/nfs3client.c
new file mode 100644 (file)
index 0000000..b3fc65e
--- /dev/null
@@ -0,0 +1,65 @@
+#include <linux/nfs_fs.h>
+#include <linux/nfs_mount.h>
+#include "internal.h"
+
+#ifdef CONFIG_NFS_V3_ACL
+static struct rpc_stat         nfsacl_rpcstat = { &nfsacl_program };
+static const struct rpc_version *nfsacl_version[] = {
+       [3]                     = &nfsacl_version3,
+};
+
+const struct rpc_program nfsacl_program = {
+       .name                   = "nfsacl",
+       .number                 = NFS_ACL_PROGRAM,
+       .nrvers                 = ARRAY_SIZE(nfsacl_version),
+       .version                = nfsacl_version,
+       .stats                  = &nfsacl_rpcstat,
+};
+
+/*
+ * Initialise an NFSv3 ACL client connection
+ */
+static void nfs_init_server_aclclient(struct nfs_server *server)
+{
+       if (server->flags & NFS_MOUNT_NOACL)
+               goto out_noacl;
+
+       server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3);
+       if (IS_ERR(server->client_acl))
+               goto out_noacl;
+
+       /* No errors! Assume that Sun nfsacls are supported */
+       server->caps |= NFS_CAP_ACLS;
+       return;
+
+out_noacl:
+       server->caps &= ~NFS_CAP_ACLS;
+}
+#else
+static inline void nfs_init_server_aclclient(struct nfs_server *server)
+{
+       server->flags &= ~NFS_MOUNT_NOACL;
+       server->caps &= ~NFS_CAP_ACLS;
+}
+#endif
+
+struct nfs_server *nfs3_create_server(struct nfs_mount_info *mount_info,
+                                     struct nfs_subversion *nfs_mod)
+{
+       struct nfs_server *server = nfs_create_server(mount_info, nfs_mod);
+       /* Create a client RPC handle for the NFS v3 ACL management interface */
+       if (!IS_ERR(server))
+               nfs_init_server_aclclient(server);
+       return server;
+}
+
+struct nfs_server *nfs3_clone_server(struct nfs_server *source,
+                                    struct nfs_fh *fh,
+                                    struct nfs_fattr *fattr,
+                                    rpc_authflavor_t flavor)
+{
+       struct nfs_server *server = nfs_clone_server(source, fh, fattr, flavor);
+       if (!IS_ERR(server) && !IS_ERR(source->client_acl))
+               nfs_init_server_aclclient(server);
+       return server;
+}
index 4f4cb8e49716493f5a4841c1377b16c6af2604c7..0952c791df36eb4f1aa58beb20732c9af67a3098 100644 (file)
@@ -969,4 +969,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
        .alloc_client   = nfs_alloc_client,
        .init_client    = nfs_init_client,
        .free_client    = nfs_free_client,
+       .create_server  = nfs3_create_server,
+       .clone_server   = nfs3_clone_server,
 };
index 769e798b39593c4a674880b2c4b3aa597d482f9c..b2d409d2805a5e4460bd1bf3bc35740bed9a7589 100644 (file)
@@ -574,8 +574,10 @@ error:
  * Create a version 4 volume record
  * - keyed on server and FSID
  */
-struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
-                                     struct nfs_fh *mntfh)
+/*struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
+                                     struct nfs_fh *mntfh)*/
+struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info,
+                                     struct nfs_subversion *nfs_mod)
 {
        struct nfs_server *server;
        int error;
@@ -587,11 +589,11 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
                return ERR_PTR(-ENOMEM);
 
        /* set up the general RPC client */
-       error = nfs4_init_server(server, data);
+       error = nfs4_init_server(server, mount_info->parsed);
        if (error < 0)
                goto error;
 
-       error = nfs4_server_common_setup(server, mntfh);
+       error = nfs4_server_common_setup(server, mount_info->mntfh);
        if (error < 0)
                goto error;
 
index eb4ba1d99df92712aa4e748e76a7553c65687491..36c6432aac7baf6a993760ab74e7a2f2d3ca57aa 100644 (file)
@@ -6916,6 +6916,8 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
        .alloc_client   = nfs4_alloc_client,
        .init_client    = nfs4_init_client,
        .free_client    = nfs4_free_client,
+       .create_server  = nfs4_create_server,
+       .clone_server   = nfs_clone_server,
 };
 
 static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = {
index 9384f666b6abaa3f79fdd67bd3c86436514b7afd..a628362566655a4abb54ee29ada3670093133699 100644 (file)
@@ -105,7 +105,7 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags,
        mount_info->set_security = nfs_set_sb_security;
 
        /* Get a volume representation */
-       server = nfs4_create_server(mount_info->parsed, mount_info->mntfh);
+       server = nfs4_create_server(mount_info, &nfs_v4);
        if (IS_ERR(server)) {
                mntroot = ERR_CAST(server);
                goto out;
index ebb3d9c5227bcba5cf3340043c5099e37a1b6f69..50a88c3546ed9eebdee4c4755ca5b7f6d35489f0 100644 (file)
@@ -817,4 +817,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
        .alloc_client   = nfs_alloc_client,
        .init_client    = nfs_init_client,
        .free_client    = nfs_free_client,
+       .create_server  = nfs_create_server,
+       .clone_server   = nfs_clone_server,
 };
index 5fca59d73e40fd16a7c4995b0d098f4e63b6fe22..a5f9fb3bfdccafbb9bd9606d4948f63a1e6e17e0 100644 (file)
@@ -1664,7 +1664,7 @@ struct dentry *nfs_try_mount(int flags, const char *dev_name,
        }
 
        /* Get a volume representation */
-       server = nfs_create_server(mount_info->parsed, mount_info->mntfh, nfs_mod);
+       server = nfs_mod->rpc_ops->create_server(mount_info, nfs_mod);
        if (IS_ERR(server))
                return ERR_CAST(server);
 
@@ -2458,7 +2458,7 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
        mount_info.mntfh = mount_info.cloned->fh;
 
        /* create a new volume representation */
-       server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor);
+       server = nfs_mod->rpc_ops->clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor);
        if (IS_ERR(server)) {
                error = PTR_ERR(server);
                goto out_err;
index bc7415baf44dc6c4398d356bc97420fa9b85b7bf..63118206299454970f639e7b2395e39aff8132d4 100644 (file)
@@ -1439,6 +1439,9 @@ struct nfs_rpc_ops {
                (*init_client) (struct nfs_client *, const struct rpc_timeout *,
                                const char *, rpc_authflavor_t);
        void    (*free_client) (struct nfs_client *);
+       struct nfs_server *(*create_server)(struct nfs_mount_info *, struct nfs_subversion *);
+       struct nfs_server *(*clone_server)(struct nfs_server *, struct nfs_fh *,
+                                          struct nfs_fattr *, rpc_authflavor_t);
 };
 
 /*