Linux NFS development
 help / color / mirror / Atom feed
From: Tom Talpey <talpey@netapp.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 13/15] RPC/RDMA: harden connection logic against missing/late rdma_cm upcalls.
Date: Wed, 08 Oct 2008 11:49:06 -0400	[thread overview]
Message-ID: <20081008154906.1336.92261.stgit@tmt3.nane.netapp.com> (raw)
In-Reply-To: <20081008154506.1336.59892.stgit-pfX4bTJKMULWwzOYslWYilaTQe2KTcn/@public.gmane.org>

Add defensive timeouts to wait_for_completion() calls in RDMA
address resolution, and make them interruptible. Fix the timeout
units to milliseconds (formerly jiffies) and move to private header.

Signed-off-by: Tom Talpey <talpey@netapp.com>
---

 net/sunrpc/xprtrdma/verbs.c     |   11 +++++++----
 net/sunrpc/xprtrdma/xprt_rdma.h |    3 +++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/include/linux/sunrpc/xprtrdma.h b/include/linux/sunrpc/xprtrdma.h
index 55a5d92..54a379c 100644
--- a/include/linux/sunrpc/xprtrdma.h
+++ b/include/linux/sunrpc/xprtrdma.h
@@ -66,9 +66,6 @@
 
 #define RPCRDMA_INLINE_PAD_THRESH  (512)/* payload threshold to pad (bytes) */
 
-#define RDMA_RESOLVE_TIMEOUT	(5*HZ)	/* TBD 5 seconds */
-#define RDMA_CONNECT_RETRY_MAX	(2)	/* retries if no listener backlog */
-
 /* memory registration strategies */
 #define RPCRDMA_PERSISTENT_REGISTRATION (1)
 
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 9ef7e0d..4076773 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -284,6 +284,7 @@ rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
 	switch (event->event) {
 	case RDMA_CM_EVENT_ADDR_RESOLVED:
 	case RDMA_CM_EVENT_ROUTE_RESOLVED:
+		ia->ri_async_rc = 0;
 		complete(&ia->ri_done);
 		break;
 	case RDMA_CM_EVENT_ADDR_ERROR:
@@ -363,26 +364,28 @@ rpcrdma_create_id(struct rpcrdma_xprt *xprt,
 		return id;
 	}
 
-	ia->ri_async_rc = 0;
+	ia->ri_async_rc = -ETIMEDOUT;
 	rc = rdma_resolve_addr(id, NULL, addr, RDMA_RESOLVE_TIMEOUT);
 	if (rc) {
 		dprintk("RPC:       %s: rdma_resolve_addr() failed %i\n",
 			__func__, rc);
 		goto out;
 	}
-	wait_for_completion(&ia->ri_done);
+	wait_for_completion_interruptible_timeout(&ia->ri_done,
+				msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT) + 1);
 	rc = ia->ri_async_rc;
 	if (rc)
 		goto out;
 
-	ia->ri_async_rc = 0;
+	ia->ri_async_rc = -ETIMEDOUT;
 	rc = rdma_resolve_route(id, RDMA_RESOLVE_TIMEOUT);
 	if (rc) {
 		dprintk("RPC:       %s: rdma_resolve_route() failed %i\n",
 			__func__, rc);
 		goto out;
 	}
-	wait_for_completion(&ia->ri_done);
+	wait_for_completion_interruptible_timeout(&ia->ri_done,
+				msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT) + 1);
 	rc = ia->ri_async_rc;
 	if (rc)
 		goto out;
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
index 2db2344..99bfbf3 100644
--- a/net/sunrpc/xprtrdma/xprt_rdma.h
+++ b/net/sunrpc/xprtrdma/xprt_rdma.h
@@ -51,6 +51,9 @@
 #include <linux/sunrpc/rpc_rdma.h> 	/* RPC/RDMA protocol */
 #include <linux/sunrpc/xprtrdma.h> 	/* xprt parameters */
 
