]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/sunrpc/xprtrdma/rpc_rdma.c
xprtrdma: Check inline size before providing a Write chunk
[linux.git] / net / sunrpc / xprtrdma / rpc_rdma.c
index d18614e02b4e8d5e31e00795397b64cc7bfc0463..7774aee7c01387d7df74c91faa27543ffc8a337c 100644 (file)
@@ -164,6 +164,21 @@ static bool rpcrdma_results_inline(struct rpcrdma_xprt *r_xprt,
        return rqst->rq_rcv_buf.buflen <= ia->ri_max_inline_read;
 }
 
+/* The client is required to provide a Reply chunk if the maximum
+ * size of the non-payload part of the RPC Reply is larger than
+ * the inline threshold.
+ */
+static bool
+rpcrdma_nonpayload_inline(const struct rpcrdma_xprt *r_xprt,
+                         const struct rpc_rqst *rqst)
+{
+       const struct xdr_buf *buf = &rqst->rq_rcv_buf;
+       const struct rpcrdma_ia *ia = &r_xprt->rx_ia;
+
+       return buf->head[0].iov_len + buf->tail[0].iov_len <
+               ia->ri_max_inline_read;
+}
+
 /* 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.
@@ -762,7 +777,8 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst)
         */
        if (rpcrdma_results_inline(r_xprt, rqst))
                wtype = rpcrdma_noch;
-       else if (ddp_allowed && rqst->rq_rcv_buf.flags & XDRBUF_READ)
+       else if ((ddp_allowed && rqst->rq_rcv_buf.flags & XDRBUF_READ) &&
+                rpcrdma_nonpayload_inline(r_xprt, rqst))
                wtype = rpcrdma_writech;
        else
                wtype = rpcrdma_replych;