svcrdma: Properly compute .len and .buflen for received RPC Calls
authorChuck Lever <chuck.lever@oracle.com>
Fri, 23 Jun 2017 21:18:41 +0000 (17:18 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Wed, 12 Jul 2017 19:54:57 +0000 (15:54 -0400)
commit71641d99ce037ea226f94d5e08f2a8f71eba08f4
tree0e10fdc4fb7f6b2988837dd74a871dd0253389c3
parentcafc739892f34b9090413179ca259409fc43bfae
svcrdma: Properly compute .len and .buflen for received RPC Calls

When an RPC-over-RDMA request is received, the Receive buffer
contains a Transport Header possibly followed by an RPC message.

Even though rq_arg.head[0] (as passed to NFSD) does not contain the
Transport Header header, currently rq_arg.len includes the size of
the Transport Header.

That violates the intent of the xdr_buf API contract. .buflen should
include everything, but .len should be exactly the length of the RPC
message in the buffer.

The rq_arg fields are summed together at the end of
svc_rdma_recvfrom to obtain the correct return value. rq_arg.len
really ought to contain the correct number of bytes already, but it
currently doesn't due to the above misbehavior.

Let's instead ensure that .buflen includes the length of the
transport header, and that .len is always equal to head.iov_len +
.page_len + tail.iov_len .

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
net/sunrpc/xprtrdma/svc_rdma_rw.c