aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2012-07-30 16:05:19 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-07-30 19:05:54 -0400
commit1179acc6a3e260bc4edc74fa94f6c7908290eaec (patch)
treef84a56e4cc1ea6347383b29c83df19eae05eea0f /fs/nfs
parentff9099f26645818563c8d396a154c2ce6ee422eb (diff)
NFS: Only initialize the ACL client in the v3 case
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>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/Makefile2
-rw-r--r--fs/nfs/client.c61
-rw-r--r--fs/nfs/internal.h15
-rw-r--r--fs/nfs/nfs3client.c65
-rw-r--r--fs/nfs/nfs3proc.c2
-rw-r--r--fs/nfs/nfs4client.c10
-rw-r--r--fs/nfs/nfs4proc.c2
-rw-r--r--fs/nfs/nfs4super.c2
-rw-r--r--fs/nfs/proc.c2
-rw-r--r--fs/nfs/super.c4
10 files changed, 96 insertions, 69 deletions
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index 66dd3075e5db..7ca0125da65e 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -10,7 +10,7 @@ nfs-y := client.o dir.o file.o getroot.o inode.o super.o \
10 dns_resolve.o cache_lib.o 10 dns_resolve.o cache_lib.o
11nfs-$(CONFIG_ROOT_NFS) += nfsroot.o 11nfs-$(CONFIG_ROOT_NFS) += nfsroot.o
12nfs-$(CONFIG_NFS_V2) += nfs2super.o proc.o nfs2xdr.o 12nfs-$(CONFIG_NFS_V2) += nfs2super.o proc.o nfs2xdr.o
13nfs-$(CONFIG_NFS_V3) += nfs3super.o nfs3proc.o nfs3xdr.o 13nfs-$(CONFIG_NFS_V3) += nfs3super.o nfs3client.o nfs3proc.o nfs3xdr.o
14nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o 14nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o
15nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ 15nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
16 nfs4super.o nfs4file.o delegation.o idmap.o \ 16 nfs4super.o nfs4file.o delegation.o idmap.o \
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 462de24482b4..1f2908287cba 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -83,22 +83,6 @@ struct rpc_stat nfs_rpcstat = {
83 .program = &nfs_program 83 .program = &nfs_program
84}; 84};
85 85
86
87#ifdef CONFIG_NFS_V3_ACL
88static struct rpc_stat nfsacl_rpcstat = { &nfsacl_program };
89static const struct rpc_version *nfsacl_version[] = {
90 [3] = &nfsacl_version3,
91};
92
93const struct rpc_program nfsacl_program = {
94 .name = "nfsacl",
95 .number = NFS_ACL_PROGRAM,
96 .nrvers = ARRAY_SIZE(nfsacl_version),
97 .version = nfsacl_version,
98 .stats = &nfsacl_rpcstat,
99};
100#endif /* CONFIG_NFS_V3_ACL */
101
102static struct nfs_subversion *find_nfs_version(unsigned int version) 86static struct nfs_subversion *find_nfs_version(unsigned int version)
103{ 87{
104 struct nfs_subversion *nfs; 88 struct nfs_subversion *nfs;
@@ -696,36 +680,6 @@ static int nfs_start_lockd(struct nfs_server *server)
696} 680}
697 681
698/* 682/*
699 * Initialise an NFSv3 ACL client connection
700 */
701#ifdef CONFIG_NFS_V3_ACL
702static void nfs_init_server_aclclient(struct nfs_server *server)
703{
704 if (server->nfs_client->rpc_ops->version != 3)
705 goto out_noacl;
706 if (server->flags & NFS_MOUNT_NOACL)
707 goto out_noacl;
708
709 server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3);
710 if (IS_ERR(server->client_acl))
711 goto out_noacl;
712
713 /* No errors! Assume that Sun nfsacls are supported */
714 server->caps |= NFS_CAP_ACLS;
715 return;
716
717out_noacl:
718 server->caps &= ~NFS_CAP_ACLS;
719}
720#else
721static inline void nfs_init_server_aclclient(struct nfs_server *server)
722{
723 server->flags &= ~NFS_MOUNT_NOACL;
724 server->caps &= ~NFS_CAP_ACLS;
725}
726#endif
727
728/*
729 * Create a general RPC client 683 * Create a general RPC client
730 */ 684 */
731int nfs_init_server_rpcclient(struct nfs_server *server, 685int nfs_init_server_rpcclient(struct nfs_server *server,
@@ -874,8 +828,6 @@ static int nfs_init_server(struct nfs_server *server,
874 server->mountd_protocol = data->mount_server.protocol; 828 server->mountd_protocol = data->mount_server.protocol;
875 829
876 server->namelen = data->namlen; 830 server->namelen = data->namlen;
877 /* Create a client RPC handle for the NFSv3 ACL management interface */
878 nfs_init_server_aclclient(server);
879 dprintk("<-- nfs_init_server() = 0 [new %p]\n", clp); 831 dprintk("<-- nfs_init_server() = 0 [new %p]\n", clp);
880 return 0; 832 return 0;
881 833
@@ -1108,8 +1060,7 @@ void nfs_free_server(struct nfs_server *server)
1108 * Create a version 2 or 3 volume record 1060 * Create a version 2 or 3 volume record
1109 * - keyed on server and FSID 1061 * - keyed on server and FSID
1110 */ 1062 */
1111struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, 1063struct nfs_server *nfs_create_server(struct nfs_mount_info *mount_info,
1112 struct nfs_fh *mntfh,
1113 struct nfs_subversion *nfs_mod) 1064 struct nfs_subversion *nfs_mod)
1114{ 1065{
1115 struct nfs_server *server; 1066 struct nfs_server *server;
@@ -1126,7 +1077,7 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data,
1126 goto error; 1077 goto error;
1127 1078
1128 /* Get a client representation */ 1079 /* Get a client representation */
1129 error = nfs_init_server(server, data, nfs_mod); 1080 error = nfs_init_server(server, mount_info->parsed, nfs_mod);
1130 if (error < 0) 1081 if (error < 0)
1131 goto error; 1082 goto error;
1132 1083
@@ -1135,13 +1086,13 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data,
1135 BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); 1086 BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
1136 1087
1137 /* Probe the root fh to retrieve its FSID */ 1088 /* Probe the root fh to retrieve its FSID */
1138 error = nfs_probe_fsinfo(server, mntfh, fattr); 1089 error = nfs_probe_fsinfo(server, mount_info->mntfh, fattr);
1139 if (error < 0) 1090 if (error < 0)
1140 goto error; 1091 goto error;
1141 if (server->nfs_client->rpc_ops->version == 3) { 1092 if (server->nfs_client->rpc_ops->version == 3) {
1142 if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN) 1093 if (server->namelen == 0 || server->namelen > NFS3_MAXNAMLEN)
1143 server->namelen = NFS3_MAXNAMLEN; 1094 server->namelen = NFS3_MAXNAMLEN;
1144 if (!(data->flags & NFS_MOUNT_NORDIRPLUS)) 1095 if (!(mount_info->parsed->flags & NFS_MOUNT_NORDIRPLUS))
1145 server->caps |= NFS_CAP_READDIRPLUS; 1096 server->caps |= NFS_CAP_READDIRPLUS;
1146 } else { 1097 } else {
1147 if (server->namelen == 0 || server->namelen > NFS2_MAXNAMLEN) 1098 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,
1149 } 1100 }
1150 1101
1151 if (!(fattr->valid & NFS_ATTR_FATTR)) { 1102 if (!(fattr->valid & NFS_ATTR_FATTR)) {
1152 error = server->nfs_client->rpc_ops->getattr(server, mntfh, fattr); 1103 error = nfs_mod->rpc_ops->getattr(server, mount_info->mntfh, fattr);
1153 if (error < 0) { 1104 if (error < 0) {
1154 dprintk("nfs_create_server: getattr error = %d\n", -error); 1105 dprintk("nfs_create_server: getattr error = %d\n", -error);
1155 goto error; 1106 goto error;
@@ -1210,8 +1161,6 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
1210 flavor); 1161 flavor);
1211 if (error < 0) 1162 if (error < 0)
1212 goto out_free_server; 1163 goto out_free_server;
1213 if (!IS_ERR(source->client_acl))
1214 nfs_init_server_aclclient(server);
1215 1164
1216 /* probe the filesystem info for this server filesystem */ 1165 /* probe the filesystem info for this server filesystem */
1217 error = nfs_probe_fsinfo(server, fh, fattr_fsinfo); 1166 error = nfs_probe_fsinfo(server, fh, fattr_fsinfo);
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 3364eccd17ef..2151bafd55b4 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -187,13 +187,11 @@ extern struct nfs_client *nfs4_find_client_ident(struct net *, int);
187extern struct nfs_client * 187extern struct nfs_client *
188nfs4_find_client_sessionid(struct net *, const struct sockaddr *, 188nfs4_find_client_sessionid(struct net *, const struct sockaddr *,
189 struct nfs4_sessionid *); 189 struct nfs4_sessionid *);
190extern struct nfs_server *nfs_create_server( 190extern struct nfs_server *nfs_create_server(struct nfs_mount_info *,
191 const struct nfs_parsed_mount_data *,
192 struct nfs_fh *,
193 struct nfs_subversion *); 191 struct nfs_subversion *);
194extern struct nfs_server *nfs4_create_server( 192extern struct nfs_server *nfs4_create_server(
195 const struct nfs_parsed_mount_data *, 193 struct nfs_mount_info *,
196 struct nfs_fh *); 194 struct nfs_subversion *);
197extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *, 195extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *,
198 struct nfs_fh *); 196 struct nfs_fh *);
199extern void nfs_free_server(struct nfs_server *server); 197extern void nfs_free_server(struct nfs_server *server);
@@ -225,6 +223,13 @@ static inline void nfs_fs_proc_exit(void)
225int nfs_sockaddr_match_ipaddr(const struct sockaddr *, const struct sockaddr *); 223int nfs_sockaddr_match_ipaddr(const struct sockaddr *, const struct sockaddr *);
226#endif 224#endif
227 225
226/* nfs3client.c */
227#ifdef CONFIG_NFS_V3
228struct nfs_server *nfs3_create_server(struct nfs_mount_info *, struct nfs_subversion *);
229struct nfs_server *nfs3_clone_server(struct nfs_server *, struct nfs_fh *,
230 struct nfs_fattr *, rpc_authflavor_t);
231#endif
232
228/* callback_xdr.c */ 233/* callback_xdr.c */
229extern struct svc_version nfs4_callback_version1; 234extern struct svc_version nfs4_callback_version1;
230extern struct svc_version nfs4_callback_version4; 235extern struct svc_version nfs4_callback_version4;
diff --git a/fs/nfs/nfs3client.c b/fs/nfs/nfs3client.c
new file mode 100644
index 000000000000..b3fc65ef39ca
--- /dev/null
+++ b/fs/nfs/nfs3client.c
@@ -0,0 +1,65 @@
1#include <linux/nfs_fs.h>
2#include <linux/nfs_mount.h>
3#include "internal.h"
4
5#ifdef CONFIG_NFS_V3_ACL
6static struct rpc_stat nfsacl_rpcstat = { &nfsacl_program };
7static const struct rpc_version *nfsacl_version[] = {
8 [3] = &nfsacl_version3,
9};
10
11const struct rpc_program nfsacl_program = {
12 .name = "nfsacl",
13 .number = NFS_ACL_PROGRAM,
14 .nrvers = ARRAY_SIZE(nfsacl_version),
15 .version = nfsacl_version,
16 .stats = &nfsacl_rpcstat,
17};
18
19/*
20 * Initialise an NFSv3 ACL client connection
21 */
22static void nfs_init_server_aclclient(struct nfs_server *server)
23{
24 if (server->flags & NFS_MOUNT_NOACL)
25 goto out_noacl;
26
27 server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3);
28 if (IS_ERR(server->client_acl))
29 goto out_noacl;
30
31 /* No errors! Assume that Sun nfsacls are supported */
32 server->caps |= NFS_CAP_ACLS;
33 return;
34
35out_noacl:
36 server->caps &= ~NFS_CAP_ACLS;
37}
38#else
39static inline void nfs_init_server_aclclient(struct nfs_server *server)
40{
41 server->flags &= ~NFS_MOUNT_NOACL;
42 server->caps &= ~NFS_CAP_ACLS;
43}
44#endif
45
46struct nfs_server *nfs3_create_server(struct nfs_mount_info *mount_info,
47 struct nfs_subversion *nfs_mod)
48{
49 struct nfs_server *server = nfs_create_server(mount_info, nfs_mod);
50 /* Create a client RPC handle for the NFS v3 ACL management interface */
51 if (!IS_ERR(server))
52 nfs_init_server_aclclient(server);
53 return server;
54}
55
56struct nfs_server *nfs3_clone_server(struct nfs_server *source,
57 struct nfs_fh *fh,
58 struct nfs_fattr *fattr,
59 rpc_authflavor_t flavor)
60{
61 struct nfs_server *server = nfs_clone_server(source, fh, fattr, flavor);
62 if (!IS_ERR(server) && !IS_ERR(source->client_acl))
63 nfs_init_server_aclclient(server);
64 return server;
65}
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 4f4cb8e49716..0952c791df36 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -969,4 +969,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
969 .alloc_client = nfs_alloc_client, 969 .alloc_client = nfs_alloc_client,
970 .init_client = nfs_init_client, 970 .init_client = nfs_init_client,
971 .free_client = nfs_free_client, 971 .free_client = nfs_free_client,
972 .create_server = nfs3_create_server,
973 .clone_server = nfs3_clone_server,
972}; 974};
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 769e798b3959..b2d409d2805a 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -574,8 +574,10 @@ error:
574 * Create a version 4 volume record 574 * Create a version 4 volume record
575 * - keyed on server and FSID 575 * - keyed on server and FSID
576 */ 576 */
577struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, 577/*struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
578 struct nfs_fh *mntfh) 578 struct nfs_fh *mntfh)*/
579struct nfs_server *nfs4_create_server(struct nfs_mount_info *mount_info,
580 struct nfs_subversion *nfs_mod)
579{ 581{
580 struct nfs_server *server; 582 struct nfs_server *server;
581 int error; 583 int error;
@@ -587,11 +589,11 @@ struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
587 return ERR_PTR(-ENOMEM); 589 return ERR_PTR(-ENOMEM);
588 590
589 /* set up the general RPC client */ 591 /* set up the general RPC client */
590 error = nfs4_init_server(server, data); 592 error = nfs4_init_server(server, mount_info->parsed);
591 if (error < 0) 593 if (error < 0)
592 goto error; 594 goto error;
593 595
594 error = nfs4_server_common_setup(server, mntfh); 596 error = nfs4_server_common_setup(server, mount_info->mntfh);
595 if (error < 0) 597 if (error < 0)
596 goto error; 598 goto error;
597 599
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index eb4ba1d99df9..36c6432aac7b 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6916,6 +6916,8 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
6916 .alloc_client = nfs4_alloc_client, 6916 .alloc_client = nfs4_alloc_client,
6917 .init_client = nfs4_init_client, 6917 .init_client = nfs4_init_client,
6918 .free_client = nfs4_free_client, 6918 .free_client = nfs4_free_client,
6919 .create_server = nfs4_create_server,
6920 .clone_server = nfs_clone_server,
6919}; 6921};
6920 6922
6921static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = { 6923static const struct xattr_handler nfs4_xattr_nfs4_acl_handler = {
diff --git a/fs/nfs/nfs4super.c b/fs/nfs/nfs4super.c
index 9384f666b6ab..a62836256665 100644
--- a/fs/nfs/nfs4super.c
+++ b/fs/nfs/nfs4super.c
@@ -105,7 +105,7 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags,
105 mount_info->set_security = nfs_set_sb_security; 105 mount_info->set_security = nfs_set_sb_security;
106 106
107 /* Get a volume representation */ 107 /* Get a volume representation */
108 server = nfs4_create_server(mount_info->parsed, mount_info->mntfh); 108 server = nfs4_create_server(mount_info, &nfs_v4);
109 if (IS_ERR(server)) { 109 if (IS_ERR(server)) {
110 mntroot = ERR_CAST(server); 110 mntroot = ERR_CAST(server);
111 goto out; 111 goto out;
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index ebb3d9c5227b..50a88c3546ed 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -817,4 +817,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
817 .alloc_client = nfs_alloc_client, 817 .alloc_client = nfs_alloc_client,
818 .init_client = nfs_init_client, 818 .init_client = nfs_init_client,
819 .free_client = nfs_free_client, 819 .free_client = nfs_free_client,
820 .create_server = nfs_create_server,
821 .clone_server = nfs_clone_server,
820}; 822};
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 5fca59d73e40..a5f9fb3bfdcc 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1664,7 +1664,7 @@ struct dentry *nfs_try_mount(int flags, const char *dev_name,
1664 } 1664 }
1665 1665
1666 /* Get a volume representation */ 1666 /* Get a volume representation */
1667 server = nfs_create_server(mount_info->parsed, mount_info->mntfh, nfs_mod); 1667 server = nfs_mod->rpc_ops->create_server(mount_info, nfs_mod);
1668 if (IS_ERR(server)) 1668 if (IS_ERR(server))
1669 return ERR_CAST(server); 1669 return ERR_CAST(server);
1670 1670
@@ -2458,7 +2458,7 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
2458 mount_info.mntfh = mount_info.cloned->fh; 2458 mount_info.mntfh = mount_info.cloned->fh;
2459 2459
2460 /* create a new volume representation */ 2460 /* create a new volume representation */
2461 server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor); 2461 server = nfs_mod->rpc_ops->clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor);
2462 if (IS_ERR(server)) { 2462 if (IS_ERR(server)) {
2463 error = PTR_ERR(server); 2463 error = PTR_ERR(server);
2464 goto out_err; 2464 goto out_err;