SUNRPC: Fix a race with XPRT_CONNECTING
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 17 Dec 2018 22:38:51 +0000 (17:38 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Tue, 18 Dec 2018 16:04:03 +0000 (11:04 -0500)
Ensure that we clear XPRT_CONNECTING before releasing the XPRT_LOCK so that
we don't have races between the (asynchronous) socket setup code and
tasks in xprt_connect().

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Tested-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/xprtsock.c

index 4c471b4235ba5585148ea7876778d34268229eaa..f0b3700cec95e8f0ccf9eac212b47158877066ab 100644 (file)
@@ -2090,8 +2090,8 @@ static void xs_udp_setup_socket(struct work_struct *work)
        trace_rpc_socket_connect(xprt, sock, 0);
        status = 0;
 out:
-       xprt_unlock_connect(xprt, transport);
        xprt_clear_connecting(xprt);
+       xprt_unlock_connect(xprt, transport);
        xprt_wake_pending_tasks(xprt, status);
 }
 
@@ -2327,8 +2327,8 @@ static void xs_tcp_setup_socket(struct work_struct *work)
        }
        status = -EAGAIN;
 out:
-       xprt_unlock_connect(xprt, transport);
        xprt_clear_connecting(xprt);
+       xprt_unlock_connect(xprt, transport);
        xprt_wake_pending_tasks(xprt, status);
 }