From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Howells Subject: [PATCH 13/30] NFS: Maintain a common server record for NFS2/3 as well as for NFS4 [try #11] Date: Thu, 27 Jul 2006 21:52:56 +0100 Message-ID: <20060727205255.8443.74309.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 Maintain a common server record for NFS2/3 as well as for NFS4 so that co= mmon stuff can be moved there from struct nfs_server. Signed-Off-By: David Howells Signed-off-by: Trond Myklebust --- fs/nfs/super.c | 21 ++++++++++++++++++++- include/linux/nfs_fs_sb.h | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 65e1bec..afd00f1 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -653,11 +653,19 @@ static void nfs_init_timeout_values(stru static struct rpc_clnt * nfs_create_client(struct nfs_server *server, const struct nfs_mount_data= *data) { + struct nfs_client *clp; struct rpc_timeout timeparms; 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; =20 + clp =3D nfs_get_client(server->hostname, &server->addr, + server->rpc_ops->version); + if (!clp) { + dprintk("%s: failed to create NFS4 client.\n", __FUNCTION__); + return ERR_PTR(PTR_ERR(clp)); + } + nfs_init_timeout_values(&timeparms, proto, data->timeo, data->retrans); =20 server->retrans_timeo =3D timeparms.to_initval; @@ -668,6 +676,8 @@ nfs_create_client(struct nfs_server *ser if (IS_ERR(xprt)) { dprintk("%s: cannot create RPC transport. Error =3D %ld\n", __FUNCTION__, PTR_ERR(xprt)); + nfs_mark_client_ready(clp, PTR_ERR(xprt)); + nfs_put_client(clp); return (struct rpc_clnt *)xprt; } clnt =3D rpc_create_client(xprt, server->hostname, &nfs_program, @@ -681,9 +691,13 @@ nfs_create_client(struct nfs_server *ser clnt->cl_intr =3D 1; clnt->cl_softrtry =3D 1; =20 + nfs_mark_client_ready(clp, 0); + server->nfs_client =3D clp; return clnt; =20 out_fail: + nfs_mark_client_ready(clp, PTR_ERR(xprt)); + nfs_put_client(clp); return clnt; } =20 @@ -759,6 +773,7 @@ static int nfs_clone_generic_sb(struct n if (server =3D=3D NULL) goto out_err; memcpy(server, parent, sizeof(*server)); + atomic_inc(&server->nfs_client->cl_count); hostname =3D (data->hostname !=3D NULL) ? data->hostname : parent->host= name; len =3D strlen(hostname) + 1; server->hostname =3D kmalloc(len, GFP_KERNEL); @@ -791,6 +806,7 @@ out_deactivate: out_rpciod_down: rpciod_down(); kfree(server->hostname); + nfs_put_client(server->nfs_client); kfree(server); return simple_set_mnt(mnt, sb); kill_rpciod: @@ -798,6 +814,7 @@ kill_rpciod: free_hostname: kfree(server->hostname); free_server: + nfs_put_client(server->nfs_client); kfree(server); out_err: return error; @@ -1066,6 +1083,7 @@ static void nfs_kill_super(struct super_ =20 nfs_free_iostats(server->io_stats); kfree(server->hostname); + nfs_put_client(server->nfs_client); kfree(server); nfs_release_automount_timer(); } @@ -1416,7 +1434,6 @@ static struct super_block *nfs4_clone_sb nfs4_server_capabilities(server, &server->fh); =20 down_write(&clp->cl_sem); - atomic_inc(&clp->cl_count); list_add_tail(&server->nfs4_siblings, &clp->cl_superblocks); up_write(&clp->cl_sem); return sb; @@ -1471,6 +1488,8 @@ static struct nfs_server *nfs4_referral_ retrans =3D 1; nfs_init_timeout_values(&timeparms, proto, timeo, retrans); =20 + nfs_put_client(server->nfs_client); + server->nfs_client =3D NULL; server->client =3D nfs4_create_client(server, &timeparms, proto, data->= authflavor); if (IS_ERR((err =3D server->client))) goto out_err; diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 95f32d5..e7d7662 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -70,6 +70,7 @@ #endif * NFS client parameters stored in the superblock. */ struct nfs_server { + struct nfs_client * nfs_client; /* shared client and NFS4 state */ 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 */ @@ -103,7 +104,6 @@ #ifdef CONFIG_NFS_V4 */ char ip_addr[16]; char * mnt_path; - struct nfs_client * nfs_client; /* all NFSv4 state starts here */ struct list_head nfs4_siblings; /* List of other nfs_server structs * that share the same clientid */