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 11/33] NFS: NFSv4.0 transport blocking
Date: Fri, 09 Aug 2013 12:49:19 -0400	[thread overview]
Message-ID: <20130809164919.5362.82216.stgit@seurat.1015granger.net> (raw)
In-Reply-To: <20130809161957.5362.90865.stgit@seurat.1015granger.net>

Plumb in a mechanism for plugging an NFSv4.0 mount, using the
same infrastructure as NFSv4.1 sessions.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfs/nfs4proc.c |   82 +++++++++++++++++++++++++++++++++++++++++++++++------
 fs/nfs/nfs4xdr.c  |   13 +++++---
 2 files changed, 79 insertions(+), 16 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 4352d51..51f4272 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -468,6 +468,67 @@ static void nfs4_set_sequence_privileged(struct nfs4_sequence_args *args)
 	args->sa_privileged = 1;
 }
 
+static int nfs40_setup_sequence(const struct nfs_server *server,
+				struct nfs4_sequence_args *args,
+				struct nfs4_sequence_res *res,
+				struct rpc_task *task)
+{
+	struct nfs4_slot_table *tbl = server->nfs_client->cl_slot_tbl;
+	struct nfs4_slot *slot;
+
+	/* slot already allocated? */
+	if (res->sr_slot != NULL)
+		goto out_start;
+
+	spin_lock(&tbl->slot_tbl_lock);
+	if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged)
+		goto out_sleep;
+
+	slot = nfs4_alloc_slot(tbl);
+	if (IS_ERR(slot)) {
+		if (slot == ERR_PTR(-ENOMEM))
+			task->tk_timeout = HZ >> 2;
+		goto out_sleep;
+	}
+	spin_unlock(&tbl->slot_tbl_lock);
+
+	args->sa_slot = slot;
+	res->sr_slot = slot;
+
+out_start:
+	rpc_call_start(task);
+	return 0;
+
+out_sleep:
+	if (args->sa_privileged)
+		rpc_sleep_on_priority(&tbl->slot_tbl_waitq, task,
+				NULL, RPC_PRIORITY_PRIVILEGED);
+	else
+		rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
+	spin_unlock(&tbl->slot_tbl_lock);
+	return -EAGAIN;
+}
+
+static int nfs40_sequence_done(struct rpc_task *task,
+			       struct nfs4_sequence_res *res)
+{
+	struct nfs4_slot *slot = res->sr_slot;
+	struct nfs4_slot_table *tbl;
+
+	if (!RPC_WAS_SENT(task))
+		goto out;
+
+	tbl = slot->table;
+	spin_lock(&tbl->slot_tbl_lock);
+	if (!nfs41_wake_and_assign_slot(tbl, slot))
+		nfs4_free_slot(tbl, slot);
+	spin_unlock(&tbl->slot_tbl_lock);
+
+	res->sr_slot = NULL;
+out:
+	return 1;
+}
+
 #if defined(CONFIG_NFS_V4_1)
 
 static void nfs41_sequence_free_slot(struct nfs4_sequence_res *res)
@@ -612,6 +673,8 @@ static int nfs4_sequence_done(struct rpc_task *task,
 {
 	if (res->sr_slot == NULL)
 		return 1;
+	if (!res->sr_slot->table->session)
+		return nfs40_sequence_done(task, res);
 	return nfs41_sequence_done(task, res);
 }
 
@@ -686,17 +749,15 @@ static int nfs4_setup_sequence(const struct nfs_server *server,
 	struct nfs4_session *session = nfs4_get_session(server);
 	int ret = 0;
 
-	if (session == NULL) {
-		rpc_call_start(task);
-		goto out;
-	}
+	if (!session)
+		return nfs40_setup_sequence(server, args, res, task);
 
 	dprintk("--> %s clp %p session %p sr_slot %u\n",
 		__func__, session->clp, session, res->sr_slot ?
 			res->sr_slot->slot_nr : NFS4_NO_SLOT);
 
 	ret = nfs41_setup_sequence(session, args, res, task);
-out:
+
 	dprintk("<-- %s status=%d\n", __func__, ret);
 	return ret;
 }
@@ -723,22 +784,23 @@ static const struct rpc_call_ops nfs41_call_sync_ops = {
 	.rpc_call_done = nfs41_call_sync_done,
 };
 
-#else
+#else	/* !CONFIG_NFS_V4_1 */
+
 static int nfs4_setup_sequence(const struct nfs_server *server,
 			       struct nfs4_sequence_args *args,
 			       struct nfs4_sequence_res *res,
 			       struct rpc_task *task)
 {
-	rpc_call_start(task);
-	return 0;
+	return nfs40_setup_sequence(server, args, res, task);
 }
 
 static int nfs4_sequence_done(struct rpc_task *task,
 			       struct nfs4_sequence_res *res)
 {
-	return 1;
+	return nfs40_sequence_done(task, res);
 }
-#endif /* CONFIG_NFS_V4_1 */
+
+#endif	/* !CONFIG_NFS_V4_1 */
 
 static void nfs40_call_sync_prepare(struct rpc_task *task, void *calldata)
 {
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 3850b01..9b195fb 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1877,11 +1877,10 @@ static void encode_sequence(struct xdr_stream *xdr,
 	struct nfs4_slot *slot = args->sa_slot;
 	__be32 *p;
 
-	if (slot == NULL)
-		return;
-
 	tp = slot->table;
 	session = tp->session;
+	if (!session)
+		return;
 
 	encode_op_hdr(xdr, OP_SEQUENCE, decode_sequence_maxsz, hdr);
 
@@ -2062,9 +2061,9 @@ static void encode_free_stateid(struct xdr_stream *xdr,
 static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args)
 {
 #if defined(CONFIG_NFS_V4_1)
-
-	if (args->sa_slot)
-		return args->sa_slot->table->session->clp->cl_mvops->minor_version;
+	struct nfs4_session *session = args->sa_slot->table->session;
+	if (session)
+		return session->clp->cl_mvops->minor_version;
 #endif /* CONFIG_NFS_V4_1 */
 	return 0;
 }
@@ -5614,6 +5613,8 @@ static int decode_sequence(struct xdr_stream *xdr,
 
 	if (res->sr_slot == NULL)
 		return 0;
+	if (!res->sr_slot->table->session)
+		return 0;
 
 	status = decode_op_hdr(xdr, OP_SEQUENCE);
 	if (!status)


  parent reply	other threads:[~2013-08-09 16:49 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 ` Chuck Lever [this message]
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 ` [PATCH v2 18/33] NFS: Add nfs4_update_server Chuck Lever
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=20130809164919.5362.82216.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.