All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH v2 18/33] NFS: Add nfs4_update_server
Date: Fri, 09 Aug 2013 12:50:23 -0400	[thread overview]
Message-ID: <20130809165023.5362.60011.stgit@seurat.1015granger.net> (raw)
In-Reply-To: <20130809161957.5362.90865.stgit@seurat.1015granger.net>

New function nfs4_update_server() moves an nfs_server to a different
nfs_client.  This is done as part of migration recovery.

Though it may be appealing to think of them as the same thing, a
migration recovery is not the same as following a referral.

For a referral, the client has not descended into the file system
yet: it has no nfs_server, no super block, no inodes or open state.
It is enough to simply instantiate the nfs_server and super block.

For a migration, however, we have all of those things already, and
they have to be moved to a different nfs_client.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfs/client.c     |    3 +-
 fs/nfs/internal.h   |    3 ++
 fs/nfs/nfs4client.c |   87 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 340b1ef..783b868 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -945,7 +945,7 @@ void nfs_server_insert_lists(struct nfs_server *server)
 }
 EXPORT_SYMBOL_GPL(nfs_server_insert_lists);
 
-static void nfs_server_remove_lists(struct nfs_server *server)
+void nfs_server_remove_lists(struct nfs_server *server)
 {
 	struct nfs_client *clp = server->nfs_client;
 	struct nfs_net *nn;
@@ -962,6 +962,7 @@ static void nfs_server_remove_lists(struct nfs_server *server)
 
 	synchronize_rcu();
 }