+#define RDMA_RESOLVE_TIMEOUT	(5000)	/* 5 seconds */
+#define RDMA_CONNECT_RETRY_MAX	(2)	/* retries if no listener backlog */
+
 /*
  * Interface Adapter -- one per transport instance
  */


  parent reply	other threads:[~2008-10-08 16:22 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-08 15:46 [PATCH 00/15] RPC/RDMA patchset for next merge window Tom Talpey
     [not found] ` <20081008154506.1336.59892.stgit-pfX4bTJKMULWwzOYslWYilaTQe2KTcn/@public.gmane.org>
2008-10-08 15:47   ` [PATCH 01/15] RPC/RDMA: refactor the inline memory registration code Tom Talpey
2008-10-08 15:47   ` [PATCH 02/15] RPC/RDMA: add data types and new FRMR memory registration enum Tom Talpey
     [not found]     ` <20081008154713.1336.41538.stgit-pfX4bTJKMULWwzOYslWYilaTQe2KTcn/@public.gmane.org>
2008-10-08 17:23       ` Trond Myklebust
2008-10-08 17:30         ` Talpey, Thomas
     [not found]           ` <RTPCLUEXC1-PRDmcarc00000072-rtwIt2gI0FxT+ZUat5FNkAK/GNPrWCqfQQ4Iyu8u01E@public.gmane.org>
2008-10-08 17:40             ` Trond Myklebust
2008-10-08 17:55             ` J. Bruce Fields
2008-10-08 17:58               ` Talpey, Thomas
2008-10-08 15:47   ` [PATCH 03/15] RPC/RDMA: check selected memory registration mode at runtime Tom Talpey
     [not found]     ` <20081008154723.1336.57976.stgit-pfX4bTJKMULWwzOYslWYilaTQe2KTcn/@public.gmane.org>
2008-10-08 17:22       ` Trond Myklebust
2008-10-08 17:29         ` Talpey, Thomas
     [not found]           ` <RTPCLUEXC1-PRD8yfog00000071-rtwIt2gI0FxT+ZUat5FNkAK/GNPrWCqfQQ4Iyu8u01E@public.gmane.org>
2008-10-08 17:40             ` Trond Myklebust
2008-10-08 15:47   ` [PATCH 04/15] RPC/RDMA: support FRMR client memory registration Tom Talpey
2008-10-08 15:47   ` [PATCH 05/15] RPC/RDMA: fix connection IRD/ORD setting Tom Talpey
     [not found]     ` <20081008154744.1336.20909.stgit-pfX4bTJKMULWwzOYslWYilaTQe2KTcn/@public.gmane.org>
2008-10-08 17:26       ` Trond Myklebust
2008-10-08 17:32         ` Talpey, Thomas
2008-10-08 15:47   ` [PATCH 06/15] RPC/RDMA: suppress retransmit on RPC/RDMA clients Tom Talpey
2008-10-08 15:48   ` [PATCH 07/15] RPC/RDMA: maintain the RPC task bytes-sent statistic Tom Talpey
2008-10-08 15:48   ` [PATCH 08/15] RPC/RDMA: avoid an oops due to disconnect racing with async upcalls Tom Talpey
2008-10-08 15:48   ` [PATCH 09/15] RPC/RDMA: adhere to protocol for unpadded client trailing write chunks Tom Talpey
     [not found]     ` <20081008154825.1336.79549.stgit-pfX4bTJKMULWwzOYslWYilaTQe2KTcn/@public.gmane.org>
2008-10-08 17:29       ` Trond Myklebust
2008-10-08 17:33         ` Talpey, Thomas
2008-10-08 15:48   ` [PATCH 10/15] RPC/RDMA: return a consistent error to mount, when connect fails Tom Talpey
     [not found]     ` <20081008154835.1336.85484.stgit-pfX4bTJKMULWwzOYslWYilaTQe2KTcn/@public.gmane.org>
2008-10-08 17:31       ` Trond Myklebust
2008-10-08 17:40         ` Talpey, Thomas
     [not found]           ` <RTPCLUEXC1-PRDbpH7100000075-rtwIt2gI0FxT+ZUat5FNkAK/GNPrWCqfQQ4Iyu8u01E@public.gmane.org>
2008-10-08 17:43             ` Trond Myklebust
2008-10-08 19:56               ` Talpey, Thomas
2008-10-08 15:48   ` [PATCH 11/15] RPC/RDMA: fix connect/reconnect resource leak Tom Talpey
2008-10-08 15:48   ` [PATCH 12/15] RPC/RDMA: correct a 5 second pause on reconnecting to an idle server Tom Talpey
     [not found]     ` <20081008154856.1336.18339.stgit-pfX4bTJKMULWwzOYslWYilaTQe2KTcn/@public.gmane.org>
2008-10-08 17:35       ` Trond Myklebust
2008-10-08 17:51         ` Talpey, Thomas
     [not found]           ` <RTPCLUEXC1-PRDjbDt300000076-rtwIt2gI0FxT+ZUat5FNkAK/GNPrWCqfQQ4Iyu8u01E@public.gmane.org>
2008-10-08 18:04             ` Trond Myklebust
2008-10-08 19:05               ` Talpey, Thomas
2008-10-08 15:49   ` Tom Talpey [this message]
2008-10-08 15:49   ` [PATCH 14/15] RPC/RDMA: reformat a debug printk to keep lines together Tom Talpey
2008-10-08 15:49   ` [PATCH 15/15] RPC/RDMA: optionally emit useful transport info upon connect/disconnect Tom Talpey

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=20081008154906.1336.92261.stgit@tmt3.nane.netapp.com \
    --to=talpey@netapp.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