Commit d896ba83 authored by Trond Myklebust's avatar Trond Myklebust
Browse files

SUNRPC: Fix races when closing the socket



Ensure that we bump the xprt->connect_cookie when we set the
XPRT_CLOSE_WAIT flag so that another call to
xprt_conditional_disconnect() won't race with the reconnection.

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 127becab
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -735,6 +735,8 @@ static void xprt_autoclose(struct work_struct *work)
	unsigned int pflags = memalloc_nofs_save();

	trace_xprt_disconnect_auto(xprt);
	xprt->connect_cookie++;
	smp_mb__before_atomic();
	clear_bit(XPRT_CLOSE_WAIT, &xprt->state);
	xprt->ops->close(xprt);
	xprt_release_write(xprt, NULL);
+1 −0
Original line number Diff line number Diff line
@@ -1134,6 +1134,7 @@ static void xs_run_error_worker(struct sock_xprt *transport, unsigned int nr)

static void xs_sock_reset_connection_flags(struct rpc_xprt *xprt)
{
	xprt->connect_cookie++;
	smp_mb__before_atomic();
	clear_bit(XPRT_CLOSE_WAIT, &xprt->state);
	clear_bit(XPRT_CLOSING, &xprt->state);