linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] SUNRPC: Don't leak sockets in xs_local_connect()
@ 2022-04-29 17:36 trondmy
  2022-04-29 17:36 ` [PATCH v2 2/4] SUNRPC: Ensure timely close of disconnected AF_LOCAL sockets trondmy
  0 siblings, 1 reply; 9+ messages in thread
From: trondmy @ 2022-04-29 17:36 UTC (permalink / raw)
  To: wanghai (M); +Cc: J. Bruce Fields, Chuck Lever, linux-nfs

From: Trond Myklebust <trond.myklebust@hammerspace.com>

If there is still a closed socket associated with the transport, then we
need to trigger an autoclose before we can set up a new connection.

Reported-by: wanghai (M) <wanghai38@huawei.com>
Fixes: f00432063db1 ("SUNRPC: Ensure we flush any closed sockets before xs_xprt_free()")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 net/sunrpc/xprtsock.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 8ab64ea46870..f9849b297ea3 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1950,6 +1950,9 @@ static void xs_local_connect(struct rpc_xprt *xprt, struct rpc_task *task)
 	struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
 	int ret;
 
+	if (transport->file)
+		goto force_disconnect;
+
 	if (RPC_IS_ASYNC(task)) {
 		/*
 		 * We want the AF_LOCAL connect to be resolved in the
@@ -1962,11 +1965,17 @@ static void xs_local_connect(struct rpc_xprt *xprt, struct rpc_task *task)
 		 */
 		task->tk_rpc_status = -ENOTCONN;
 		rpc_exit(task, -ENOTCONN);
-		return;
+		goto out_wake;
 	}
 	ret = xs_local_setup_socket(transport);
 	if (ret && !RPC_IS_SOFTCONN(task))
 		msleep_interruptible(15000);
+	return;
+force_disconnect:
+	xprt_force_disconnect(xprt);
+out_wake:
+	xprt_clear_connecting(xprt);
+	xprt_wake_pending_tasks(xprt, -ENOTCONN);
 }
 
 #if IS_ENABLED(CONFIG_SUNRPC_SWAP)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-05-09 11:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-29 17:36 [PATCH v2 1/4] SUNRPC: Don't leak sockets in xs_local_connect() trondmy
2022-04-29 17:36 ` [PATCH v2 2/4] SUNRPC: Ensure timely close of disconnected AF_LOCAL sockets trondmy
2022-04-29 17:36   ` [PATCH v2 3/4] SUNRPC: Ensure gss-proxy connects on setup trondmy
2022-04-29 17:36     ` [PATCH v2 4/4] Revert "SUNRPC: attempt AF_LOCAL connect on setup" trondmy
2022-04-30  0:56       ` Trond Myklebust
2022-05-05  9:19         ` wanghai (M)
2022-05-05 14:54         ` wanghai (M)
2022-05-09 10:28     ` [PATCH v2 3/4] SUNRPC: Ensure gss-proxy connects on setup wanghai (M)
2022-05-09 11:22       ` wanghai (M)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).