diff options
author | David Howells <dhowells@redhat.com> | 2006-08-22 20:06:12 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-09-22 23:24:35 -0400 |
commit | 8fa5c000d7f986ef9cdc6d95f9f7fcee20e0a7d6 (patch) | |
tree | 356b811803db9775fd9c870d189a9ff75885ae6c /fs/nfs/super.c | |
parent | 1f163415dc05983830bcc47b33c155b2528b1574 (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>
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r-- | fs/nfs/super.c | 59 |
1 files changed, 33 insertions, 26 deletions
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; |
756 | out_put_root: | 775 | out_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; |