aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-08-22 20:06:12 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-09-22 23:24:35 -0400
commit8fa5c000d7f986ef9cdc6d95f9f7fcee20e0a7d6 (patch)
tree356b811803db9775fd9c870d189a9ff75885ae6c
parent1f163415dc05983830bcc47b33c155b2528b1574 (diff)
NFS: Move rpc_ops from nfs_server to nfs_client
Move the rpc_ops from the nfs_server struct to the nfs_client struct as they're common to all server records of a particular NFS protocol version. Signed-Off-By: David Howells <dhowells@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/dir.c2
-rw-r--r--fs/nfs/inode.c4
-rw-r--r--fs/nfs/namespace.c6
-rw-r--r--fs/nfs/nfs4proc.c2
-rw-r--r--fs/nfs/super.c59
-rw-r--r--include/linux/nfs_fs.h2
-rw-r--r--include/linux/nfs_fs_sb.h2
7 files changed, 43 insertions, 34 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 067d144d141b..19362712452f 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1147,7 +1147,7 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
1147 } 1147 }
1148 if (!(fattr->valid & NFS_ATTR_FATTR)) { 1148 if (!(fattr->valid & NFS_ATTR_FATTR)) {
1149 struct nfs_server *server = NFS_SB(dentry->d_sb); 1149 struct nfs_server *server = NFS_SB(dentry->d_sb);
1150 error = server->rpc_ops->getattr(server, fhandle, fattr); 1150 error = server->nfs_client->rpc_ops->getattr(server, fhandle, fattr);
1151 if (error < 0) 1151 if (error < 0)
1152 goto out_err; 1152 goto out_err;
1153 } 1153 }
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 6ed018c9aad2..771c3b833757 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -237,13 +237,13 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
237 /* Why so? Because we want revalidate for devices/FIFOs, and 237 /* Why so? Because we want revalidate for devices/FIFOs, and
238 * that's precisely what we have in nfs_file_inode_operations. 238 * that's precisely what we have in nfs_file_inode_operations.
239 */ 239 */
240 inode->i_op = NFS_SB(sb)->rpc_ops->file_inode_ops; 240 inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->file_inode_ops;
241 if (S_ISREG(inode->i_mode)) { 241 if (S_ISREG(inode->i_mode)) {
242 inode->i_fop = &nfs_file_operations; 242 inode->i_fop = &nfs_file_operations;
243 inode->i_data.a_ops = &nfs_file_aops; 243 inode->i_data.a_ops = &nfs_file_aops;
244 inode->i_data.backing_dev_info = &NFS_SB(sb)->backing_dev_info; 244 inode->i_data.backing_dev_info = &NFS_SB(sb)->backing_dev_info;
245 } else if (S_ISDIR(inode->i_mode)) { 245 } else if (S_ISDIR(inode->i_mode)) {
246 inode->i_op = NFS_SB(sb)->rpc_ops->dir_inode_ops; 246 inode->i_op = NFS_SB(sb)->nfs_client->rpc_ops->dir_inode_ops;
247 inode->i_fop = &nfs_dir_operations; 247 inode->i_fop = &nfs_dir_operations;
248 if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) 248 if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS)
249 && fattr->size <= NFS_LIMIT_READDIRPLUS) 249 && fattr->size <= NFS_LIMIT_READDIRPLUS)
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 85d9ed1dcf42..d8b8d56266cb 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -104,7 +104,9 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
104 goto out_follow; 104 goto out_follow;
105 /* Look it up again */ 105 /* Look it up again */
106 parent = dget_parent(nd->dentry); 106 parent = dget_parent(nd->dentry);
107 err = server->rpc_ops->lookup(parent->d_inode, &nd->dentry->d_name, &fh, &fattr); 107 err = server->nfs_client->rpc_ops->lookup(parent->d_inode,
108 &nd->dentry->d_name,
109 &fh, &fattr);
108 dput(parent); 110 dput(parent);
109 if (err != 0) 111 if (err != 0)
110 goto out_err; 112 goto out_err;
@@ -178,7 +180,7 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server,
178{ 180{
179#ifdef CONFIG_NFS_V4 181#ifdef CONFIG_NFS_V4
180 struct vfsmount *mnt = NULL; 182 struct vfsmount *mnt = NULL;
181 switch (server->rpc_ops->version) { 183 switch (server->nfs_client->cl_nfsversion) {
182 case 2: 184 case 2:
183 case 3: 185 case 3:
184 mnt = vfs_kern_mount(&clone_nfs_fs_type, 0, devname, mountdata); 186 mnt = vfs_kern_mount(&clone_nfs_fs_type, 0, devname, mountdata);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index b731b1945270..1573eeb07ce1 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -758,7 +758,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
758 } 758 }
759 nfs_confirm_seqid(&data->owner->so_seqid, 0); 759 nfs_confirm_seqid(&data->owner->so_seqid, 0);
760 if (!(o_res->f_attr->valid & NFS_ATTR_FATTR)) 760 if (!(o_res->f_attr->valid & NFS_ATTR_FATTR))
761 return server->rpc_ops->getattr(server, &o_res->fh, o_res->f_attr); 761 return server->nfs_client->rpc_ops->getattr(server, &o_res->fh, o_res->f_attr);
762 return 0; 762 return 0;
763} 763}
764 764
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index d1b4a5b36e33..e1e5eab0259b 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -252,7 +252,7 @@ static int nfs_statfs(struct dentry *dentry, struct kstatfs *buf)
252 252
253 lock_kernel(); 253 lock_kernel();
254 254
255 error = server->rpc_ops->statfs(server, fh, &res); 255 error = server->nfs_client->rpc_ops->statfs(server, fh, &res);
256 buf->f_type = NFS_SUPER_MAGIC; 256 buf->f_type = NFS_SUPER_MAGIC;
257 if (error < 0) 257 if (error < 0)
258 goto out_err; 258 goto out_err;
@@ -343,10 +343,11 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
343 { 0, NULL, NULL } 343 { 0, NULL, NULL }
344 }; 344 };
345 const struct proc_nfs_info *nfs_infop; 345 const struct proc_nfs_info *nfs_infop;
346 struct nfs_client *clp = nfss->nfs_client;
346 char buf[12]; 347 char buf[12];
347 const char *proto; 348 const char *proto;
348 349
349 seq_printf(m, ",vers=%d", nfss->rpc_ops->version); 350 seq_printf(m, ",vers=%d", clp->rpc_ops->version);
350 seq_printf(m, ",rsize=%d", nfss->rsize); 351 seq_printf(m, ",rsize=%d", nfss->rsize);
351 seq_printf(m, ",wsize=%d", nfss->wsize); 352 seq_printf(m, ",wsize=%d", nfss->wsize);
352 if (nfss->acregmin != 3*HZ || showdefaults) 353 if (nfss->acregmin != 3*HZ || showdefaults)
@@ -427,7 +428,7 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
427 seq_printf(m, ",namelen=%d", nfss->namelen); 428 seq_printf(m, ",namelen=%d", nfss->namelen);
428 429
429#ifdef CONFIG_NFS_V4 430#ifdef CONFIG_NFS_V4
430 if (nfss->rpc_ops->version == 4) { 431 if (nfss->nfs_client->cl_nfsversion == 4) {
431 seq_printf(m, "\n\tnfsv4:\t"); 432 seq_printf(m, "\n\tnfsv4:\t");
432 seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]); 433 seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]);
433 seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]); 434 seq_printf(m, ",bm1=0x%x", nfss->attr_bitmask[1]);
@@ -503,7 +504,7 @@ nfs_get_root(struct super_block *sb, struct nfs_fh *rootfh, struct nfs_fsinfo *f
503 struct nfs_server *server = NFS_SB(sb); 504 struct nfs_server *server = NFS_SB(sb);
504 int error; 505 int error;
505 506
506 error = server->rpc_ops->getroot(server, rootfh, fsinfo); 507 error = server->nfs_client->rpc_ops->getroot(server, rootfh, fsinfo);
507 if (error < 0) { 508 if (error < 0) {
508 dprintk("nfs_get_root: getattr error = %d\n", -error); 509 dprintk("nfs_get_root: getattr error = %d\n", -error);
509 return ERR_PTR(error); 510 return ERR_PTR(error);
@@ -553,14 +554,14 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor)
553 no_root_error = -ENOMEM; 554 no_root_error = -ENOMEM;
554 goto out_no_root; 555 goto out_no_root;
555 } 556 }
556 sb->s_root->d_op = server->rpc_ops->dentry_ops; 557 sb->s_root->d_op = server->nfs_client->rpc_ops->dentry_ops;
557 558
558 /* mount time stamp, in seconds */ 559 /* mount time stamp, in seconds */
559 server->mount_time = jiffies; 560 server->mount_time = jiffies;
560 561
561 /* Get some general file system info */ 562 /* Get some general file system info */
562 if (server->namelen == 0 && 563 if (server->namelen == 0 &&
563 server->rpc_ops->pathconf(server, &server->fh, &pathinfo) >= 0) 564 server->nfs_client->rpc_ops->pathconf(server, &server->fh, &pathinfo) >= 0)
564 server->namelen = pathinfo.max_namelen; 565 server->namelen = pathinfo.max_namelen;
565 /* Work out a lot of parameters */ 566 /* Work out a lot of parameters */
566 if (server->rsize == 0) 567 if (server->rsize == 0)
@@ -663,9 +664,14 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data)
663 struct rpc_xprt *xprt = NULL; 664 struct rpc_xprt *xprt = NULL;
664 struct rpc_clnt *clnt = NULL; 665 struct rpc_clnt *clnt = NULL;
665 int proto = (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP; 666 int proto = (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP;
667 int nfsversion = 2;
666 668
667 clp = nfs_get_client(server->hostname, &server->addr, 669#ifdef CONFIG_NFS_V3
668 server->rpc_ops->version); 670 if (server->flags & NFS_MOUNT_VER3)
671 nfsversion = 3;
672#endif
673
674 clp = nfs_get_client(server->hostname, &server->addr, nfsversion);
669 if (!clp) { 675 if (!clp) {
670 dprintk("%s: failed to create NFS4 client.\n", __FUNCTION__); 676 dprintk("%s: failed to create NFS4 client.\n", __FUNCTION__);
671 return ERR_PTR(PTR_ERR(clp)); 677 return ERR_PTR(PTR_ERR(clp));
@@ -676,6 +682,19 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data)
676 server->retrans_timeo = timeparms.to_initval; 682 server->retrans_timeo = timeparms.to_initval;
677 server->retrans_count = timeparms.to_retries; 683 server->retrans_count = timeparms.to_retries;
678 684
685 /* Check NFS protocol revision and initialize RPC op vector
686 * and file handle pool. */
687#ifdef CONFIG_NFS_V3
688 if (nfsversion == 3) {
689 clp->rpc_ops = &nfs_v3_clientops;
690 server->caps |= NFS_CAP_READDIRPLUS;
691 } else {
692 clp->rpc_ops = &nfs_v2_clientops;
693 }
694#else
695 clp->rpc_ops = &nfs_v2_clientops;
696#endif
697
679 /* create transport and client */ 698 /* create transport and client */
680 xprt = xprt_create_proto(proto, &server->addr, &timeparms); 699 xprt = xprt_create_proto(proto, &server->addr, &timeparms);
681 if (IS_ERR(xprt)) { 700 if (IS_ERR(xprt)) {
@@ -686,7 +705,7 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data)
686 return (struct rpc_clnt *)xprt; 705 return (struct rpc_clnt *)xprt;
687 } 706 }
688 clnt = rpc_create_client(xprt, server->hostname, &nfs_program, 707 clnt = rpc_create_client(xprt, server->hostname, &nfs_program,
689 server->rpc_ops->version, data->pseudoflavor); 708 clp->cl_nfsversion, data->pseudoflavor);
690 if (IS_ERR(clnt)) { 709 if (IS_ERR(clnt)) {
691 dprintk("%s: cannot create RPC client. Error = %ld\n", 710 dprintk("%s: cannot create RPC client. Error = %ld\n",
692 __FUNCTION__, PTR_ERR(xprt)); 711 __FUNCTION__, PTR_ERR(xprt));
@@ -750,7 +769,7 @@ static struct nfs_server *nfs_clone_server(struct super_block *sb, struct nfs_cl
750 fsinfo.fattr = data->fattr; 769 fsinfo.fattr = data->fattr;
751 if (NFS_PROTO(root_inode)->fsinfo(server, data->fh, &fsinfo) == 0) 770 if (NFS_PROTO(root_inode)->fsinfo(server, data->fh, &fsinfo) == 0)
752 nfs_super_set_maxbytes(sb, fsinfo.maxfilesize); 771 nfs_super_set_maxbytes(sb, fsinfo.maxfilesize);
753 sb->s_root->d_op = server->rpc_ops->dentry_ops; 772 sb->s_root->d_op = server->nfs_client->rpc_ops->dentry_ops;
754 sb->s_flags |= MS_ACTIVE; 773 sb->s_flags |= MS_ACTIVE;
755 return server; 774 return server;
756out_put_root: 775out_put_root:
@@ -865,19 +884,6 @@ nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int silent)
865 return -ENOMEM; 884 return -ENOMEM;
866 strcpy(server->hostname, data->hostname); 885 strcpy(server->hostname, data->hostname);
867 886
868 /* Check NFS protocol revision and initialize RPC op vector
869 * and file handle pool. */
870#ifdef CONFIG_NFS_V3
871 if (server->flags & NFS_MOUNT_VER3) {
872 server->rpc_ops = &nfs_v3_clientops;
873 server->caps |= NFS_CAP_READDIRPLUS;
874 } else {
875 server->rpc_ops = &nfs_v2_clientops;
876 }
877#else
878 server->rpc_ops = &nfs_v2_clientops;
879#endif
880
881 /* Fill in pseudoflavor for mount version < 5 */ 887 /* Fill in pseudoflavor for mount version < 5 */
882 if (!(data->flags & NFS_MOUNT_SECFLAVOUR)) 888 if (!(data->flags & NFS_MOUNT_SECFLAVOUR))
883 data->pseudoflavor = RPC_AUTH_UNIX; 889 data->pseudoflavor = RPC_AUTH_UNIX;
@@ -888,6 +894,7 @@ nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data, int silent)
888 server->client = nfs_create_client(server, data); 894 server->client = nfs_create_client(server, data);
889 if (IS_ERR(server->client)) 895 if (IS_ERR(server->client))
890 return PTR_ERR(server->client); 896 return PTR_ERR(server->client);
897
891 /* RFC 2623, sec 2.3.2 */ 898 /* RFC 2623, sec 2.3.2 */
892 if (authflavor != RPC_AUTH_UNIX) { 899 if (authflavor != RPC_AUTH_UNIX) {
893 struct rpc_auth *auth; 900 struct rpc_auth *auth;
@@ -1129,6 +1136,8 @@ static struct rpc_clnt *nfs4_create_client(struct nfs_server *server,
1129 1136
1130 /* Now create transport and client */ 1137 /* Now create transport and client */
1131 if (clp->cl_cons_state == NFS_CS_INITING) { 1138 if (clp->cl_cons_state == NFS_CS_INITING) {
1139 clp->rpc_ops = &nfs_v4_clientops;
1140
1132 xprt = xprt_create_proto(proto, &server->addr, timeparms); 1141 xprt = xprt_create_proto(proto, &server->addr, timeparms);
1133 if (IS_ERR(xprt)) { 1142 if (IS_ERR(xprt)) {
1134 err = PTR_ERR(xprt); 1143 err = PTR_ERR(xprt);
@@ -1139,7 +1148,7 @@ static struct rpc_clnt *nfs4_create_client(struct nfs_server *server,
1139 /* Bind to a reserved port! */ 1148 /* Bind to a reserved port! */
1140 xprt->resvport = 1; 1149 xprt->resvport = 1;
1141 clnt = rpc_create_client(xprt, server->hostname, &nfs_program, 1150 clnt = rpc_create_client(xprt, server->hostname, &nfs_program,
1142 server->rpc_ops->version, flavor); 1151 clp->cl_nfsversion, flavor);
1143 if (IS_ERR(clnt)) { 1152 if (IS_ERR(clnt)) {
1144 err = PTR_ERR(clnt); 1153 err = PTR_ERR(clnt);
1145 dprintk("%s: cannot create RPC client. Error = %d\n", 1154 dprintk("%s: cannot create RPC client. Error = %d\n",
@@ -1215,8 +1224,6 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data,
1215 server->acdirmin = data->acdirmin*HZ; 1224 server->acdirmin = data->acdirmin*HZ;
1216 server->acdirmax = data->acdirmax*HZ; 1225 server->acdirmax = data->acdirmax*HZ;
1217 1226
1218 server->rpc_ops = &nfs_v4_clientops;
1219
1220 nfs_init_timeout_values(&timeparms, data->proto, data->timeo, data->retrans); 1227 nfs_init_timeout_values(&timeparms, data->proto, data->timeo, data->retrans);
1221 1228
1222 server->retrans_timeo = timeparms.to_initval; 1229 server->retrans_timeo = timeparms.to_initval;
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 70e1dc9162e2..51e9bd90dedc 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -215,7 +215,7 @@ static inline struct nfs_inode *NFS_I(struct inode *inode)
215#define NFS_FH(inode) (&NFS_I(inode)->fh) 215#define NFS_FH(inode) (&NFS_I(inode)->fh)
216#define NFS_SERVER(inode) (NFS_SB(inode->i_sb)) 216#define NFS_SERVER(inode) (NFS_SB(inode->i_sb))
217#define NFS_CLIENT(inode) (NFS_SERVER(inode)->client) 217#define NFS_CLIENT(inode) (NFS_SERVER(inode)->client)
218#define NFS_PROTO(inode) (NFS_SERVER(inode)->rpc_ops) 218#define NFS_PROTO(inode) (NFS_SERVER(inode)->nfs_client->rpc_ops)
219#define NFS_ADDR(inode) (RPC_PEERADDR(NFS_CLIENT(inode))) 219#define NFS_ADDR(inode) (RPC_PEERADDR(NFS_CLIENT(inode)))
220#define NFS_COOKIEVERF(inode) (NFS_I(inode)->cookieverf) 220#define NFS_COOKIEVERF(inode) (NFS_I(inode)->cookieverf)
221#define NFS_READTIME(inode) (NFS_I(inode)->read_cache_jiffies) 221#define NFS_READTIME(inode) (NFS_I(inode)->read_cache_jiffies)
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index e7d7662f51fd..aae7c117597a 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -25,6 +25,7 @@ struct nfs_client {
25 struct list_head cl_superblocks; /* List of nfs_server structs */ 25 struct list_head cl_superblocks; /* List of nfs_server structs */
26 26
27 struct rpc_clnt * cl_rpcclient; 27 struct rpc_clnt * cl_rpcclient;
28 const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
28 29
29#ifdef CONFIG_NFS_V4 30#ifdef CONFIG_NFS_V4
30 u64 cl_clientid; /* constant */ 31 u64 cl_clientid; /* constant */
@@ -74,7 +75,6 @@ struct nfs_server {
74 struct rpc_clnt * client; /* RPC client handle */ 75 struct rpc_clnt * client; /* RPC client handle */
75 struct rpc_clnt * client_sys; /* 2nd handle for FSINFO */ 76 struct rpc_clnt * client_sys; /* 2nd handle for FSINFO */
76 struct rpc_clnt * client_acl; /* ACL RPC client handle */ 77 struct rpc_clnt * client_acl; /* ACL RPC client handle */
77 const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
78 struct nfs_iostats * io_stats; /* I/O statistics */ 78 struct nfs_iostats * io_stats; /* I/O statistics */
79 struct backing_dev_info backing_dev_info; 79 struct backing_dev_info backing_dev_info;
80 int flags; /* various flags */ 80 int flags; /* various flags */