Skip to content

Commit d896ba8

Browse files
author
Trond Myklebust
committed
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: Trond Myklebust <[email protected]>
1 parent 127beca commit d896ba8

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

net/sunrpc/xprt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ static void xprt_autoclose(struct work_struct *work)
735735
unsigned int pflags = memalloc_nofs_save();
736736

737737
trace_xprt_disconnect_auto(xprt);
738+
xprt->connect_cookie++;
739+
smp_mb__before_atomic();
738740
clear_bit(XPRT_CLOSE_WAIT, &xprt->state);
739741
xprt->ops->close(xprt);
740742
xprt_release_write(xprt, NULL);

net/sunrpc/xprtsock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,7 @@ static void xs_run_error_worker(struct sock_xprt *transport, unsigned int nr)
11341134

11351135
static void xs_sock_reset_connection_flags(struct rpc_xprt *xprt)
11361136
{
1137+
xprt->connect_cookie++;
11371138
smp_mb__before_atomic();
11381139
clear_bit(XPRT_CLOSE_WAIT, &xprt->state);
11391140
clear_bit(XPRT_CLOSING, &xprt->state);

0 commit comments

Comments
 (0)