public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: linux-rdma@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: [PATCH v2 03/10] xprtrdma: unmap all FMRs during transport disconnect
Date: Sat, 08 Nov 2014 20:14:29 -0500	[thread overview]
Message-ID: <20141109011429.8806.34346.stgit@manet.1015granger.net> (raw)
In-Reply-To: <20141109010328.8806.5861.stgit@manet.1015granger.net>

When using RPCRDMA_MTHCAFMR memory registration, after a few
transport disconnect / reconnect cycles, ib_map_phys_fmr() starts to
return EINVAL because the provider has exhausted its map pool.

Make sure that all FMRs are unmapped during transport disconnect,
and that ->send_request remarshals them during an RPC retransmit.
This resets the transport's MRs to ensure that none are leaked
during a disconnect.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 net/sunrpc/xprtrdma/transport.c |    2 +-
 net/sunrpc/xprtrdma/verbs.c     |   42 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index 6a4615d..cfe9a81 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -599,7 +599,7 @@ xprt_rdma_send_request(struct rpc_task *task)
 
 	if (req->rl_niovs == 0)
 		rc = rpcrdma_marshal_req(rqst);
-	else if (r_xprt->rx_ia.ri_memreg_strategy == RPCRDMA_FRMR)
+	else if (r_xprt->rx_ia.ri_memreg_strategy != RPCRDMA_ALLPHYSICAL)
 		rc = rpcrdma_marshal_chunks(rqst, 0);
 	if (rc < 0)
 		goto failed_marshal;
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index af45cf3..3c88276 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -62,6 +62,7 @@
 #endif
 
 static void rpcrdma_reset_frmrs(struct rpcrdma_ia *);
+static void rpcrdma_reset_fmrs(struct rpcrdma_ia *);
 
 /*
  * internal functions
@@ -868,8 +869,19 @@ retry:
 		rpcrdma_ep_disconnect(ep, ia);
 		rpcrdma_flush_cqs(ep);
 
-		if (ia->ri_memreg_strategy == RPCRDMA_FRMR)
+		switch (ia->ri_memreg_strategy) {
+		case RPCRDMA_FRMR:
 			rpcrdma_reset_frmrs(ia);
+			break;
+		case RPCRDMA_MTHCAFMR:
+			rpcrdma_reset_fmrs(ia);
+			break;
+		case RPCRDMA_ALLPHYSICAL:
+			break;
+		default:
+			rc = -EIO;
+			goto out;
+		}
 
 		xprt = container_of(ia, struct rpcrdma_xprt, rx_ia);
 		id = rpcrdma_create_id(xprt, ia,
@@ -1289,6 +1301,34 @@ rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
 	kfree(buf->rb_pool);
 }
 
+/* After a disconnect, unmap all FMRs.
+ *
+ * This is invoked only in the transport connect worker in order
+ * to serialize with rpcrdma_register_fmr_external().
+ */
+static void
+rpcrdma_reset_fmrs(struct rpcrdma_ia *ia)
+{
+	struct rpcrdma_xprt *r_xprt =
+				container_of(ia, struct rpcrdma_xprt, rx_ia);
+	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
+	struct list_head *pos;
+	struct rpcrdma_mw *r;
+	LIST_HEAD(l);
+	int rc;
+
+	list_for_each(pos, &buf->rb_all) {
+		r = list_entry(pos, struct rpcrdma_mw, mw_all);
+
+		INIT_LIST_HEAD(&l);
+		list_add(&r->r.fmr->list, &l);
+		rc = ib_unmap_fmr(&l);
+		if (rc)
+			dprintk("RPC:       %s: ib_unmap_fmr failed %i\n",
+				__func__, rc);
+	}
+}
+
 /* After a disconnect, a flushed FAST_REG_MR can leave an FRMR in
  * an unusable state. Find FRMRs in this state and dereg / reg
  * each.  FRMRs that are VALID and attached to an rpcrdma_req are


  parent reply	other threads:[~2014-11-09  1:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-09  1:14 [PATCH v2 00/10] NFS/RDMA patches for 3.19 Chuck Lever
2014-11-09  1:14 ` [PATCH v2 01/10] xprtrdma: Return an errno from rpcrdma_register_external() Chuck Lever
2014-11-09  1:14 ` [PATCH v2 02/10] xprtrdma: Cap req_cqinit Chuck Lever
2014-11-09 10:13   ` Sagi Grimberg
2014-11-09 21:43     ` Chuck Lever
2014-11-09  1:14 ` Chuck Lever [this message]
2014-11-09  1:14 ` [PATCH v2 04/10] xprtrdma: Refactor tasklet scheduling Chuck Lever
2014-11-09  1:14 ` [PATCH v2 05/10] xprtrdma: Re-write rpcrdma_flush_cqs() Chuck Lever
2014-11-09  1:14 ` [PATCH v2 06/10] xprtrdma: Enable pad optimization Chuck Lever
2014-11-10 14:36   ` Anna Schumaker
2014-11-10 14:54     ` Chuck Lever
2014-11-10 15:05       ` J. Bruce Fields
2014-11-09  1:15 ` [PATCH v2 07/10] xprtrdma: Display async errors Chuck Lever
2014-11-11 14:30   ` Sagi Grimberg
2014-11-11 16:52     ` Chuck Lever
2014-11-11 18:49       ` Sagi Grimberg
2014-11-11 20:30         ` Or Gerlitz
2014-11-09  1:15 ` [PATCH v2 08/10] SUNRPC: serialize iostats updates Chuck Lever
2014-11-09  1:15 ` [PATCH v2 09/10] NFS: SETCLIENTID XDR buffer sizes are incorrect Chuck Lever
2014-11-10 15:22   ` Anna Schumaker
2014-11-10 16:21     ` Trond Myklebust
2014-11-09  1:15 ` [PATCH v2 10/10] NFS: Clean up nfs4_init_callback() Chuck Lever
2014-11-26 16:25 ` [PATCH v2 00/10] NFS/RDMA patches for 3.19 Anna Schumaker
2014-11-26 16:36   ` 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=20141109011429.8806.34346.stgit@manet.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-rdma@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