xprtrdma: Clean up rpcrdma_prepare_readch()
[linux-block.git] / net / sunrpc / xprtrdma / rpc_rdma.c
index 8f5d0cb683609901bd7f8eac80ad80df76f5a1d8..292f066d006e5beff3928306255a43faa23119dc 100644 (file)
@@ -204,9 +204,7 @@ rpcrdma_alloc_sparse_pages(struct xdr_buf *buf)
        return 0;
 }
 
-/* Split @vec on page boundaries into SGEs. FMR registers pages, not
- * a byte range. Other modes coalesce these SGEs into a single MR
- * when they can.
+/* Convert @vec to a single SGL element.
  *
  * Returns pointer to next available SGE, and bumps the total number
  * of SGEs consumed.
@@ -215,22 +213,11 @@ static struct rpcrdma_mr_seg *
 rpcrdma_convert_kvec(struct kvec *vec, struct rpcrdma_mr_seg *seg,
                     unsigned int *n)
 {
-       u32 remaining, page_offset;
-       char *base;
-
-       base = vec->iov_base;
-       page_offset = offset_in_page(base);
-       remaining = vec->iov_len;
-       while (remaining) {
-               seg->mr_page = NULL;
-               seg->mr_offset = base;
-               seg->mr_len = min_t(u32, PAGE_SIZE - page_offset, remaining);
-               remaining -= seg->mr_len;
-               base += seg->mr_len;
-               ++seg;
-               ++(*n);
-               page_offset = 0;
-       }
+       seg->mr_page = virt_to_page(vec->iov_base);
+       seg->mr_offset = offset_in_page(vec->iov_base);
+       seg->mr_len = vec->iov_len;
+       ++seg;
+       ++(*n);
        return seg;
 }
 
@@ -259,7 +246,7 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf,
        page_base = offset_in_page(xdrbuf->page_base);
        while (len) {
                seg->mr_page = *ppages;
-               seg->mr_offset = (char *)page_base;
+               seg->mr_offset = page_base;
                seg->mr_len = min_t(u32, PAGE_SIZE - page_base, len);
                len -= seg->mr_len;
                ++ppages;
@@ -268,10 +255,7 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf,
                page_base = 0;
        }
 
-       /* When encoding a Read chunk, the tail iovec contains an
-        * XDR pad and may be omitted.
-        */
-       if (type == rpcrdma_readch && r_xprt->rx_ep->re_implicit_roundup)
+       if (type == rpcrdma_readch)
                goto out;
 
        /* When encoding a Write chunk, some servers need to see an
@@ -283,7 +267,7 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf,
                goto out;
 
        if (xdrbuf->tail[0].iov_len)
-               seg = rpcrdma_convert_kvec(&xdrbuf->tail[0], seg, &n);
+               rpcrdma_convert_kvec(&xdrbuf->tail[0], seg, &n);
 
 out:
        if (unlikely(n > RPCRDMA_MAX_SEGS))
@@ -644,9 +628,8 @@ out_mapping_err:
        return false;
 }
 
-/* The tail iovec may include an XDR pad for the page list,
- * as well as additional content, and may not reside in the
- * same page as the head iovec.
+/* The tail iovec might not reside in the same page as the
+ * head iovec.
  */
 static bool rpcrdma_prepare_tail_iov(struct rpcrdma_req *req,
                                     struct xdr_buf *xdr,
@@ -764,27 +747,19 @@ static bool rpcrdma_prepare_readch(struct rpcrdma_xprt *r_xprt,
                                   struct rpcrdma_req *req,
                                   struct xdr_buf *xdr)
 {
+       struct kvec *tail = &xdr->tail[0];
+
        if (!rpcrdma_prepare_head_iov(r_xprt, req, xdr->head[0].iov_len))
                return false;
 
-       /* If there is a Read chunk, the page list is being handled
+       /* If there is a Read chunk, the page list is handled
         * via explicit RDMA, and thus is skipped here.
         */
 
-       /* Do not include the tail if it is only an XDR pad */
-       if (xdr->tail[0].iov_len > 3) {
-               unsigned int page_base, len;
-
-               /* If the content in the page list is an odd length,
-                * xdr_write_pages() adds a pad at the beginning of
-                * the tail iovec. Force the tail's non-pad content to
-                * land at the next XDR position in the Send message.
-                */
-               page_base = offset_in_page(xdr->tail[0].iov_base);
-               len = xdr->tail[0].iov_len;
-               page_base += len & 3;
-               len -= len & 3;
-               if (!rpcrdma_prepare_tail_iov(req, xdr, page_base, len))
+       if (tail->iov_len) {
+               if (!rpcrdma_prepare_tail_iov(req, xdr,
+                                             offset_in_page(tail->iov_base),
+                                             tail->iov_len))
                        return false;
                kref_get(&req->rl_kref);
        }
@@ -1164,14 +1139,10 @@ rpcrdma_is_bcall(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep)
         */
        p = xdr_inline_decode(xdr, 3 * sizeof(*p));
        if (unlikely(!p))
-               goto out_short;
+               return true;
 
        rpcrdma_bc_receive_call(r_xprt, rep);
        return true;
-
-out_short:
-       pr_warn("RPC/RDMA short backward direction call\n");
-       return true;
 }
 #else  /* CONFIG_SUNRPC_BACKCHANNEL */
 {