From: Tom Talpey <talpey@netapp.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 03/15] RPC/RDMA: check selected memory registration mode at runtime.
Date: Wed, 08 Oct 2008 11:47:24 -0400 [thread overview]
Message-ID: <20081008154723.1336.57976.stgit@tmt3.nane.netapp.com> (raw)
In-Reply-To: <20081008154506.1336.59892.stgit-pfX4bTJKMULWwzOYslWYilaTQe2KTcn/@public.gmane.org>
At transport creation, check for, and use, any local dma lkey.
Then, check that the selected memory registration mode is in fact
supported by the RDMA adapter selected for the mount. Fall back
to best alternative if not.
Signed-off-by: Tom Talpey <talpey@netapp.com>
Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---
net/sunrpc/xprtrdma/verbs.c | 95 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 80 insertions(+), 15 deletions(-)
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index d04208a..0f3b431 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -423,7 +423,8 @@ rpcrdma_clean_cq(struct ib_cq *cq)
int
rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
{
- int rc;
+ int rc, mem_priv;
+ struct ib_device_attr devattr;
struct rpcrdma_ia *ia = &xprt->rx_ia;
init_completion(&ia->ri_done);
@@ -443,6 +444,53 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
}
/*
+ * Query the device to determine if the requested memory
+ * registration strategy is supported. If it isn't, set the
+ * strategy to a globally supported model.
+ */
+ rc = ib_query_device(ia->ri_id->device, &devattr);
+ if (rc) {
+ dprintk("RPC: %s: ib_query_device failed %d\n",
+ __func__, rc);
+ goto out2;
+ }
+
+ if (devattr.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY) {
+ ia->ri_have_dma_lkey = 1;
+ ia->ri_dma_lkey = ia->ri_id->device->local_dma_lkey;
+ }
+
+ switch (memreg) {
+ case RPCRDMA_MEMWINDOWS:
+ case RPCRDMA_MEMWINDOWS_ASYNC:
+ if (!(devattr.device_cap_flags & IB_DEVICE_MEM_WINDOW)) {
+ dprintk("RPC: %s: MEMWINDOWS registration "
+ "specified but not supported by adapter, "
+ "using slower RPCRDMA_REGISTER\n",
+ __func__);
+ memreg = RPCRDMA_REGISTER;
+ }
+ break;
+ case RPCRDMA_MTHCAFMR:
+ if (!ia->ri_id->device->alloc_fmr) {
+#if RPCRDMA_PERSISTENT_REGISTRATION
+ dprintk("RPC: %s: MTHCAFMR registration "
+ "specified but not supported by adapter, "
+ "using riskier RPCRDMA_ALLPHYSICAL\n",
+ __func__);
+ memreg = RPCRDMA_ALLPHYSICAL;
+#else
+ dprintk("RPC: %s: MTHCAFMR registration "
+ "specified but not supported by adapter, "
+ "using slower RPCRDMA_REGISTER\n",
+ __func__);
+ memreg = RPCRDMA_REGISTER;
+#endif
+ }
+ break;
+ }
+
+ /*
* Optionally obtain an underlying physical identity mapping in
* order to do a memory window-based bind. This base registration
* is protected from remote access - that is enabled only by binding
@@ -450,22 +498,27 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
* revoked after the corresponding completion similar to a storage
* adapter.
*/
- if (memreg > RPCRDMA_REGISTER) {
- int mem_priv = IB_ACCESS_LOCAL_WRITE;
- switch (memreg) {
+ switch (memreg) {
+ case RPCRDMA_BOUNCEBUFFERS:
+ case RPCRDMA_REGISTER:
+ break;
#if RPCRDMA_PERSISTENT_REGISTRATION
- case RPCRDMA_ALLPHYSICAL:
- mem_priv |= IB_ACCESS_REMOTE_WRITE;
- mem_priv |= IB_ACCESS_REMOTE_READ;
- break;
+ case RPCRDMA_ALLPHYSICAL:
+ mem_priv = IB_ACCESS_LOCAL_WRITE |
+ IB_ACCESS_REMOTE_WRITE |
+ IB_ACCESS_REMOTE_READ;
+ goto register_setup;
#endif
- case RPCRDMA_MEMWINDOWS_ASYNC:
- case RPCRDMA_MEMWINDOWS:
- mem_priv |= IB_ACCESS_MW_BIND;
- break;
- default:
+ case RPCRDMA_MEMWINDOWS_ASYNC:
+ case RPCRDMA_MEMWINDOWS:
+ mem_priv = IB_ACCESS_LOCAL_WRITE |
+ IB_ACCESS_MW_BIND;
+ goto register_setup;
+ case RPCRDMA_MTHCAFMR:
+ if (ia->ri_have_dma_lkey)
break;
- }
+ mem_priv = IB_ACCESS_LOCAL_WRITE;
+ register_setup:
ia->ri_bind_mem = ib_get_dma_mr(ia->ri_pd, mem_priv);
if (IS_ERR(ia->ri_bind_mem)) {
printk(KERN_ALERT "%s: ib_get_dma_mr for "
@@ -475,7 +528,15 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
memreg = RPCRDMA_REGISTER;
ia->ri_bind_mem = NULL;
}
+ break;
+ default:
+ printk(KERN_ERR "%s: invalid memory registration mode %d\n",
+ __func__, memreg);
+ rc = -EINVAL;
+ goto out2;
}
+ dprintk("RPC: %s: memory registration strategy is %d\n",
+ __func__, memreg);
/* Else will do memory reg/dereg for each chunk */
ia->ri_memreg_strategy = memreg;
@@ -1248,7 +1309,11 @@ rpcrdma_register_internal(struct rpcrdma_ia *ia, void *va, int len,
va, len, DMA_BIDIRECTIONAL);
iov->length = len;
- if (ia->ri_bind_mem != NULL) {
+ if (ia->ri_have_dma_lkey) {
+ *mrp = NULL;
+ iov->lkey = ia->ri_dma_lkey;
+ return 0;
+ } else if (ia->ri_bind_mem != NULL) {
*mrp = NULL;
iov->lkey = ia->ri_bind_mem->lkey;
return 0;
next prev 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 ` Tom Talpey [this message]
[not found] ` <20081008154723.1336.57976.stgit-pfX4bTJKMULWwzOYslWYilaTQe2KTcn/@public.gmane.org>
2008-10-08 17:22 ` [PATCH 03/15] RPC/RDMA: check selected memory registration mode at runtime 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 ` [PATCH 13/15] RPC/RDMA: harden connection logic against missing/late rdma_cm upcalls Tom Talpey
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=20081008154723.1336.57976.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