mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org, steved@redhat.com,
	trond.myklebust@fys.uio.no
Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com,
	nfsv4@linux-nfs.org, linux-kernel@vger.kernel.org
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	[thread overview]
Message-ID: <20060727205255.8443.74309.stgit@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <20060727205222.8443.29381.stgit@warthog.cambridge.redhat.com>

Maintain a common server record for NFS2/3 as well as for NFS4 so that common
stuff can be moved there from struct nfs_server.

Signed-Off-By: David Howells <dhowells@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---

 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 = NULL;
 	struct rpc_clnt		*clnt = NULL;
 	int			proto = (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP;
 
+	clp = 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);
 
 	server->retrans_timeo = 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 = %ld\n",
 				__FUNCTION__, PTR_ERR(xprt));
+		nfs_mark_client_ready(clp, PTR_ERR(xprt));
+		nfs_put_client(clp);
 		return (struct rpc_clnt *)xprt;
 	}
 	clnt = rpc_create_client(xprt, server->hostname, &nfs_program,
@@ -681,9 +691,13 @@ nfs_create_client(struct nfs_server *ser
 	clnt->cl_intr     = 1;
 	clnt->cl_softrtry = 1;
 
+	nfs_mark_client_ready(clp, 0);
+	server->nfs_client = clp;
 	return clnt;
 
 out_fail:
+	nfs_mark_client_ready(clp, PTR_ERR(xprt));
+	nfs_put_client(clp);
 	return clnt;
 }
 
@@ -759,6 +773,7 @@ static int nfs_clone_generic_sb(struct n
 	if (server == NULL)
 		goto out_err;
 	memcpy(server, parent, sizeof(*server));
+	atomic_inc(&server->nfs_client->cl_count);
 	hostname = (data->hostname != NULL) ? data->hostname : parent->hostname;
 	len = strlen(hostname) + 1;
 	server->hostname = 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_
 
 	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);
 
 	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 = 1;
 	nfs_init_timeout_values(&timeparms, proto, timeo, retrans);
 
+	nfs_put_client(server->nfs_client);
+	server->nfs_client = NULL;
 	server->client = nfs4_create_client(server, &timeparms, proto, data->authflavor);
 	if (IS_ERR((err = 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
 						 */

  parent reply	other threads:[~2006-07-27 21:05 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-27 20:52 [PATCH 00/30] Permit filesystem local caching and NFS superblock sharing " David Howells
2006-07-27 20:52 ` [PATCH 01/30] NFS: Add dentry materialisation op " David Howells
2006-07-27 20:52 ` [PATCH 02/30] NFS: Fix up split of fs/nfs/inode.c " David Howells
2006-07-27 20:52 ` [PATCH 03/30] NFS: Disambiguate nfs_stat_to_errno() " David Howells
2006-07-27 20:52 ` [PATCH 04/30] NFS: Fix NFS4 callback up/down prototypes " David Howells
2006-07-27 20:52 ` [PATCH 05/30] NFS: Rename struct nfs4_client to struct nfs_client " David Howells
2006-07-27 20:52 ` [PATCH 06/30] NFS: Rename nfs_server::nfs4_state " David Howells
2006-07-27 20:52 ` [PATCH 07/30] NFS: Return an error when starting the idmapping pipe " David Howells
2006-07-27 20:52 ` [PATCH 08/30] NFS: Add a lookupfh NFS RPC op " David Howells
2006-07-27 20:52 ` [PATCH 09/30] NFS: Add a server capabilities " David Howells
2006-07-27 20:52 ` [PATCH 10/30] NFS: Generalise the nfs_client structure " David Howells
2006-07-27 20:52 ` [PATCH 11/30] NFS: Use the dentry superblock directly in nfs_statfs() " David Howells
2006-07-27 20:52 ` [PATCH 12/30] NFS: Add extra const qualifiers " David Howells
2006-07-27 20:52 ` David Howells [this message]
2006-07-27 20:52 ` [PATCH 14/30] NFS: Make better use of inode* dereferencing macros " David Howells
2006-07-27 20:53 ` [PATCH 15/30] NFS: Move rpc_ops from nfs_server to nfs_client " David Howells
2006-07-27 20:53 ` [PATCH 16/30] NFS: Eliminate client_sys in favour of cl_rpcclient " David Howells
2006-07-27 20:53 ` [PATCH 17/30] NFS: Start rpciod in server common management " David Howells
2006-07-27 20:53 ` [PATCH 19/30] NFS: Add server and volume lists to /proc " David Howells
2006-07-27 20:53 ` [PATCH 20/30] NFS: Fix error handling " David Howells
2006-07-27 20:53 ` [PATCH 21/30] NFS: Secure the roots of the NFS subtrees in a shared superblock " David Howells
2006-07-27 20:53 ` [PATCH 22/30] FS-Cache: Provide a filesystem-specific sync'able page bit " David Howells
2006-07-27 20:53 ` [PATCH 24/30] FS-Cache: Release page->private in failed readahead " David Howells
2006-07-27 20:53 ` [PATCH 25/30] FS-Cache: Make kAFS use FS-Cache " David Howells
2006-07-27 20:53 ` [PATCH 26/30] NFS: Use local caching " David Howells
2006-07-27 20:53 ` [PATCH 27/30] FS-Cache: CacheFiles: ia64: missing copy_page export " David Howells
2006-07-27 20:53 ` [PATCH 29/30] AUTOFS: Make sure all dentries refs are released before calling kill_anon_super() " David Howells
2006-07-27 20:53 ` [PATCH 30/30] VFS: Destroy the dentries contributed by a superblock on unmounting " David Howells
2006-08-01  9:03   ` Jan Blunck
2006-08-01 10:18   ` David Howells
2006-07-28  8:55 ` [PATCH 00/30] Permit filesystem local caching and NFS superblock sharing " Jeff Garzik
2006-07-29  6:05 ` Andrew Morton
2006-07-29 11:12 ` David Howells
2006-07-29 16:30   ` Trond Myklebust
2006-09-07 17:17 ` FS-Cache patches David Howells
2006-09-18 19:10   ` Christoph Hellwig
2006-09-19  9:34   ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060727205255.8443.74309.stgit@warthog.cambridge.redhat.com \
    --to=dhowells@redhat.com \
    --cc=akpm@osdl.org \
    --cc=linux-cachefs@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nfsv4@linux-nfs.org \
    --cc=steved@redhat.com \
    --cc=torvalds@osdl.org \
    --cc=trond.myklebust@fys.uio.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome