SUNRPC/xprtrdma: Fix reconnection locking
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 26 Jul 2021 12:03:12 +0000 (08:03 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Mon, 9 Aug 2021 20:57:05 +0000 (16:57 -0400)
commitf99fa50880f5300fbbb3c0754ddc7f8738d24fe7
treea47e6a99e45c86f1d44bea9f7bad4ed7ece9ba00
parente26d9972720e2484f44cdd94ca4e31cc372ed2ed
SUNRPC/xprtrdma: Fix reconnection locking

The xprtrdma client code currently relies on the task that initiated the
connect to hold the XPRT_LOCK for the duration of the connection
attempt. If the task is woken early, due to some other event, then that
lock could get released early.
Avoid races by using the same mechanism that the socket code uses of
transferring lock ownership to the RDMA connect worker itself. That
frees us to call rpcrdma_xprt_disconnect() directly since we're now
guaranteed exclusion w.r.t. other callers.

Fixes: 4cf44be6f1e8 ("xprtrdma: Fix recursion into rpcrdma_xprt_disconnect()")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprt.c
net/sunrpc/xprtrdma/transport.c