From: David Howells Subject: [PATCH 15/30] NFS: Move rpc_ops from nfs_server to nfs_client [try #11] Date: Thu, 27 Jul 2006 21:53:00 +0100 Message-ID: <20060727205300.8443.86429.stgit@warthog.cambridge.redhat.com> References: <20060727205222.8443.29381.stgit@warthog.cambridge.redhat.com> Reply-To: Linux filesystem caching discussion list Content-Type: text/plain; charset=utf-8; format=fixed Content-Transfer-Encoding: quoted-printable Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, nfsv4@linux-nfs.org, linux-kernel@vger.kernel.org Return-path: To: torvalds@osdl.org, akpm@osdl.org, steved@redhat.com, trond.myklebust@fys.uio.no In-Reply-To: <20060727205222.8443.29381.stgit@warthog.cambridge.redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cachefs-bounces@redhat.com Errors-To: linux-cachefs-bounces@redhat.com List-Id: linux-fsdevel.vger.kernel.org Move the rpc_ops from the nfs_server struct to the nfs_client struct as t= hey're common to all server records of a particular NFS protocol version. Signed-Off-By: David Howells Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 2 +- fs/nfs/inode.c | 4 ++- fs/nfs/namespace.c | 6 +++-- fs/nfs/nfs4proc.c | 2 +- fs/nfs/super.c | 59 +++++++++++++++++++++++++--------------= ------ include/linux/nfs_fs.h | 2 +- include/linux/nfs_fs_sb.h | 2 +- 7 files changed, 43 insertions(+), 34 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index e7ffb4d..0dd727d 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1147,7 +1147,7 @@ int nfs_instantiate(struct dentry *dentr } if (!(fattr->valid & NFS_ATTR_FATTR)) { struct nfs_server *server =3D NFS_SB(dentry->d_sb); - error =3D server->rpc_ops->getattr(server, fhandle, fattr); + error =3D server->nfs_client->rpc_ops->getattr(server, fhandle, fattr)= ; if (error < 0) goto out_err; } diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index d349fb2..a9ff211 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -242,13 +242,13 @@ nfs_fhget(struct super_block *sb, struct /* Why so? Because we want revalidate for devices/FIFOs, and * that's precisely what we have in nfs_file_inode_operations. */ - inode->i_op =3D NFS_SB(sb)->rpc_ops->file_inode_ops; + inode->i_op =3D NFS_SB(sb)->nfs_client->rpc_ops->file_inode_ops; if (S_ISREG(inode->i_mode)) { inode->i_fop =3D &nfs_file_operations; inode->i_data.a_ops =3D &nfs_file_aops; inode->i_data.backing_dev_info =3D &NFS_SB(sb)->backing_dev_info; } else if (S_ISDIR(inode->i_mode)) { - inode->i_op =3D NFS_SB(sb)->rpc_ops->dir_inode_ops; + inode->i_op =3D NFS_SB(sb)->nfs_client->rpc_ops->dir_inode_ops; inode->i_fop =3D &nfs_dir_operations; if (nfs_server_capable(inode, NFS_CAP_READDIRPLUS) && fattr->size <=3D NFS_LIMIT_READDIRPLUS) diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c index 460a978..f1b6ff6 100644 --- a/fs/nfs/namespace.c +++ b/fs/nfs/namespace.c @@ -102,7 +102,9 @@ static void * nfs_follow_mountpoint(stru goto out_follow; /* Look it up again */ parent =3D dget_parent(nd->dentry); - err =3D server->rpc_ops->lookup(parent->d_inode, &nd->dentry->d_name, &= fh, &fattr); + err =3D server->nfs_client->rpc_ops->lookup(parent->d_inode, + &nd->dentry->d_name, + &fh, &fattr); dput(parent); if (err !=3D 0) goto out_err; @@ -176,7 +178,7 @@ static struct vfsmount *nfs_do_clone_mou { #ifdef CONFIG_NFS_V4 struct vfsmount *mnt =3D NULL; - switch (server->rpc_ops->version) { + switch (server->nfs_client->cl_nfsversion) { case 2: case 3: mnt =3D vfs_kern_mount(&clone_nfs_fs_type, 0, devname, mountdata); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 74b9163..e041ff8 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -758,7 +758,7 @@ static int _nfs4_proc_open(struct nfs4_o } nfs_confirm_seqid(&data->owner->so_seqid, 0); if (!(o_res->f_attr->valid & NFS_ATTR_FATTR)) - return server->rpc_ops->getattr(server, &o_res->fh, o_res->f_attr); + return server->nfs_client->rpc_ops->getattr(server, &o_res->fh, o_res-= >f_attr); return 0; } =20 diff --git a/fs/nfs/super.c b/fs/nfs/super.c index afd00f1..a23b9cc 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -247,7 +247,7 @@ static int nfs_statfs(struct dentry *den =20 lock_kernel(); =20 - error =3D server->rpc_ops->statfs(server, fh, &res); + error =3D server->nfs_client->rpc_ops->statfs(server, fh, &res); buf->f_type =3D NFS_SUPER_MAGIC; if (error < 0) goto out_err; @@ -338,10 +338,11 @@ static void nfs_show_mount_options(struc { 0, NULL, NULL } }; const struct proc_nfs_info *nfs_infop; + struct nfs_client *clp =3D nfss->nfs_client; char buf[12]; const char *proto; =20 - seq_printf(m, ",vers=3D%d", nfss->rpc_ops->version); + seq_printf(m, ",vers=3D%d", clp->rpc_ops->version); seq_printf(m, ",rsize=3D%d", nfss->rsize); seq_printf(m, ",wsize=3D%d", nfss->wsize); if (nfss->acregmin !=3D 3*HZ || showdefaults) @@ -422,7 +423,7 @@ static int nfs_show_stats(struct seq_fil seq_printf(m, ",namelen=3D%d", nfss->namelen); =20 #ifdef CONFIG_NFS_V4 - if (nfss->rpc_ops->version =3D=3D 4) { + if (nfss->nfs_client->cl_nfsversion =3D=3D 4) { seq_printf(m, "\n\tnfsv4:\t"); seq_printf(m, "bm0=3D0x%x", nfss->attr_bitmask[0]); seq_printf(m, ",bm1=3D0x%x", nfss->attr_bitmask[1]); @@ -498,7 +499,7 @@ nfs_get_root(struct super_block *sb, str struct nfs_server *server =3D NFS_SB(sb); int error; =20 - error =3D server->rpc_ops->getroot(server, rootfh, fsinfo); + error =3D server->nfs_client->rpc_ops->getroot(server, rootfh, fsinfo); if (error < 0) { dprintk("nfs_get_root: getattr error =3D %d\n", -error); return ERR_PTR(error); @@ -548,14 +549,14 @@ nfs_sb_init(struct super_block *sb, rpc_ no_root_error =3D -ENOMEM; goto out_no_root; } - sb->s_root->d_op =3D server->rpc_ops->dentry_ops; + sb->s_root->d_op =3D server->nfs_client->rpc_ops->dentry_ops; =20 /* mount time stamp, in seconds */ server->mount_time =3D jiffies; =20 /* Get some general file system info */ if (server->namelen =3D=3D 0 && - server->rpc_ops->pathconf(server, &server->fh, &pathinfo) >=3D 0) + server->nfs_client->rpc_ops->pathconf(server, &server->fh, &pathinf= o) >=3D 0) server->namelen =3D pathinfo.max_namelen; /* Work out a lot of parameters */ if (server->rsize =3D=3D 0) @@ -658,9 +659,14 @@ nfs_create_client(struct nfs_server *ser struct rpc_xprt *xprt =3D NULL; struct rpc_clnt *clnt =3D NULL; int proto =3D (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_U= DP; + int nfsversion =3D 2; =20 - clp =3D nfs_get_client(server->hostname, &server->addr, - server->rpc_ops->version); +#ifdef CONFIG_NFS_V3 + if (server->flags & NFS_MOUNT_VER3) + nfsversion =3D 3; +#endif + + clp =3D nfs_get_client(server->hostname, &server->addr, nfsversion); if (!clp) { dprintk("%s: failed to create NFS4 client.\n", __FUNCTION__); return ERR_PTR(PTR_ERR(clp)); @@ -671,6 +677,19 @@ nfs_create_client(struct nfs_server *ser server->retrans_timeo =3D timeparms.to_initval; server->retrans_count =3D timeparms.to_retries; =20 + /* Check NFS protocol revision and initialize RPC op vector + * and file handle pool. */ +#ifdef CONFIG_NFS_V3 + if (nfsversion =3D=3D 3) { + clp->rpc_ops =3D &nfs_v3_clientops; + server->caps |=3D NFS_CAP_READDIRPLUS; + } else { + clp->rpc_ops =3D &nfs_v2_clientops; + } +#else + clp->rpc_ops =3D &nfs_v2_clientops; +#endif + /* create transport and client */ xprt =3D xprt_create_proto(proto, &server->addr, &timeparms); if (IS_ERR(xprt)) { @@ -681,7 +700,7 @@ nfs_create_client(struct nfs_server *ser return (struct rpc_clnt *)xprt; } clnt =3D rpc_create_client(xprt, server->hostname, &nfs_program, - server->rpc_ops->version, data->pseudoflavor); + clp->cl_nfsversion, data->pseudoflavor); if (IS_ERR(clnt)) { dprintk("%s: cannot create RPC client. Error =3D %ld\n", __FUNCTION__, PTR_ERR(xprt)); @@ -745,7 +764,7 @@ static struct nfs_server *nfs_clone_serv fsinfo.fattr =3D data->fattr; if (NFS_PROTO(root_inode)->fsinfo(server, data->fh, &fsinfo) =3D=3D 0) nfs_super_set_maxbytes(sb, fsinfo.maxfilesize); - sb->s_root->d_op =3D server->rpc_ops->dentry_ops; + sb->s_root->d_op =3D server->nfs_client->rpc_ops->dentry_ops; sb->s_flags |=3D MS_ACTIVE; return server; out_put_root: @@ -860,19 +879,6 @@ nfs_fill_super(struct super_block *sb, s return -ENOMEM; strcpy(server->hostname, data->hostname); =20 - /* Check NFS protocol revision and initialize RPC op vector - * and file handle pool. */ -#ifdef CONFIG_NFS_V3 - if (server->flags & NFS_MOUNT_VER3) { - server->rpc_ops =3D &nfs_v3_clientops; - server->caps |=3D NFS_CAP_READDIRPLUS; - } else { - server->rpc_ops =3D &nfs_v2_clientops; - } -#else - server->rpc_ops =3D &nfs_v2_clientops; -#endif - /* Fill in pseudoflavor for mount version < 5 */ if (!(data->flags & NFS_MOUNT_SECFLAVOUR)) data->pseudoflavor =3D RPC_AUTH_UNIX; @@ -883,6 +889,7 @@ #endif server->client =3D nfs_create_client(server, data); if (IS_ERR(server->client)) return PTR_ERR(server->client); + /* RFC 2623, sec 2.3.2 */ if (authflavor !=3D RPC_AUTH_UNIX) { struct rpc_auth *auth; @@ -1124,6 +1131,8 @@ static struct rpc_clnt *nfs4_create_clie =20 /* Now create transport and client */ if (clp->cl_cons_state =3D=3D NFS_CS_INITING) { + clp->rpc_ops =3D &nfs_v4_clientops; + xprt =3D xprt_create_proto(proto, &server->addr, timeparms); if (IS_ERR(xprt)) { err =3D PTR_ERR(xprt); @@ -1134,7 +1143,7 @@ static struct rpc_clnt *nfs4_create_clie /* Bind to a reserved port! */ xprt->resvport =3D 1; clnt =3D rpc_create_client(xprt, server->hostname, &nfs_program, - server->rpc_ops->version, flavor); + clp->cl_nfsversion, flavor); if (IS_ERR(clnt)) { err =3D PTR_ERR(clnt); dprintk("%s: cannot create RPC client. Error =3D %d\n", @@ -1210,8 +1219,6 @@ static int nfs4_fill_super(struct super_ server->acdirmin =3D data->acdirmin*HZ; server->acdirmax =3D data->acdirmax*HZ; =20 - server->rpc_ops =3D &nfs_v4_clientops; - nfs_init_timeout_values(&timeparms, data->proto, data->timeo, data->ret= rans); =20 server->retrans_timeo =3D timeparms.to_initval; diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 9616419..b7b4371 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -209,7 +209,7 @@ #define NFS_SB(s) ((struct nfs_server * #define NFS_FH(inode) (&NFS_I(inode)->fh) #define NFS_SERVER(inode) (NFS_SB(inode->i_sb)) #define NFS_CLIENT(inode) (NFS_SERVER(inode)->client) -#define NFS_PROTO(inode) (NFS_SERVER(inode)->rpc_ops) +#define NFS_PROTO(inode) (NFS_SERVER(inode)->nfs_client->rpc_ops) #define NFS_ADDR(inode) (RPC_PEERADDR(NFS_CLIENT(inode))) #define NFS_COOKIEVERF(inode) (NFS_I(inode)->cookieverf) #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 e7d7662..aae7c11 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -25,6 +25,7 @@ #define NFS_CS_IDMAP 2 /* - idmap star struct list_head cl_superblocks; /* List of nfs_server structs */ =20 struct rpc_clnt * cl_rpcclient; + const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */ =20 #ifdef CONFIG_NFS_V4 u64 cl_clientid; /* constant */ @@ -74,7 +75,6 @@ struct nfs_server { struct rpc_clnt * client; /* RPC client handle */ struct rpc_clnt * client_sys; /* 2nd handle for FSINFO */ struct rpc_clnt * client_acl; /* ACL RPC client handle */ - const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */ struct nfs_iostats * io_stats; /* I/O statistics */ struct backing_dev_info backing_dev_info; int flags; /* various flags */