History

SUNRPC: Fix NFSD's request deferral on RDMA transports

Trond Myklebust reports an NFSD crash in svc_rdma_sendto(). Further investigation shows that the crash occurred while NFSD was handling a deferred request. This patch addresses two inter-related issues that prevent request deferral from working correctly for RPC/RDMA requests: 1. Prevent the crash by ensuring that the original svc_rqst::rq_xprt_ctxt value is available when the request is revisited. Otherwise svc_rdma_sendto() does not have a Receive context available with which to construct its reply. 2. Possibly since before commit 71641d99ce03 ("svcrdma: Properly compute .len and .buflen for received RPC Calls"), svc_rdma_recvfrom() did not include the transport header in the returned xdr_buf. There should have been no need for svc_defer() and friends to save and restore that header, as of that commit. This issue is addressed in a backport-friendly way by simply having svc_rdma_recvfrom() set rq_xprt_hlen to zero unconditionally, just as svc_tcp_recvfrom() does. This enables svc_deferred_recv() to correctly reconstruct an RPC message received via RPC/RDMA.

Chuck Lever committed 4 years ago

Commit 773f91b1 parent 99939793 files · +5 −1Browse files

Unified · Split

3 files
  1. include/linux/sunrpc/svc.h +1 −0
  2. net/sunrpc/svc_xprt.c +3 −0
  3. net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +1 −1
include/linux/sunrpc/svc.h+1−0
@@ -395,6 +395,7 @@ struct svc_deferred_req { · 394 unmodified lines
395 size_t addrlen;395 size_t addrlen;
396 struct sockaddr_storage daddr; /* where reply must come from */396 struct sockaddr_storage daddr; /* where reply must come from */
397 size_t daddrlen;397 size_t daddrlen;
398 void *xprt_ctxt;
398 struct cache_deferred_req handle;399 struct cache_deferred_req handle;
399 size_t xprt_hlen;400 size_t xprt_hlen;
400 int argslen;401 int argslen;
net/sunrpc/svc_xprt.c+3−0
@@ -1231,6 +1231,8 @@ static struct cache_deferred_req *svc_defer(struct cache_req *req) · 1230 unmodified lines
1231 dr->daddr = rqstp->rq_daddr;1231 dr->daddr = rqstp->rq_daddr;
1232 dr->argslen = rqstp->rq_arg.len >> 2;1232 dr->argslen = rqstp->rq_arg.len >> 2;
1233 dr->xprt_hlen = rqstp->rq_xprt_hlen;1233 dr->xprt_hlen = rqstp->rq_xprt_hlen;
1234 dr->xprt_ctxt = rqstp->rq_xprt_ctxt;
1235 rqstp->rq_xprt_ctxt = NULL;
1234 1236
1235 /* back up head to the start of the buffer and copy */1237 /* back up head to the start of the buffer and copy */
1236 skip = rqstp->rq_arg.len - rqstp->rq_arg.head[0].iov_len;1238 skip = rqstp->rq_arg.len - rqstp->rq_arg.head[0].iov_len;
@@ -1269,6 +1271,7 @@ static noinline int svc_deferred_recv(struct svc_rqst *rqstp) · 32 unmodified lines
1269 rqstp->rq_xprt_hlen = dr->xprt_hlen;1271 rqstp->rq_xprt_hlen = dr->xprt_hlen;
1270 rqstp->rq_daddr = dr->daddr;1272 rqstp->rq_daddr = dr->daddr;
1271 rqstp->rq_respages = rqstp->rq_pages;1273 rqstp->rq_respages = rqstp->rq_pages;
1274 rqstp->rq_xprt_ctxt = dr->xprt_ctxt;
1272 svc_xprt_received(rqstp->rq_xprt);1275 svc_xprt_received(rqstp->rq_xprt);
1273 return (dr->argslen<<2) - dr->xprt_hlen;1276 return (dr->argslen<<2) - dr->xprt_hlen;
1274}1277}
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c+1−1
@@ -831,7 +831,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp) · 830 unmodified lines
831 goto out_err;831 goto out_err;
832 if (ret == 0)832 if (ret == 0)
833 goto out_drop;833 goto out_drop;
834 rqstp->rq_xprt_hlen = ret;834 rqstp->rq_xprt_hlen = 0;
835 835
836 if (svc_rdma_is_reverse_direction_reply(xprt, ctxt))836 if (svc_rdma_is_reverse_direction_reply(xprt, ctxt))
837 goto out_backchannel;837 goto out_backchannel;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t