aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-12-14 14:56:07 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-01-30 02:05:49 -0500
commit40c553193df41920de659f0446e5d214c862e827 (patch)
tree4ee62a79fae0ebba26d119a1aae89bfd1a552c10
parentc81468a1a766921f11ae44e8a99816ac8dc7b015 (diff)
NFS: Remove the redundant nfs_client->cl_nfsversion
We can get the same information from the rpc_ops structure instead. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/client.c41
-rw-r--r--fs/nfs/namespace.c2
-rw-r--r--fs/nfs/super.c2
-rw-r--r--include/linux/nfs_fs_sb.h1
4 files changed, 20 insertions, 26 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index ff778ecee0bd..3b21731ae571 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -96,7 +96,7 @@ struct rpc_program nfsacl_program = {
96struct nfs_client_initdata { 96struct nfs_client_initdata {
97 const char *hostname; 97 const char *hostname;
98 const struct sockaddr_in *addr; 98 const struct sockaddr_in *addr;
99 int version; 99 const struct nfs_rpc_ops *rpc_ops;
100}; 100};
101 101
102/* 102/*
@@ -112,7 +112,9 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
112 if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL) 112 if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL)
113 goto error_0; 113 goto error_0;
114 114
115 if (cl_init->version == 4) { 115 clp->rpc_ops = cl_init->rpc_ops;
116
117 if (cl_init->rpc_ops->version == 4) {
116 if (nfs_callback_up() < 0) 118 if (nfs_callback_up() < 0)
117 goto error_2; 119 goto error_2;
118 __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state); 120 __set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
@@ -121,7 +123,6 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
121 atomic_set(&clp->cl_count, 1); 123 atomic_set(&clp->cl_count, 1);
122 clp->cl_cons_state = NFS_CS_INITING; 124 clp->cl_cons_state = NFS_CS_INITING;
123 125
124 clp->cl_nfsversion = cl_init->version;
125 memcpy(&clp->cl_addr, cl_init->addr, sizeof(clp->cl_addr)); 126 memcpy(&clp->cl_addr, cl_init->addr, sizeof(clp->cl_addr));
126 127
127 if (cl_init->hostname) { 128 if (cl_init->hostname) {
@@ -170,7 +171,7 @@ static void nfs4_shutdown_client(struct nfs_client *clp)
170 */ 171 */
171static void nfs_free_client(struct nfs_client *clp) 172static void nfs_free_client(struct nfs_client *clp)
172{ 173{
173 dprintk("--> nfs_free_client(%d)\n", clp->cl_nfsversion); 174 dprintk("--> nfs_free_client(%u)\n", clp->rpc_ops->version);
174 175
175 nfs4_shutdown_client(clp); 176 nfs4_shutdown_client(clp);
176 177
@@ -222,7 +223,7 @@ struct nfs_client *nfs_find_client(const struct sockaddr_in *addr, int nfsversio
222 continue; 223 continue;
223 224
224 /* Different NFS versions cannot share the same nfs_client */ 225 /* Different NFS versions cannot share the same nfs_client */
225 if (clp->cl_nfsversion != nfsversion) 226 if (clp->rpc_ops->version != nfsversion)
226 continue; 227 continue;
227 228
228 /* Match only the IP address, not the port number */ 229 /* Match only the IP address, not the port number */
@@ -251,7 +252,7 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
251 continue; 252 continue;
252 253
253 /* Different NFS versions cannot share the same nfs_client */ 254 /* Different NFS versions cannot share the same nfs_client */
254 if (clp->cl_nfsversion != data->version) 255 if (clp->rpc_ops != data->rpc_ops)
255 continue; 256 continue;
256 257
257 /* Match the full socket address */ 258 /* Match the full socket address */
@@ -273,9 +274,9 @@ static struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_in
273 struct nfs_client *clp, *new = NULL; 274 struct nfs_client *clp, *new = NULL;
274 int error; 275 int error;
275 276
276 dprintk("--> nfs_get_client(%s,"NIPQUAD_FMT":%d,%d)\n", 277 dprintk("--> nfs_get_client(%s,"NIPQUAD_FMT":%d,%u)\n",
277 cl_init->hostname ?: "", NIPQUAD(cl_init->addr->sin_addr), 278 cl_init->hostname ?: "", NIPQUAD(cl_init->addr->sin_addr),
278 cl_init->addr->sin_port, cl_init->version); 279 cl_init->addr->sin_port, cl_init->rpc_ops->version);
279 280
280 /* see if the client already exists */ 281 /* see if the client already exists */
281 do { 282 do {
@@ -430,7 +431,7 @@ static int nfs_start_lockd(struct nfs_server *server)
430{ 431{
431 int error = 0; 432 int error = 0;
432 433
433 if (server->nfs_client->cl_nfsversion > 3) 434 if (server->nfs_client->rpc_ops->version > 3)
434 goto out; 435 goto out;
435 if (server->flags & NFS_MOUNT_NONLM) 436 if (server->flags & NFS_MOUNT_NONLM)
436 goto out; 437 goto out;
@@ -450,7 +451,7 @@ out:
450#ifdef CONFIG_NFS_V3_ACL 451#ifdef CONFIG_NFS_V3_ACL
451static void nfs_init_server_aclclient(struct nfs_server *server) 452static void nfs_init_server_aclclient(struct nfs_server *server)
452{ 453{
453 if (server->nfs_client->cl_nfsversion != 3) 454 if (server->nfs_client->rpc_ops->version != 3)
454 goto out_noacl; 455 goto out_noacl;
455 if (server->flags & NFS_MOUNT_NOACL) 456 if (server->flags & NFS_MOUNT_NOACL)
456 goto out_noacl; 457 goto out_noacl;
@@ -521,12 +522,6 @@ static int nfs_init_client(struct nfs_client *clp,
521 return 0; 522 return 0;
522 } 523 }
523 524
524 /* Check NFS protocol revision and initialize RPC op vector */
525 clp->rpc_ops = &nfs_v2_clientops;
526#ifdef CONFIG_NFS_V3
527 if (clp->cl_nfsversion == 3)
528 clp->rpc_ops = &nfs_v3_clientops;
529#endif
530 /* 525 /*
531 * Create a client RPC handle for doing FSSTAT with UNIX auth only 526 * Create a client RPC handle for doing FSSTAT with UNIX auth only
532 * - RFC 2623, sec 2.3.2 527 * - RFC 2623, sec 2.3.2
@@ -553,7 +548,7 @@ static int nfs_init_server(struct nfs_server *server,
553 struct nfs_client_initdata cl_init = { 548 struct nfs_client_initdata cl_init = {
554 .hostname = data->nfs_server.hostname, 549 .hostname = data->nfs_server.hostname,
555 .addr = &data->nfs_server.address, 550 .addr = &data->nfs_server.address,
556 .version = 2, 551 .rpc_ops = &nfs_v2_clientops,
557 }; 552 };
558 struct nfs_client *clp; 553 struct nfs_client *clp;
559 int error; 554 int error;
@@ -562,7 +557,7 @@ static int nfs_init_server(struct nfs_server *server,
562 557
563#ifdef CONFIG_NFS_V3 558#ifdef CONFIG_NFS_V3
564 if (data->flags & NFS_MOUNT_VER3) 559 if (data->flags & NFS_MOUNT_VER3)
565 cl_init.version = 3; 560 cl_init.rpc_ops = &nfs_v3_clientops;
566#endif 561#endif
567 562
568 /* Allocate or find a client reference we can use */ 563 /* Allocate or find a client reference we can use */
@@ -906,7 +901,7 @@ static int nfs4_set_client(struct nfs_server *server,
906 struct nfs_client_initdata cl_init = { 901 struct nfs_client_initdata cl_init = {
907 .hostname = hostname, 902 .hostname = hostname,
908 .addr = addr, 903 .addr = addr,
909 .version = 4, 904 .rpc_ops = &nfs_v4_clientops,
910 }; 905 };
911 struct nfs_client *clp; 906 struct nfs_client *clp;
912 int error; 907 int error;
@@ -1284,8 +1279,8 @@ static int nfs_server_list_show(struct seq_file *m, void *v)
1284 /* display one transport per line on subsequent lines */ 1279 /* display one transport per line on subsequent lines */
1285 clp = list_entry(v, struct nfs_client, cl_share_link); 1280 clp = list_entry(v, struct nfs_client, cl_share_link);
1286 1281
1287 seq_printf(m, "v%d %02x%02x%02x%02x %4hx %3d %s\n", 1282 seq_printf(m, "v%u %02x%02x%02x%02x %4hx %3d %s\n",
1288 clp->cl_nfsversion, 1283 clp->rpc_ops->version,
1289 NIPQUAD(clp->cl_addr.sin_addr), 1284 NIPQUAD(clp->cl_addr.sin_addr),
1290 ntohs(clp->cl_addr.sin_port), 1285 ntohs(clp->cl_addr.sin_port),
1291 atomic_read(&clp->cl_count), 1286 atomic_read(&clp->cl_count),
@@ -1363,8 +1358,8 @@ static int nfs_volume_list_show(struct seq_file *m, void *v)
1363 (unsigned long long) server->fsid.major, 1358 (unsigned long long) server->fsid.major,
1364 (unsigned long long) server->fsid.minor); 1359 (unsigned long long) server->fsid.minor);
1365 1360
1366 seq_printf(m, "v%d %02x%02x%02x%02x %4hx %-7s %-17s\n", 1361 seq_printf(m, "v%u %02x%02x%02x%02x %4hx %-7s %-17s\n",
1367 clp->cl_nfsversion, 1362 clp->rpc_ops->version,
1368 NIPQUAD(clp->cl_addr.sin_addr), 1363 NIPQUAD(clp->cl_addr.sin_addr),
1369 ntohs(clp->cl_addr.sin_port), 1364 ntohs(clp->cl_addr.sin_port),
1370 dev, 1365 dev,
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index acfc56f9edc0..be4ce1c3a3d8 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -188,7 +188,7 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server,
188{ 188{
189#ifdef CONFIG_NFS_V4 189#ifdef CONFIG_NFS_V4
190 struct vfsmount *mnt = NULL; 190 struct vfsmount *mnt = NULL;
191 switch (server->nfs_client->cl_nfsversion) { 191 switch (server->nfs_client->rpc_ops->version) {
192 case 2: 192 case 2:
193 case 3: 193 case 3:
194 mnt = vfs_kern_mount(&nfs_xdev_fs_type, 0, devname, mountdata); 194 mnt = vfs_kern_mount(&nfs_xdev_fs_type, 0, devname, mountdata);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index a3492d6f8f9b..5608e6a4c1e1 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -529,7 +529,7 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
529 seq_printf(m, ",namelen=%d", nfss->namelen); 529 seq_printf(m, ",namelen=%d", nfss->namelen);
530 530
531#ifdef CONFIG_NFS_V4 531#ifdef CONFIG_NFS_V4
532 if (nfss->nfs_client->cl_nfsversion == 4) { 532 if (nfss->nfs_client->rpc_ops->version == 4) {
533 seq_printf(m, "\n\tnfsv4:\t"); 533 seq_printf(m, "\n\tnfsv4:\t");
534 seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]); 534 seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]);
535 seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]); 535 seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]);
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 9f949b587684..97b325756667 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -17,7 +17,6 @@ struct nfs_client {
17 int cl_cons_state; /* current construction state (-ve: init error) */ 17 int cl_cons_state; /* current construction state (-ve: init error) */
18#define NFS_CS_READY 0 /* ready to be used */ 18#define NFS_CS_READY 0 /* ready to be used */
19#define NFS_CS_INITING 1 /* busy initialising */ 19#define NFS_CS_INITING 1 /* busy initialising */
20 int cl_nfsversion; /* NFS protocol version */
21 unsigned long cl_res_state; /* NFS resources state */ 20 unsigned long cl_res_state; /* NFS resources state */
22#define NFS_CS_CALLBACK 1 /* - callback started */ 21#define NFS_CS_CALLBACK 1 /* - callback started */
23#define NFS_CS_IDMAP 2 /* - idmap started */ 22#define NFS_CS_IDMAP 2 /* - idmap started */