NFSoRDMA Client Fixes for Linux 5.7

Bugfixes:
 - Restore wake-up-all to rpcrdma_cm_event_handler()
   - Otherwise the client won't respond to server disconnect requests
 - Fix tracepoint use-after-free race
 - Fix usage of xdr_stream_encode_item_{present, absent}
   - These functions return a size on success, and not 0
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEnZ5MQTpR7cLU7KEp18tUv7ClQOsFAl6jVawACgkQ18tUv7Cl
 QOvklhAAmg0MImljNfQ6FmMHQokxtLlOuw7P8HQsARrwxO+cJjSx1vriCI0EyE+T
 yB386Bd+tGUurDZf6k+TjctQlVNSfz7Pv2gJTj/rQEvZFM2AopOBjbovKnNOnOTj
 aPnNOkshZzxZk9JYh9RN3zmyZHtlldimnvLloUrO3nZ63iUGuF1nBkQ9TWuG/CSz
 XuE1bUJgsJkdG07+I1yLrn9MAOdgzuJB2TJ5hL2GjN0BIrJ3jzweXVYXrLFikZUD
 vRTyf1K/zcDOVKPn/Aw4NSPNeTBlsP0Ain9zY7C2cuEXasu1gbEXYmmq/qvrF6kt
 N9TIDqqDZgDRA4Z3nfCJZOXyNwZ3nyEx0+S+8lK58w6khXRYiD21bxrA1eSB3aIS
 LzqJIoto/2/cl8DjNbuyvB7znjlthxYPcOo6cCeJOQ7jPWi6IDDZ6t9mwnXhSU3C
 +GdUyulWJPfx9hj6HlDbrXy6ESlCIFYobHGKVqYu7ZvaIxVVSdlfAIR64PsD7edX
 m3NzNcH1PJNKmTFvyyQDuMgwxauVLaAAs2A0Vvnzt8Vq8uSxEiySVUXOjH4+DnNm
 NNfDXGq7yQj9NqAsqlCe+zkcBT7Wy7ds+y05tipWD92Lu2mvOE+3Lht5H5GnIyWl
 1Lq/eUmrBBlxYRK0ir/RRI3aBYvuO4AK/g81ZzGQZAiWAL319MI=
 =jre3
 -----END PGP SIGNATURE-----

Merge tag 'nfs-rdma-for-5.7-2' of git://git.linux-nfs.org/projects/anna/linux-nfs

NFSoRDMA Client Fixes for Linux 5.7

Bugfixes:
- Restore wake-up-all to rpcrdma_cm_event_handler()
  - Otherwise the client won't respond to server disconnect requests
- Fix tracepoint use-after-free race
- Fix usage of xdr_stream_encode_item_{present, absent}
  - These functions return a size on success, and not 0

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
Trond Myklebust 2020-04-28 15:59:03 -04:00
commit 8e2912c7c6
3 changed files with 17 additions and 13 deletions

View File

@ -692,11 +692,10 @@ TRACE_EVENT(xprtrdma_prepsend_failed,
TRACE_EVENT(xprtrdma_post_send, TRACE_EVENT(xprtrdma_post_send,
TP_PROTO( TP_PROTO(
const struct rpcrdma_req *req, const struct rpcrdma_req *req
int status
), ),
TP_ARGS(req, status), TP_ARGS(req),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(const void *, req) __field(const void *, req)
@ -705,7 +704,6 @@ TRACE_EVENT(xprtrdma_post_send,
__field(unsigned int, client_id) __field(unsigned int, client_id)
__field(int, num_sge) __field(int, num_sge)
__field(int, signaled) __field(int, signaled)
__field(int, status)
), ),
TP_fast_assign( TP_fast_assign(
@ -718,15 +716,13 @@ TRACE_EVENT(xprtrdma_post_send,
__entry->sc = req->rl_sendctx; __entry->sc = req->rl_sendctx;
__entry->num_sge = req->rl_wr.num_sge; __entry->num_sge = req->rl_wr.num_sge;
__entry->signaled = req->rl_wr.send_flags & IB_SEND_SIGNALED; __entry->signaled = req->rl_wr.send_flags & IB_SEND_SIGNALED;
__entry->status = status;
), ),
TP_printk("task:%u@%u req=%p sc=%p (%d SGE%s) %sstatus=%d", TP_printk("task:%u@%u req=%p sc=%p (%d SGE%s) %s",
__entry->task_id, __entry->client_id, __entry->task_id, __entry->client_id,
__entry->req, __entry->sc, __entry->num_sge, __entry->req, __entry->sc, __entry->num_sge,
(__entry->num_sge == 1 ? "" : "s"), (__entry->num_sge == 1 ? "" : "s"),
(__entry->signaled ? "signaled " : ""), (__entry->signaled ? "signaled" : "")
__entry->status
) )
); );

View File

@ -388,7 +388,9 @@ static int rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt,
} while (nsegs); } while (nsegs);
done: done:
return xdr_stream_encode_item_absent(xdr); if (xdr_stream_encode_item_absent(xdr) < 0)
return -EMSGSIZE;
return 0;
} }
/* Register and XDR encode the Write list. Supports encoding a list /* Register and XDR encode the Write list. Supports encoding a list
@ -454,7 +456,9 @@ static int rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt,
*segcount = cpu_to_be32(nchunks); *segcount = cpu_to_be32(nchunks);
done: done:
return xdr_stream_encode_item_absent(xdr); if (xdr_stream_encode_item_absent(xdr) < 0)
return -EMSGSIZE;
return 0;
} }
/* Register and XDR encode the Reply chunk. Supports encoding an array /* Register and XDR encode the Reply chunk. Supports encoding an array
@ -480,8 +484,11 @@ static int rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt,
int nsegs, nchunks; int nsegs, nchunks;
__be32 *segcount; __be32 *segcount;
if (wtype != rpcrdma_replych) if (wtype != rpcrdma_replych) {
return xdr_stream_encode_item_absent(xdr); if (xdr_stream_encode_item_absent(xdr) < 0)
return -EMSGSIZE;
return 0;
}
seg = req->rl_segments; seg = req->rl_segments;
nsegs = rpcrdma_convert_iovs(r_xprt, &rqst->rq_rcv_buf, 0, wtype, seg); nsegs = rpcrdma_convert_iovs(r_xprt, &rqst->rq_rcv_buf, 0, wtype, seg);

View File

@ -289,6 +289,7 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
case RDMA_CM_EVENT_DISCONNECTED: case RDMA_CM_EVENT_DISCONNECTED:
ep->re_connect_status = -ECONNABORTED; ep->re_connect_status = -ECONNABORTED;
disconnected: disconnected:
xprt_force_disconnect(xprt);
return rpcrdma_ep_destroy(ep); return rpcrdma_ep_destroy(ep);
default: default:
break; break;
@ -1355,8 +1356,8 @@ int rpcrdma_post_sends(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
--ep->re_send_count; --ep->re_send_count;
} }
trace_xprtrdma_post_send(req);
rc = frwr_send(r_xprt, req); rc = frwr_send(r_xprt, req);
trace_xprtrdma_post_send(req, rc);
if (rc) if (rc)
return -ENOTCONN; return -ENOTCONN;
return 0; return 0;