NFS/RDMA server patches for 4.5
Subsystems (4)
v3 cover NFS/RDMA server patches for 4.5
Here are patches to support server-side bi-directional RPC/RDMA operation (to enable NFSv4.1 on RPC/RDMA transports). Thanks to all who reviewed v1 and v2.
Also available in the "nfsd-rdma-for-4.5" topic branch of this git repo:
git://git.linux-nfs.org/projects/cel/cel-2.6.git
Or for browsing:
http://git.linux-nfs.org/?p=cel/cel-2.6.git;a=log;h=refs/heads/nfsd-rdma-for-4.5
Changes since v2:
- Rebased on v4.4-rc4
- Backchannel code in new source file to address dprintk issues
- svc_rdma_get_context() now uses a pre-allocated cache
- Dropped svc_rdma_send clean up
Changes since v1:
- Rebased on v4.4-rc3
- Removed the use of CONFIG_SUNRPC_BACKCHANNEL
- Fixed computation of forward and backward max_requests
- Updated some comments and patch descriptions
- pr_err and pr_info converted to dprintk
- Simplified svc_rdma_get_context()
- Dropped patch removing access_flags field
- NFSv4.1 callbacks tested with for-4.5 client
---
Chuck Lever (6):
svcrdma: Do not send XDR roundup bytes for a write chunk
svcrdma: Improve allocation of struct svc_rdma_op_ctxt
svcrdma: Define maximum number of backchannel requests
svcrdma: Add infrastructure to send backwards direction RPC/RDMA calls
svcrdma: Add infrastructure to receive backwards direction RPC/RDMA replies
xprtrdma: Add class for RDMA backwards direction transport
include/linux/sunrpc/svc_rdma.h | 13 + include/linux/sunrpc/xprt.h | 1 net/sunrpc/xprt.c | 1 net/sunrpc/xprtrdma/Makefile | 2 net/sunrpc/xprtrdma/svc_rdma.c | 17 -- net/sunrpc/xprtrdma/svc_rdma_backchannel.c | 305 ++++++++++++++++++++++++++++ net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 51 +++++ net/sunrpc/xprtrdma/svc_rdma_sendto.c | 68 ++++++ net/sunrpc/xprtrdma/svc_rdma_transport.c | 104 ++++++++-- net/sunrpc/xprtrdma/transport.c | 31 ++- net/sunrpc/xprtrdma/xprt_rdma.h | 15 + 11 files changed, 559 insertions(+), 49 deletions(-) create mode 100644 net/sunrpc/xprtrdma/svc_rdma_backchannel.c
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 1/6 svcrdma: Do not send XDR roundup bytes for a write chunk
Minor optimization: when dealing with write chunk XDR roundup, do not post a Write WR for the zero bytes in the pad. Simply update the write segment in the RPC-over-RDMA header to reflect the extra pad bytes.
The Reply chunk is also a write chunk, but the server does not use send_write_chunks() to send the Reply chunk. That's OK in this case:
the server Upper Layer typically marshals the Reply chunk contents in a single contiguous buffer, without a separate tail for the XDR pad.
The comments and the variable naming refer to "chunks" but what is really meant is "segments." The existing code sends only one xdr_write_chunk per RPC reply.
The fix assumes this as well. When the XDR pad in the first write chunk is reached, the assumption is the Write list is complete and send_write_chunks() returns.
That will remain a valid assumption until the server Upper Layer can support multiple bulk payload results per RPC.
--- net/sunrpc/xprtrdma/svc_rdma_sendto.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/sunrpc/xprtrdma/svc_rdma_sendto.c +7 -0
@@ -342,6 +342,13 @@ static int send_write_chunks(struct svcxprt_rdma *xprt, arg_ch->rs_handle, arg_ch->rs_offset, write_len); + +/* Do not send XDR pad bytes */ +if (chunk_no && write_len <4 ) { + chunk_no++; +break ; + } + chunk_off =0 ;while (write_len) { ret = send_write(xprt, rqstp,
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Tom Talpey
reviewerRe: [PATCH v3 1/6] svcrdma: Do not send XDR roundup bytes for a write chunk
Two small comments.
Quoted 32 lines · Chuck Lever
Minor optimization: when dealing with write chunk XDR roundup, do not post a Write WR for the zero bytes in the pad. Simply update the write segment in the RPC-over-RDMA header to reflect the extra pad bytes.
The Reply chunk is also a write chunk, but the server does not use
send_write_chunks()to send the Reply chunk. That's OK in this case:
the server Upper Layer typically marshals the Reply chunk contents in a single contiguous buffer, without a separate tail for the XDR pad.The comments and the variable naming refer to "chunks" but what is really meant is "segments." The existing code sends only one
xdr_write_chunkper RPC reply.The fix assumes this as well. When the XDR pad in the first write chunk is reached, the assumption is the Write list is complete and
send_write_chunks()returns.That will remain a valid assumption until the server Upper Layer can support multiple bulk payload results per RPC.
Signed-off-by Chuck Lever <[email protected]>--- net/sunrpc/xprtrdma/svc_rdma_sendto.c | 7 +++++++ 1 file changed, 7 insertions(+)net/sunrpc/xprtrdma/svc_rdma_sendto.c +0
-0
net/sunrpc/xprtrdma/svc_rdma_sendto.c static int send_write_chunks(struct svcxprt_rdma *xprt, · line 346
Quoted 5 lines
net/sunrpc/xprtrdma/svc_rdma_sendto.c +2
-0@@ -342,6 +342,13 @@ static int send_write_chunks(struct svcxprt_rdma *xprt, arg_ch->rs_handle, arg_ch->rs_offset, write_len); + +/* Do not send XDR pad bytes */
It might be clearer to say "marshal" instead of "send".
net/sunrpc/xprtrdma/svc_rdma_sendto.c static int send_write_chunks(struct svcxprt_rdma *xprt, · line 347
Quoted 1 line
net/sunrpc/xprtrdma/svc_rdma_sendto.c +1
-0+if (chunk_no && write_len <4 ) {
Why is it necessary to check for chunk_no == 0? It is not possible for leading data to ever be padding, nor is a leading data element ever less than 4 bytes long. Right?
Tom.
Quoted 14 lines
net/sunrpc/xprtrdma/svc_rdma_sendto.c +4
-1+ chunk_no++; +break ; + } + chunk_off =0 ;while (write_len) { ret = send_write(xprt, rqstp, --To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 1/6] svcrdma: Do not send XDR roundup bytes for a write chunk
Hi Tom-
Quoted 32 lines · Tom Talpey
Two small comments.
Quoted 27 lines · Chuck Lever
Minor optimization: when dealing with write chunk XDR roundup, do not post a Write WR for the zero bytes in the pad. Simply update the write segment in the RPC-over-RDMA header to reflect the extra pad bytes.
The Reply chunk is also a write chunk, but the server does not use
send_write_chunks()to send the Reply chunk. That's OK in this case:
the server Upper Layer typically marshals the Reply chunk contents in a single contiguous buffer, without a separate tail for the XDR pad.The comments and the variable naming refer to "chunks" but what is really meant is "segments." The existing code sends only one
xdr_write_chunkper RPC reply.The fix assumes this as well. When the XDR pad in the first write chunk is reached, the assumption is the Write list is complete and
send_write_chunks()returns.That will remain a valid assumption until the server Upper Layer can support multiple bulk payload results per RPC.
Signed-off-by Chuck Lever <[email protected]>--- net/sunrpc/xprtrdma/svc_rdma_sendto.c | 7 +++++++ 1 file changed, 7 insertions(+)
Quoted 12 lines
net/sunrpc/xprtrdma/svc_rdma_sendto.c static int send_write_chunks(struct svcxprt_rdma *xprt, · line 346
Quoted 10 lines
net/sunrpc/xprtrdma/svc_rdma_sendto.c +2
-0@@ -342,6 +342,13 @@ static int send_write_chunks(struct svcxprt_rdma *xprt, arg_ch->rs_handle, arg_ch->rs_offset, write_len); + +/* Do not send XDR pad bytes */ It might be clearer to say "marshal" instead of "send".
Marshaling each segment happens unconditionally in the svc_rdma_xdr_encode_array_chunk() call just before this comment. I really do mean "Do not send" here: the patch is intended to squelch the RDMA Write of the XDR pad for this chunk.
Perhaps "Do not write" would be more precise, but Bruce has already committed this patch, IIRC.
Quoted 5 lines
net/sunrpc/xprtrdma/svc_rdma_sendto.c static int send_write_chunks(struct svcxprt_rdma *xprt, · line 347
Quoted 1 line
net/sunrpc/xprtrdma/svc_rdma_sendto.c +1
-0+if (chunk_no && write_len <4 ) {Why is it necessary to check for
chunk_no== 0? It is not possible for leading data to ever be padding, nor is a leading data element ever less than 4 bytes long. Right?
I'm checking for chunk_no != 0, for exactly the reasons you mentioned.
Quoted 9 lines
Tom.
net/sunrpc/xprtrdma/svc_rdma_sendto.c static int send_write_chunks(struct svcxprt_rdma *xprt, · line 354
Quoted 7 lines
net/sunrpc/xprtrdma/svc_rdma_sendto.c +4
-0+ chunk_no++; +break ; + } + chunk_off =0 ;while (write_len) { ret = send_write(xprt, rqstp,
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 2/6 svcrdma: Improve allocation of struct svc_rdma_op_ctxt
In reply to Chuck LeverTurns out that when the maximum payload size of NFS READ and WRITE was increased to 1MB, the size of struct svc_rdma_op_ctxt increased to 6KB (x86_64). That makes allocating one of these from a kmem_cache more likely to fail.
Allocating one of these has to be fast in general, and none of the current caller sites expect allocation failure. The existing logic ensures no failure by looping and sleeping.
Since I'm about to add a caller where this allocation must always work _and_ it cannot sleep, pre-allocate them for each connection, like other RDMA transport-related resources.
--- include/linux/sunrpc/svc_rdma.h | 4 ++ net/sunrpc/xprtrdma/svc_rdma.c | 17 ------- net/sunrpc/xprtrdma/svc_rdma_transport.c | 76 ++++++++++++++++++++++++++---- net/sunrpc/xprtrdma/xprt_rdma.h | 2 - 4 files changed, 70 insertions(+), 29 deletions(-)
include/linux/sunrpc/svc_rdma.h +4 -0
@@ -69,6 +69,7 @@ extern atomic_t rdma_stat_sq_prod;* completes. */ struct svc_rdma_op_ctxt { +struct list_head free_q;struct svc_rdma_op_ctxt *read_hdr;struct svc_rdma_fastreg_mr *frmr;int hdr_count;
@@ -142,6 +143,9 @@ struct svcxprt_rdma {atomic_t sc_dma_used;atomic_t sc_ctxt_used; +struct list_head sc_ctxt_q; +spinlock_t sc_ctxt_lock; +struct list_head sc_rq_dto_q;spinlock_t sc_rq_dto_lock;struct ib_qp *sc_qp;
net/sunrpc/xprtrdma/svc_rdma.c +0 -17
@@ -71,9 +71,7 @@ atomic_t rdma_stat_rq_prod;atomic_t rdma_stat_sq_poll;atomic_t rdma_stat_sq_prod; -/* Temporary NFS request map and context caches */ struct kmem_cache *svc_rdma_map_cachep; -struct kmem_cache *svc_rdma_ctxt_cachep;struct workqueue_struct *svc_rdma_wq;
@@ -244,7 +242,6 @@ void svc_rdma_cleanup(void)#endif svc_unreg_xprt_class (&svc_rdma_class);kmem_cache_destroy (svc_rdma_map_cachep); -kmem_cache_destroy (svc_rdma_ctxt_cachep); }int svc_rdma_init (void )
@@ -275,26 +272,12 @@ int svc_rdma_init(void) goto err0; } -/* Create the temporary context cache */ - svc_rdma_ctxt_cachep = -kmem_cache_create ("svc_rdma_ctxt_cache" , -sizeof (struct svc_rdma_op_ctxt ), -0 , -SLAB_HWCACHE_ALIGN , -NULL ); -if (!svc_rdma_ctxt_cachep) { -printk (KERN_INFO "Could not allocate WR ctxt cache.\n" ); - goto err1; - } -/* Register RDMA with the SVC transport switch */ svc_reg_xprt_class (&svc_rdma_class);#if defined(CONFIG_SUNRPC_BACKCHANNEL )svc_reg_xprt_class (&svc_rdma_bc_class);#endif return 0 ; - err1: -kmem_cache_destroy (svc_rdma_map_cachep); err0:unregister_sysctl_table (svcrdma_table_header);destroy_workqueue (svc_rdma_wq);
net/sunrpc/xprtrdma/svc_rdma_transport.c +66 -10
137 lines not on this page · raw message
net/sunrpc/xprtrdma/xprt_rdma.h +0 -2
@@ -531,8 +531,6 @@ void xprt_rdma_bc_destroy(struct rpc_xprt *, unsigned int);/* Temporary NFS request map cache. Created in svc_rdma.c */ extern struct kmem_cache *svc_rdma_map_cachep; -/* WR context cache. Created in svc_rdma.c */ -extern struct kmem_cache *svc_rdma_ctxt_cachep;/* Workqueue created in svc_rdma.c */ extern struct workqueue_struct *svc_rdma_wq;
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 3/6 svcrdma: Define maximum number of backchannel requests
In reply to Chuck LeverExtra resources for handling backchannel requests have to be pre-allocated when a transport instance is created. Set a limit.
--- include/linux/sunrpc/svc_rdma.h | 2 ++ net/sunrpc/xprtrdma/svc_rdma_transport.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-)
include/linux/sunrpc/svc_rdma.h +2 -0
@@ -138,6 +138,7 @@ struct svcxprt_rdma {int sc_max_requests;/* Depth of RQ */ int sc_max_req_size;/* Size of each RQ WR buf */ +int sc_max_bc_requests;struct ib_pd *sc_pd;
@@ -182,6 +183,7 @@ struct svcxprt_rdma {#define RPCRDMA_SQ_DEPTH_MULT 8#define RPCRDMA_MAX_REQUESTS 32#define RPCRDMA_MAX_REQ_SIZE 4096 +#define RPCRDMA_MAX_BC_REQUESTS 2#define RPCSVC_MAXPAYLOAD_RDMA RPCSVC_MAXPAYLOAD
net/sunrpc/xprtrdma/svc_rdma_transport.c +9 -5
@@ -566,6 +566,7 @@ static struct svcxprt_rdma *rdma_create_xprt(struct svc_serv *serv, cma_xprt->sc_max_req_size = svcrdma_max_req_size; cma_xprt->sc_max_requests = svcrdma_max_requests; + cma_xprt->sc_max_bc_requests =RPCRDMA_MAX_BC_REQUESTS ; cma_xprt->sc_sq_depth = svcrdma_max_requests *RPCRDMA_SQ_DEPTH_MULT ;atomic_set (&cma_xprt->sc_sq_count,0 );atomic_set (&cma_xprt->sc_ctxt_used,0 );
@@ -922,6 +923,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)struct ib_device_attr devattr;int uninitialized_var (dma_mr_acc );int need_dma_mr =0 ; +int total_reqs;int ret;int i;
@@ -957,8 +959,10 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) newxprt->sc_max_sge_rd =min_t (size_t, devattr.max_sge_rd,RPCSVC_MAXPAGES ); newxprt->sc_max_requests =min ((size_t )devattr.max_qp_wr, - (size_t )svcrdma_max_requests); - newxprt->sc_sq_depth =RPCRDMA_SQ_DEPTH_MULT * newxprt->sc_max_requests; + (size_t )svcrdma_max_requests); + newxprt->sc_max_bc_requests =RPCRDMA_MAX_BC_REQUESTS ; + total_reqs = newxprt->sc_max_requests + newxprt->sc_max_bc_requests; + newxprt->sc_sq_depth = total_reqs *RPCRDMA_SQ_DEPTH_MULT ;for (i = newxprt->sc_sq_depth; i; i--) {struct svc_rdma_op_ctxt *ctxt;
@@ -997,7 +1001,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)dprintk ("svcrdma: error creating SQ CQ for connect request\n" ); goto errout; } - cq_attr.cqe = newxprt->sc_max_requests; + cq_attr.cqe = total_reqs; newxprt->sc_rq_cq = ib_create_cq(newxprt->sc_cm_id->device, rq_comp_handler, cq_event_handler,
@@ -1012,7 +1016,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) qp_attr.event_handler = qp_event_handler; qp_attr.qp_context = &newxprt->sc_xprt; qp_attr.cap.max_send_wr = newxprt->sc_sq_depth; - qp_attr.cap.max_recv_wr = newxprt->sc_max_requests; + qp_attr.cap.max_recv_wr = total_reqs; qp_attr.cap.max_send_sge = newxprt->sc_max_sge; qp_attr.cap.max_recv_sge = newxprt->sc_max_sge; qp_attr.sq_sig_type =IB_SIGNAL_REQ_WR ;
@@ -1108,7 +1112,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) newxprt->sc_cm_id->device->local_dma_lkey;/* Post receive buffers */ -for (i =0 ; i < newxprt->sc_max_requests; i++) { +for (i =0 ; i < total_reqs; i++) { ret =svc_rdma_post_recv (newxprt);if (ret) {dprintk ("svcrdma: failure posting receive buffers\n" );
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 4/6 svcrdma: Add infrastructure to send backwards direction RPC/RDMA calls
In reply to Chuck LeverTo support the NFSv4.1 backchannel on RDMA connections, add a mechanism for sending a backwards-direction RPC/RDMA call on a connection established by a client.
--- include/linux/sunrpc/svc_rdma.h | 2 + net/sunrpc/xprtrdma/svc_rdma_sendto.c | 61 +++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
include/linux/sunrpc/svc_rdma.h +2 -0
@@ -215,6 +215,8 @@ extern int rdma_read_chunk_frmr(struct svcxprt_rdma *, struct svc_rqst *,extern int svc_rdma_sendto (struct svc_rqst *);extern struct rpcrdma_read_chunk *svc_rdma_get_read_chunk (struct rpcrdma_msg *); +extern int svc_rdma_bc_post_send (struct svcxprt_rdma *, +struct svc_rdma_op_ctxt *,struct xdr_buf *);/* svc_rdma_transport.c */ extern int svc_rdma_send (struct svcxprt_rdma *,struct ib_send_wr *);
net/sunrpc/xprtrdma/svc_rdma_sendto.c +61 -0
64 lines not on this page · raw message
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 5/6 svcrdma: Add infrastructure to receive backwards direction RPC/RDMA replies
In reply to Chuck LeverTo support the NFSv4.1 backchannel on RDMA connections, add a capability for receiving an RPC/RDMA reply on a connection established by a client.
--- include/linux/sunrpc/svc_rdma.h | 5 ++ net/sunrpc/xprtrdma/Makefile | 2 - net/sunrpc/xprtrdma/svc_rdma_backchannel.c | 86 ++++++++++++++++++++++++++++ net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | 51 +++++++++++++++++ net/sunrpc/xprtrdma/xprt_rdma.h | 2 + 5 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 net/sunrpc/xprtrdma/svc_rdma_backchannel.c
include/linux/sunrpc/svc_rdma.h +5 -0
@@ -187,6 +187,11 @@ struct svcxprt_rdma {#define RPCSVC_MAXPAYLOAD_RDMA RPCSVC_MAXPAYLOAD +/* svc_rdma_backchannel.c */ +extern int svc_rdma_handle_bc_reply (struct rpc_xprt *xprt, +struct rpcrdma_msg *rmsgp, +struct xdr_buf *rcvbuf); +/* svc_rdma_marshal.c */ extern int svc_rdma_xdr_decode_req (struct rpcrdma_msg **,struct svc_rqst *); extern int svc_rdma_xdr_encode_error(struct svcxprt_rdma *,
net/sunrpc/xprtrdma/Makefile +1 -1
@@ -2,7 +2,7 @@ obj-$(CONFIG_SUNRPC_XPRT_RDMA) += rpcrdma.o rpcrdma-y := transport.o rpc_rdma.o verbs.o \ fmr_ops.o frwr_ops.o physical_ops.o \ - svc_rdma.o svc_rdma_transport.o \ + svc_rdma.o svc_rdma_backchannel.o svc_rdma_transport.o \ svc_rdma_marshal.o svc_rdma_sendto.o svc_rdma_recvfrom.o \ module.o rpcrdma-$(CONFIG_SUNRPC_BACKCHANNEL) += backchannel.o
net/sunrpc/xprtrdma/svc_rdma_backchannel.c new file +86 -0
86 lines not on this page · raw message
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +51 -0
67 lines not on this page · raw message
net/sunrpc/xprtrdma/xprt_rdma.h +2 -0
@@ -309,6 +309,8 @@ struct rpcrdma_buffer {u32 rb_bc_srv_max_requests;spinlock_t rb_reqslock;/* protect rb_allreqs */ struct list_head rb_allreqs; + +u32 rb_bc_max_requests; };#define rdmab_to_ia (b) (&container_of((b), struct rpcrdma_xprt, rx_buf)->rx_ia)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Tom Talpey
reviewerRe: [PATCH v3 5/6] svcrdma: Add infrastructure to receive backwards direction RPC/RDMA replies
Three comments.
Quoted 6 lines · Chuck Lever
To support the NFSv4.1 backchannel on RDMA connections, add a capability for receiving an RPC/RDMA reply on a connection established by a client.
(snip)+/* By convention, backchannel calls arrive via
rdma_msgtype
"By convention" is ok, but it's important to note that this is actually not "by protocol". Therefore, the following check may reject valid messages. Even though it is unlikely an implementation will insert chunks, it's not illegal, and ignoring them will be less harmful. So I'm going to remake my earlier observation that three checks below should be removed:
Quoted 4 lines
+ * messages, and never populate the chunk lists. This makes
+ * the RPC/RDMA header small and fixed in size, so it is
+ * straightforward to check the RPC header's direction field.
+ */
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c static int rdma_read_complete(struct svc_rqst *rqstp, · line 584
Quoted 10 lines
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +10
-0+static bool +svc_rdma_is_backchannel_reply (struct svc_xprt *xprt,struct rpcrdma_msg *rmsgp) +{ +__be32 *p = (__be32 *)rmsgp; + +if (!xprt->xpt_bc_xprt) +return false; + +if (rmsgp->rm_type != rdma_msg) +return false;
These three:
Quoted 7 lines
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +7
-0+if (rmsgp->rm_body.rm_chunks[0 ] != xdr_zero) +return false; +if (rmsgp->rm_body.rm_chunks[1 ] != xdr_zero) +return false; +if (rmsgp->rm_body.rm_chunks[2 ] != xdr_zero) +return false; +
(snip)
net/sunrpc/xprtrdma/xprt_rdma.h struct rpcrdma_buffer { · line 313
Quoted 10 lines
net/sunrpc/xprtrdma/xprt_rdma.h +2
-0@@ -309,6 +309,8 @@ struct rpcrdma_buffer {u32 rb_bc_srv_max_requests;spinlock_t rb_reqslock;/* protect rb_allreqs */ struct list_head rb_allreqs; + +u32 rb_bc_max_requests;
Why does this need to be u32? Shouldn't it be an int, and also the rb_bc_srv_max_requests just above? The forward channel max_requests are int, btw.
Tom.
Re: [PATCH v3 5/6] svcrdma: Add infrastructure to receive backwards direction RPC/RDMA replies
Hi Tom-
Quoted 10 lines · Tom Talpey
Three comments.
Quoted 4 lines · Chuck Lever
To support the NFSv4.1 backchannel on RDMA connections, add a capability for receiving an RPC/RDMA reply on a connection established by a client.
(snip)
Quoted 8 lines
Quoted 1 line
+/* By convention, backchannel calls arrive via
rdma_msgtype"By convention" is ok, but it's important to note that this is actually not "by protocol". Therefore, the following check may reject valid messages. Even though it is unlikely an implementation will insert chunks, it's not illegal, and ignoring them will be less harmful. So I'm going to remake my earlier observation that three checks below should be removed:
The convention is established in
https://datatracker.ietf.org/doc/draft-ietf-nfsv4-rpcrdma-bidirection/
Specifically, it states that backward direction messages in RPC-over-RDMA Version One cannot have chunks and cannot be larger than the connection's inline threshold. Thus these checks are all valid and will not reject valid forward or backward messages.
The reason for that stipulation is it makes the RPC-over-RDMA header in backward direction messages a fixed size.
a. The call direction field in incoming RPC headers is then
always at a predictable offset in backward direction calls. This means chunk lists don't have to be parsed to find the call direction field. All that is needed is to ensure that the chunk lists in the header are empty before going after the call direction field. If any chunk list is present, it must be a forward direction message.
b. The maximum size of backward direction messages is
predictable: it is always the inline threshold minus the size of the RPC-over-RDMA header (always 28 bytes when there are no chunks).
The client side has a very similar looking set of checks in its reply handler to distinguish incoming backward direction RPC calls from forward direction RPC replies.
Quoted 26 lines
Quoted 4 lines
+ * messages, and never populate the chunk lists. This makes
+ * the RPC/RDMA header small and fixed in size, so it is
+ * straightforward to check the RPC header's direction field.
+ */net/sunrpc/xprtrdma/svc_rdma_recvfrom.c static int rdma_read_complete(struct svc_rqst *rqstp, · line 584
Quoted 10 lines
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +10
-0+static bool +svc_rdma_is_backchannel_reply (struct svc_xprt *xprt,struct rpcrdma_msg *rmsgp) +{ +__be32 *p = (__be32 *)rmsgp; + +if (!xprt->xpt_bc_xprt) +return false; + +if (rmsgp->rm_type != rdma_msg) +return false;These three:
Quoted 7 lines
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +7
-0+if (rmsgp->rm_body.rm_chunks[0 ] != xdr_zero) +return false; +if (rmsgp->rm_body.rm_chunks[1 ] != xdr_zero) +return false; +if (rmsgp->rm_body.rm_chunks[2 ] != xdr_zero) +return false; +(snip)
Quoted 14 lines
net/sunrpc/xprtrdma/xprt_rdma.h struct rpcrdma_buffer { · line 313
Quoted 10 lines
net/sunrpc/xprtrdma/xprt_rdma.h +2
-0@@ -309,6 +309,8 @@ struct rpcrdma_buffer {u32 rb_bc_srv_max_requests;spinlock_t rb_reqslock;/* protect rb_allreqs */ struct list_head rb_allreqs; + +u32 rb_bc_max_requests;Why does this need to be u32? Shouldn't it be an int, and also the
rb_bc_srv_max_requestsjust above? The forward channelmax_requestsare int, btw.
The XDR definition of RPC-over-RDMA in Section 4.3 of RFC 5666 defines the on-the-wire credits field as a uint32.
I prefer that the host representation of this field match the sign and be able to contain the full range values that can be conveyed in the on-the-wire field. That makes marshaling and unmarshaling of the wire value straightforward; and reasoning about the C code in our implementation also applies directly to wire values as well.
The forward channel max_requests field on the client, rb_max_requests, is also a u32 since commit 9b1dcbc8cf46 from February 2015.
I've changed the equivalent server side field, sc_max_requests, to a u32 in the next version of this series.
ib_device_attr::max_qp_wr and svcxprt_rdma::sc_sq_depth are both signed, but I can't imagine what a negative value in these fields could mean.
sc_sq_depth is plugged into ib_qp_cap::max_send_wr and ib_cq_init_attr::cqe, which are both unsigned, so sc_sq_depth really should be unsigned too, IMHO.
--
Chuck Lever
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 6/6 xprtrdma: Add class for RDMA backwards direction transport
In reply to Chuck LeverTo support the server-side of an NFSv4.1 backchannel on RDMA connections, add a transport class that enables backward direction messages on an existing forward channel connection.
--- include/linux/sunrpc/xprt.h | 1 net/sunrpc/xprt.c | 1 net/sunrpc/xprtrdma/svc_rdma_backchannel.c | 219 ++++++++++++++++++++++++++++ net/sunrpc/xprtrdma/svc_rdma_transport.c | 14 +- net/sunrpc/xprtrdma/transport.c | 31 +++- net/sunrpc/xprtrdma/xprt_rdma.h | 11 + 6 files changed, 263 insertions(+), 14 deletions(-)
include/linux/sunrpc/xprt.h +1 -0
@@ -85,6 +85,7 @@ struct rpc_rqst {__u32 * rq_buffer;/* XDR encode buffer */ size_t rq_callsize, rq_rcvsize; +void * rq_privdata;/* xprt-specific per-rqst data */ size_t rq_xmit_bytes_sent;/* total bytes sent */ size_t rq_reply_bytes_recvd;/* total reply bytes */ /* received */
net/sunrpc/xprt.c +1 -0
@@ -1425,3 +1425,4 @@ void xprt_put(struct rpc_xprt *xprt)if (atomic_dec_and_test (&xprt->count))xprt_destroy (xprt); } +EXPORT_SYMBOL_GPL (xprt_put);
net/sunrpc/xprtrdma/svc_rdma_backchannel.c +219 -0
222 lines not on this page · raw message
net/sunrpc/xprtrdma/svc_rdma_transport.c +11 -3
@@ -1212,12 +1212,14 @@ static void __svc_rdma_free(struct work_struct *work) {struct svcxprt_rdma *rdma = container_of(work, struct svcxprt_rdma, sc_work); -dprintk ("svcrdma: svc_rdma_free(%p)\n" , rdma); +struct svc_xprt *xprt = &rdma->sc_xprt; + +dprintk ("svcrdma: %s(%p)\n" , __func__, rdma);/* We should only be called from kref_put */ -if (atomic_read (&rdma->sc_xprt.xpt_ref.refcount) !=0 ) +if (atomic_read (&xprt->xpt_ref.refcount) !=0 )pr_err ("svcrdma: sc_xprt still in use? (%d)\n" , -atomic_read (&rdma->sc_xprt.xpt_ref.refcount)); +atomic_read (&xprt->xpt_ref.refcount));/* * Destroy queued, but not processed read completions. Note
@@ -1252,6 +1254,12 @@ static void __svc_rdma_free(struct work_struct *work)pr_err ("svcrdma: dma still in use? (%d)\n" ,atomic_read (&rdma->sc_dma_used)); +/* Final put of backchannel client transport */ +if (xprt->xpt_bc_xprt) { +xprt_put (xprt->xpt_bc_xprt); + xprt->xpt_bc_xprt =NULL ; + } +/* De-allocate fastreg mr */ rdma_dealloc_frmr_q (rdma);
net/sunrpc/xprtrdma/transport.c +20 -11
@@ -63,7 +63,7 @@*/ static unsigned int xprt_rdma_slot_table_entries =RPCRDMA_DEF_SLOT_TABLE ; -static unsigned int xprt_rdma_max_inline_read =RPCRDMA_DEF_INLINE ; +unsigned int xprt_rdma_max_inline_read =RPCRDMA_DEF_INLINE ;static unsigned int xprt_rdma_max_inline_write =RPCRDMA_DEF_INLINE ;static unsigned int xprt_rdma_inline_write_padding;static unsigned int xprt_rdma_memreg_strategy =RPCRDMA_FRMR ;
@@ -143,12 +143,8 @@ static struct ctl_table sunrpc_table[] = {#endif -#define RPCRDMA_BIND_TO (60U * HZ) -#define RPCRDMA_INIT_REEST_TO (5U * HZ) -#define RPCRDMA_MAX_REEST_TO (30U * HZ) -#define RPCRDMA_IDLE_DISC_TO (5U * 60 * HZ) - -static struct rpc_xprt_ops xprt_rdma_procs;/* forward reference */ +static struct rpc_xprt_ops xprt_rdma_procs; +extern struct xprt_class xprt_rdma_bc;static void xprt_rdma_format_addresses4 (struct rpc_xprt *xprt,struct sockaddr *sap)
@@ -174,7 +170,7 @@ xprt_rdma_format_addresses6(struct rpc_xprt *xprt, struct sockaddr *sap) xprt->address_strings[RPC_DISPLAY_NETID ] =RPCBIND_NETID_RDMA6 ; } -static void +void xprt_rdma_format_addresses (struct rpc_xprt *xprt,struct sockaddr *sap) {char buf[128 ];
@@ -203,7 +199,7 @@ xprt_rdma_format_addresses(struct rpc_xprt *xprt, struct sockaddr *sap) xprt->address_strings[RPC_DISPLAY_PROTO ] ="rdma" ; } -static void +void xprt_rdma_free_addresses (struct rpc_xprt *xprt) {unsigned int i;
@@ -499,7 +495,7 @@ xprt_rdma_allocate(struct rpc_task *task, size_t size)if (req ==NULL )return NULL ; - flags =GFP_NOIO | __GFP_NOWARN; + flags =RPCRDMA_DEF_GFP ;if (RPC_IS_SWAPPER (task)) flags = __GFP_MEMALLOC |GFP_NOWAIT | __GFP_NOWARN;
@@ -639,7 +635,7 @@ drop_connection:return -ENOTCONN ;/* implies disconnect */ } -static void xprt_rdma_print_stats (struct rpc_xprt *xprt,struct seq_file *seq) +void xprt_rdma_print_stats (struct rpc_xprt *xprt,struct seq_file *seq) {struct rpcrdma_xprt *r_xprt =rpcx_to_rdmax (xprt);long idle_time =0 ;
@@ -740,6 +736,11 @@ void xprt_rdma_cleanup(void)rpcrdma_destroy_wq ();frwr_destroy_recovery_wq (); + + rc =xprt_unregister_transport (&xprt_rdma_bc); +if (rc) +dprintk ("RPC: %s: xprt_unregister(bc) returned %i\n" , + __func__, rc); }int xprt_rdma_init (void )
@@ -763,6 +764,14 @@ int xprt_rdma_init(void)return rc; } + rc =xprt_register_transport (&xprt_rdma_bc); +if (rc) { +xprt_unregister_transport (&xprt_rdma); +rpcrdma_destroy_wq (); +frwr_destroy_recovery_wq (); +return rc; + } +dprintk ("RPCRDMA Module Init, register RPC RDMA transport\n" );dprintk ("Defaults:\n" );
net/sunrpc/xprtrdma/xprt_rdma.h +11 -0
@@ -55,6 +55,11 @@#define RDMA_RESOLVE_TIMEOUT (5000)/* 5 seconds */ #define RDMA_CONNECT_RETRY_MAX (2)/* retries if no listener backlog */ +#define RPCRDMA_BIND_TO (60U * HZ) +#define RPCRDMA_INIT_REEST_TO (5U * HZ) +#define RPCRDMA_MAX_REEST_TO (30U * HZ) +#define RPCRDMA_IDLE_DISC_TO (5U * 60 * HZ) +/* * Interface Adapter -- one per transport instance */
@@ -148,6 +153,8 @@ rdmab_to_msg(struct rpcrdma_regbuf *rb)return (struct rpcrdma_msg *)rb->rg_base; } +#define RPCRDMA_DEF_GFP (GFP_NOIO | __GFP_NOWARN) +/* * struct rpcrdma_rep -- this structure encapsulates state required to recv * and complete a reply, asychronously. It needs several pieces of
@@ -516,6 +523,10 @@ int rpcrdma_marshal_req(struct rpc_rqst *);/* RPC/RDMA module init - xprtrdma/transport.c */ +extern unsigned int xprt_rdma_max_inline_read; +void xprt_rdma_format_addresses (struct rpc_xprt *xprt,struct sockaddr *sap); +void xprt_rdma_free_addresses (struct rpc_xprt *xprt); +void xprt_rdma_print_stats (struct rpc_xprt *xprt,struct seq_file *seq);int xprt_rdma_init (void );void xprt_rdma_cleanup (void );
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html