Commit 15cdc644b268a9a9ce73ce0b153129222c254b7b

Authored by Tom Tucker
Committed by Trond Myklebust
1 parent 7a8b80eb38

rpcrdma: Fix SQ size calculation when memreg is FRMR

This patch updates the computation to include the worst case situation
where three FRMR are required to map a single RPC REQ.

Signed-off-by: Tom Tucker <tom@ogc.us>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 2 changed files with 18 additions and 4 deletions Side-by-side Diff

net/sunrpc/xprtrdma/rpc_rdma.c
... ... @@ -249,6 +249,8 @@
249 249 req->rl_nchunks = nchunks;
250 250  
251 251 BUG_ON(nchunks == 0);
  252 + BUG_ON((r_xprt->rx_ia.ri_memreg_strategy == RPCRDMA_FRMR)
  253 + && (nchunks > 3));
252 254  
253 255 /*
254 256 * finish off header. If write, marshal discrim and nchunks.
net/sunrpc/xprtrdma/verbs.c
... ... @@ -650,10 +650,22 @@
650 650 ep->rep_attr.cap.max_send_wr = cdata->max_requests;
651 651 switch (ia->ri_memreg_strategy) {
652 652 case RPCRDMA_FRMR:
653   - /* Add room for frmr register and invalidate WRs */
654   - ep->rep_attr.cap.max_send_wr *= 3;
655   - if (ep->rep_attr.cap.max_send_wr > devattr.max_qp_wr)
656   - return -EINVAL;
  653 + /* Add room for frmr register and invalidate WRs.
  654 + * 1. FRMR reg WR for head
  655 + * 2. FRMR invalidate WR for head
  656 + * 3. FRMR reg WR for pagelist
  657 + * 4. FRMR invalidate WR for pagelist
  658 + * 5. FRMR reg WR for tail
  659 + * 6. FRMR invalidate WR for tail
  660 + * 7. The RDMA_SEND WR
  661 + */
  662 + ep->rep_attr.cap.max_send_wr *= 7;
  663 + if (ep->rep_attr.cap.max_send_wr > devattr.max_qp_wr) {
  664 + cdata->max_requests = devattr.max_qp_wr / 7;
  665 + if (!cdata->max_requests)
  666 + return -EINVAL;
  667 + ep->rep_attr.cap.max_send_wr = cdata->max_requests * 7;
  668 + }
657 669 break;
658 670 case RPCRDMA_MEMWINDOWS_ASYNC:
659 671 case RPCRDMA_MEMWINDOWS: