SUNRPC/xprtrdma: Fix reconnection locking
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 26 Jul 2021 12:03:12 +0000 (08:03 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:40:13 +0000 (13:40 +0200)
commitf19abe046354fb3c1578008c626b2e036a763f39
tree4e998ba83844afd9a1412ebbf3c7b5ba0aefc1b8
parentf3d30161278776fb0a4a163c05f44a55acc47f1b
SUNRPC/xprtrdma: Fix reconnection locking

[ Upstream commit f99fa50880f5300fbbb3c0754ddc7f8738d24fe7 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sunrpc/xprt.c
net/sunrpc/xprtrdma/transport.c