+EXPORT_SYMBOL_GPL(nfs_server_remove_lists);
 
 /*
  * Allocate and initialise a server record
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 3c8373f..8392278 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -153,6 +153,7 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *,
 				  rpc_authflavor_t);
 int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *);
 void nfs_server_insert_lists(struct nfs_server *);
+void nfs_server_remove_lists(struct nfs_server *);
 void nfs_init_timeout_values(struct rpc_timeout *, int, unsigned int, unsigned int);
 int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *t,
 		rpc_authflavor_t);
@@ -173,6 +174,8 @@ extern struct nfs_server *nfs4_create_server(
 					struct nfs_subversion *);
 extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *,
 						      struct nfs_fh *);
+extern int nfs4_update_server(struct nfs_server *server, const char *hostname,
+					struct sockaddr *sap, size_t salen);
 extern void nfs_free_server(struct nfs_server *server);
 extern struct nfs_server *nfs_clone_server(struct nfs_server *,
 					   struct nfs_fh *,
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index eedd686..d462e40 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -968,3 +968,90 @@ error:
 	dprintk("<-- nfs4_create_referral_server() = error %d\n", error);
 	return ERR_PTR(error);
 }
+
+/**
+ * nfs4_update_server - Replace transitioned nfs_server's transport
+ *
+ * @server: FSID whose transport will be replaced
+ * @hostname: new end-point's hostname
+ * @sap: new end-point's socket address
+ * @salen: size of "sap"
+ *
+ * The nfs_server must be quiescent before this function is invoked.
+ * Either its session is drained, or the transport is plugged and
+ * drained.
+ *
+ * Returns zero on success, or a negative errno value.
+ */
+int nfs4_update_server(struct nfs_server *server, const char *hostname,
+		       struct sockaddr *sap, size_t salen)
+{
+	struct nfs_client *clp = server->nfs_client;
+	struct rpc_clnt *clnt = server->client;
+	struct xprt_create xargs = {
+		.ident		= clp->cl_proto,
+		.net		= &init_net,
+		.dstaddr	= sap,
+		.addrlen	= salen,
+		.servername	= hostname,
+	};
+	char buf[INET6_ADDRSTRLEN + 1];
+	struct sockaddr_storage address;
+	struct sockaddr *localaddr = (struct sockaddr *)&address;
+	struct nfs_fh *mntfh;
+	int error;
+
+	dprintk("--> %s: move FSID %llx:%llx to \"%s\")\n", __func__,
+			(unsigned long long)server->fsid.major,
+			(unsigned long long)server->fsid.minor,
+			hostname);
+
+	error = -ENOMEM;
+	mntfh = nfs_alloc_fhandle();
+	if (mntfh == NULL)
+		goto out;
+
+	error = rpc_switch_client_transport(clnt, &xargs, clnt->cl_timeout);
+	if (error != 0) {
+		dprintk("<-- %s(): rpc_switch_client_transport returned %d\n",
+			__func__, error);
+		goto out;
+	}
+
+	error = rpc_localaddr(clnt, localaddr, sizeof(address));
+	if (error != 0) {
+		dprintk("<-- %s(): rpc_localaddr returned %d\n",
+			__func__, error);
+		goto out;
+	}
+
+	error = -EAFNOSUPPORT;
+	if (rpc_ntop(localaddr, buf, sizeof(buf)) == 0) {
+		dprintk("<-- %s(): rpc_ntop returned %d\n",
+			__func__, error);
+		goto out;
+	}
+
+	nfs_server_remove_lists(server);
+	error = nfs4_set_client(server, hostname, sap, salen, buf,
+				clp->cl_rpcclient->cl_auth->au_flavor,
+				clp->cl_proto, clnt->cl_timeout,
+				clp->cl_minorversion, clp->cl_net);
+	if (error != 0) {
+		dprintk("<-- %s(): nfs4_set_client returned %d\n",
+			__func__, error);
+		goto out;
+	}
+
+	if (server->nfs_client->cl_hostname == NULL)
+		server->nfs_client->cl_hostname = kstrdup(hostname, GFP_KERNEL);
+
+	error = nfs4_server_common_setup(server, mntfh);
+	if (error < 0)
+		goto out;
+
+	dprintk("<-- %s() succeeded\n", __func__);
+out:
+	nfs_free_fhandle(mntfh);
+	return error;
+}


  parent reply	other threads:[~2013-08-09 16:50 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-09 16:47 [PATCH v2 00/33] Proposed migration patches for 3.12 Chuck Lever
2013-08-09 16:47 ` [PATCH v2 01/33] NFS: When displaying session slot numbers, use "%u" consistently Chuck Lever
2013-08-09 16:48 ` [PATCH v2 02/33] NFS: Rename nfs41_call_sync_data as a common data structure Chuck Lever
2013-08-09 16:48 ` [PATCH v2 03/33] NFS: Clean up nfs4_setup_sequence() Chuck Lever
2013-08-09 16:48 ` [PATCH v2 04/33] NFS: Common versions of sequence helper functions Chuck Lever
2013-08-09 16:48 ` [PATCH v2 05/33] NFS: Add RPC callouts to start NFSv4.0 synchronous requests Chuck Lever
2013-08-09 16:48 ` [PATCH v2 06/33] NFS: Remove unused call_sync minor version op Chuck Lever
2013-08-09 16:48 ` [PATCH v2 07/33] NFS: Enable slot table helpers for NFSv4.0 Chuck Lever
2013-09-03 16:50   ` Myklebust, Trond
2013-09-03 18:19     ` Chuck Lever
2013-08-09 16:48 ` [PATCH v2 08/33] NFS: Add global helper to set up a stand-along nfs4_slot_table Chuck Lever
2013-08-09 16:49 ` [PATCH v2 09/33] NFS: Add global helper for releasing slot table resources Chuck Lever
2013-08-09 16:49 ` [PATCH v2 10/33] NFS: Add a slot table to struct nfs_client for NFSv4.0 transport blocking Chuck Lever
2013-08-09 16:49 ` [PATCH v2 11/33] NFS: " Chuck Lever
2013-08-09 16:49 ` [PATCH v2 12/33] NFS: Enable nfs4_setup_sequence() for DELEGRETURN Chuck Lever
2013-08-09 16:49 ` [PATCH v2 13/33] NFS: Add nfs4_sequence calls for RELEASE_LOCKOWNER Chuck Lever
2013-08-09 16:49 ` [PATCH v2 14/33] NFS: Add nfs4_sequence calls for OPEN_CONFIRM Chuck Lever
2013-08-09 16:49 ` [PATCH v2 15/33] NFS: Update session draining barriers for NFSv4.0 transport blocking Chuck Lever
2013-09-03 17:52   ` Myklebust, Trond
2013-09-03 17:57     ` Chuck Lever
2013-08-09 16:50 ` [PATCH v2 16/33] SUNRPC: Modify synopsis of rpc_client_register() Chuck Lever
2013-09-03 18:04   ` Myklebust, Trond
2013-09-03 18:16     ` Chuck Lever
2013-09-03 18:23       ` Myklebust, Trond
2013-09-03 18:33         ` Chuck Lever
2013-08-09 16:50 ` [PATCH v2 17/33] SUNRPC: Add a helper to switch the transport of an rpc_clnt Chuck Lever
2013-08-09 16:50 ` Chuck Lever [this message]
2013-08-09 16:50 ` [PATCH v2 19/33] NFS: Add functions to swap transports during migration recovery Chuck Lever
2013-08-09 16:50 ` [PATCH v2 20/33] NFS: Introduce a vector of migration recovery ops Chuck Lever
2013-08-09 16:50 ` [PATCH v2 21/33] NFS: Export _nfs_display_fhandle() Chuck Lever
2013-08-09 16:50 ` [PATCH v2 22/33] NFS: Add method to retrieve fs_locations during migration recovery Chuck Lever
2013-08-09 16:51 ` [PATCH v2 23/33] NFS: Add a super_block backpointer to the nfs_server struct Chuck Lever
2013-08-09 16:51 ` [PATCH v2 24/33] NFS: Add basic migration support to state manager thread Chuck Lever
2013-08-09 16:51 ` [PATCH v2 25/33] NFS: Re-use exit code in nfs4_async_handle_error() Chuck Lever
2013-08-09 16:51 ` [PATCH v2 26/33] NFS: Rename "stateid_invalid" label Chuck Lever
2013-08-09 16:51 ` [PATCH v2 27/33] NFS: Add migration recovery callouts in nfs4proc.c Chuck Lever
2013-08-09 16:51 ` [PATCH v2 28/33] NFS: Add method to detect whether an FSID is still on the server Chuck Lever
2013-08-09 16:52 ` [PATCH v2 29/33] NFS: Implement support for NFS4ERR_LEASE_MOVED in state manager Chuck Lever
2013-08-09 16:52 ` [PATCH v2 30/33] NFS: Implement support for NFS4ERR_LEASE_MOVED Chuck Lever
2013-08-09 16:52 ` [PATCH v2 31/33] " Chuck Lever
2013-08-09 16:52 ` [PATCH v2 32/33] NFS: Implement NFSv4.1 " Chuck Lever
2013-08-09 16:52 ` [PATCH v2 33/33] NFS: Set EXCHGID4_FLAG_SUPP_MOVED_MIGR Chuck Lever

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=20130809165023.5362.60011.stgit@seurat.1015granger.net \
    --to=chuck.lever@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.