summaryrefslogtreecommitdiff
path: root/net/sunrpc/xprt.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2021-10-29 19:26:17 +0300
committerTrond Myklebust <trond.myklebust@hammerspace.com>2021-11-05 02:46:19 +0300
commitd896ba8300ebd09e5fc9c43051d9eb36b65e996e (patch)
tree7ca16fb82801fa28a737440a3a2985a532090125 /net/sunrpc/xprt.c
parent127becabad7bef13b2e2ab795953cf8e9cce8aab (diff)
downloadlinux-d896ba8300ebd09e5fc9c43051d9eb36b65e996e.tar.xz
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 <trond.myklebust@hammerspace.com>
Diffstat (limited to 'net/sunrpc/xprt.c')
-rw-r--r--net/sunrpc/xprt.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 48560188e84d..691fe5a682b6 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -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);