linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Malahal Naineni <malahal@us.ibm.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 06/13] NFS: Add an API for cloning an nfs_client
Date: Mon, 30 Jan 2012 13:29:48 -0600	[thread overview]
Message-ID: <1327951795-16400-7-git-send-email-malahal@us.ibm.com> (raw)
In-Reply-To: <1327951795-16400-1-git-send-email-malahal@us.ibm.com>

From: Chuck Lever <chuck.lever@oracle.com>

After a migration event, we have to preserve the long-form client ID
or session ID the client used with the source server, and introduce it
to the destination server, in case the migration transparently
migrated state for the migrating FSID.

To preserve this state information, clone the source FSID's
nfs_client.  The migrated FSID is moved from the original nfs_client
to the cloned one.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: malahal Naineni <malahal@us.ibm.com>
---
 fs/nfs/client.c   |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/internal.h |    4 ++++
 2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index be5e702..3e3c2ff 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1435,6 +1435,52 @@ error:
 	return error;
 }
 
+int nfs4_clone_client(struct nfs_client *clp, const struct sockaddr *sap,
+		      size_t salen, const char *ip_addr,
+		      struct nfs_server *server)
+{
+	struct rpc_clnt *rpcclnt = clp->cl_rpcclient;
+	struct nfs_client_initdata cl_init = {
+		.addr		= sap,
+		.addrlen	= salen,
+		.rpc_ops	= &nfs_v4_clientops,
+		.proto		= rpc_protocol(rpcclnt),
+		.minorversion	= clp->cl_minorversion,
+	};
+	struct nfs_client *new;
+	int status = 0;
+
+	dprintk("--> %s cloning \"%s\" (client ID %llx)\n",
+		__func__, clp->cl_hostname, clp->cl_clientid);
+
+	new = nfs_get_client(&cl_init, rpcclnt->cl_timeout, ip_addr,
+				rpcclnt->cl_auth->au_flavor, 0);
+	if (IS_ERR(new)) {
+		dprintk("<-- %s nfs_get_client failed\n", __func__);
+		status = PTR_ERR(new);
+		goto out;
+	}
+
+	nfs_server_remove_lists(server);
+	server->nfs_client = new;
+	nfs_server_insert_lists(server);
+
+	/*
+	 * The client ID verifier is derived from cl_boot_time.
+	 * This verifier must not change, or callback update will
+	 * act like a regular SETCLIENTID, causing the server to
+	 * lose state.
+	 */
+	new->cl_boot_time = clp->cl_boot_time;
+
+	dprintk("<-- %s moved (%llx:%llx) to nfs_client %p\n", __func__,
+			(unsigned long long)server->fsid.major,
+			(unsigned long long)server->fsid.minor, new);
+
+out:
+	return status;
+}
+
 /*
  * Set up a pNFS Data Server client.
  *
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 8102db9..93c8daa 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -165,6 +165,10 @@ extern struct nfs_server *nfs_clone_server(struct nfs_server *,
 					   struct nfs_fattr *);
 extern void nfs_mark_client_ready(struct nfs_client *clp, int state);
 extern int nfs4_check_client_ready(struct nfs_client *clp);
+extern int nfs4_clone_client(struct nfs_client *clp,
+			     const struct sockaddr *sap, size_t salen,
+			     const char *ip_addr,
+			     struct nfs_server *server);
 extern struct nfs_client *nfs4_set_ds_client(struct nfs_client* mds_clp,
 					     const struct sockaddr *ds_addr,
 					     int ds_addrlen, int ds_proto);
-- 
1.7.8.3


  parent reply	other threads:[~2012-01-30 19:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30 19:29 [RFC] [PATCH 00/13] NFS4 replication support Malahal Naineni
2012-01-30 19:29 ` [PATCH 01/13] SUNRPC: Allow temporary blocking of an rpc client Malahal Naineni
2012-01-30 19:29 ` [PATCH 02/13] SUNRPC: Use RCU to dereference the rpc_clnt.cl_xprt field Malahal Naineni
2012-01-30 19:29 ` [PATCH 03/13] SUNRPC: Move clnt->cl_server into struct rpc_xprt Malahal Naineni
2012-01-30 19:29 ` [PATCH 04/13] SUNRPC: Add a helper to switch the transport of the rpc_client Malahal Naineni
2012-01-30 19:29 ` [PATCH 05/13] SUNRPC: Add API to acquire source address Malahal Naineni
2012-01-30 19:29 ` Malahal Naineni [this message]
2012-01-30 19:29 ` [PATCH 07/13] NFS: Save root file handle in nfs_server Malahal Naineni
2012-01-30 19:29 ` [PATCH 08/13] NFS: Store server locations for replication Malahal Naineni
2012-01-30 19:29 ` [PATCH 09/13] NFS: Add replica servers to volumes proc file Malahal Naineni
2012-01-30 19:29 ` [PATCH 10/13] NFS: Add replace transport infrastructure for replication Malahal Naineni
2012-01-30 19:29 ` [PATCH 11/13] NFS: Add replication capability to state manager thread Malahal Naineni
2012-01-30 19:29 ` [PATCH 12/13] NFS: Handle replication on a timeout error Malahal Naineni
2012-01-30 19:29 ` [PATCH 13/13] NFS: Avoid spurious replication recoveries Malahal Naineni

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=1327951795-16400-7-git-send-email-malahal@us.ibm.com \
    --to=malahal@us.ibm.com \
    --cc=linux-nfs@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).