]> git.dujemihanovic.xyz Git - linux.git/commitdiff
xprtrdma: Prevent leak of rpcrdma_rep objects
authorChuck Lever <chuck.lever@oracle.com>
Fri, 7 Dec 2018 16:11:44 +0000 (11:11 -0500)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Wed, 2 Jan 2019 17:05:19 +0000 (12:05 -0500)
If a reply has been processed but the RPC is later retransmitted
anyway, the req->rl_reply field still contains the only pointer to
the old rpcrdma rep. When the next reply comes in, the reply handler
will stomp on the rl_reply field, leaking the old rep.

A trace event is added to capture such leaks.

This problem seems to be worsened by the restructuring of the RPC
Call path in v4.20. Fully addressing this issue will require at
least a re-architecture of the disconnect logic, which is not
appropriate during -rc.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
include/trace/events/rpcrdma.h
net/sunrpc/xprtrdma/rpc_rdma.c

index ce528d5942c5c6db3b37d684c531d606f555d099..399b1aedc927a2786a429d74f044be7fe7af2c6f 100644 (file)
@@ -1065,6 +1065,34 @@ TRACE_EVENT(xprtrdma_cb_setup,
 DEFINE_CB_EVENT(xprtrdma_cb_call);
 DEFINE_CB_EVENT(xprtrdma_cb_reply);
 
+TRACE_EVENT(xprtrdma_leaked_rep,
+       TP_PROTO(
+               const struct rpc_rqst *rqst,
+               const struct rpcrdma_rep *rep
+       ),
+
+       TP_ARGS(rqst, rep),
+
+       TP_STRUCT__entry(
+               __field(unsigned int, task_id)
+               __field(unsigned int, client_id)
+               __field(u32, xid)
+               __field(const void *, rep)
+       ),
+
+       TP_fast_assign(
+               __entry->task_id = rqst->rq_task->tk_pid;
+               __entry->client_id = rqst->rq_task->tk_client->cl_clid;
+               __entry->xid = be32_to_cpu(rqst->rq_xid);
+               __entry->rep = rep;
+       ),
+
+       TP_printk("task:%u@%u xid=0x%08x rep=%p",
+               __entry->task_id, __entry->client_id, __entry->xid,
+               __entry->rep
+       )
+);
+
 /**
  ** Server-side RPC/RDMA events
  **/
index 062aee97b070607038b381db9d5d79f9a329a327..d18614e02b4e8d5e31e00795397b64cc7bfc0463 100644 (file)
@@ -1350,6 +1350,10 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep)
        }
 
        req = rpcr_to_rdmar(rqst);
+       if (req->rl_reply) {
+               trace_xprtrdma_leaked_rep(rqst, req->rl_reply);
+               rpcrdma_recv_buffer_put(req->rl_reply);
+       }
        req->rl_reply = rep;
        rep->rr_rqst = rqst;
        clear_bit(RPCRDMA_REQ_F_PENDING, &req->rl_flags);