]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
xprtrdma: Clean up fixup_copy_count accounting
authorChuck Lever <chuck.lever@oracle.com>
Wed, 29 Jun 2016 17:54:58 +0000 (13:54 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Mon, 11 Jul 2016 19:50:43 +0000 (15:50 -0400)
fixup_copy_count should count only the number of bytes copied to the
page list. The head and tail are now always handled without a data
copy.

And the debugging at the end of rpcrdma_inline_fixup() is also no
longer necessary, since copy_len will be non-zero when there is reply
data in the tail (a normal and valid case).

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprtrdma/rpc_rdma.c

index a0e811dd7b84c5f656dcd320ac3d584936d24f45..dac2990ae2f7de91f91b2f782ebc4d3588977463 100644 (file)
@@ -755,11 +755,14 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, int wrchunk, __be32 **iptrp)
  * many cases this function simply updates iov_base pointers in
  * rq_rcv_buf to point directly to the received reply data, to
  * avoid copying reply data.
+ *
+ * Returns the count of bytes which had to be memcopied.
  */
-static void
+static unsigned long
 rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len, int pad)
 {
-       int i, npages, curlen, olen;
+       unsigned long fixup_copy_count;
+       int i, npages, curlen;
        char *destp;
        struct page **ppages;
        int page_base;
@@ -781,13 +784,10 @@ rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len, int pad)
        srcp += curlen;
        copy_len -= curlen;
 
-       olen = copy_len;
-       i = 0;
-       rpcx_to_rdmax(rqst->rq_xprt)->rx_stats.fixup_copy_count += olen;
        page_base = rqst->rq_rcv_buf.page_base;
        ppages = rqst->rq_rcv_buf.pages + (page_base >> PAGE_SHIFT);
        page_base &= ~PAGE_MASK;
-
+       fixup_copy_count = 0;
        if (copy_len && rqst->rq_rcv_buf.page_len) {
                int pagelist_len;
 
@@ -795,7 +795,7 @@ rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len, int pad)
                if (pagelist_len > copy_len)
                        pagelist_len = copy_len;
                npages = PAGE_ALIGN(page_base + pagelist_len) >> PAGE_SHIFT;
-               for (; i < npages; i++) {
+               for (i = 0; i < npages; i++) {
                        curlen = PAGE_SIZE - page_base;
                        if (curlen > pagelist_len)
                                curlen = pagelist_len;
@@ -809,6 +809,7 @@ rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len, int pad)
                        kunmap_atomic(destp);
                        srcp += curlen;
                        copy_len -= curlen;
+                       fixup_copy_count += curlen;
                        pagelist_len -= curlen;
                        if (!pagelist_len)
                                break;
@@ -833,10 +834,7 @@ rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len, int pad)
                rqst->rq_private_buf.tail[0].iov_base = srcp;
        }
 
-       if (copy_len)
-               dprintk("RPC:       %s: %d bytes in"
-                       " %d extra segments (%d lost)\n",
-                       __func__, olen, i, copy_len);
+       return fixup_copy_count;
 }
 
 void
@@ -999,8 +997,10 @@ rpcrdma_reply_handler(struct rpcrdma_rep *rep)
                        rep->rr_len -= RPCRDMA_HDRLEN_MIN;
                        status = rep->rr_len;
                }
-               /* Fix up the rpc results for upper layer */
-               rpcrdma_inline_fixup(rqst, (char *)iptr, rep->rr_len, rdmalen);
+
+               r_xprt->rx_stats.fixup_copy_count +=
+                       rpcrdma_inline_fixup(rqst, (char *)iptr, rep->rr_len,
+                                            rdmalen);
                break;
 
        case rdma_nomsg: