From: Stefan Metzmacher <metze@samba.org>
To: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org
Cc: metze@samba.org, Steve French <smfrench@gmail.com>,
Tom Talpey <tom@talpey.com>, Long Li <longli@microsoft.com>,
Steve French <stfrench@microsoft.com>
Subject: [PATCH v2 7/9] smb: client: use status_wait and SMBDIRECT_SOCKET_RESOLVE_{ADDR,ROUTE}_RUNNING for completion
Date: Fri, 8 Aug 2025 17:28:05 +0200 [thread overview]
Message-ID: <0e7f6c3f3ca208a86f86d55f76cf5f50af20fb5a.1754666549.git.metze@samba.org> (raw)
In-Reply-To: <cover.1754666549.git.metze@samba.org>
We can use the state change from
SMBDIRECT_SOCKET_RESOLVE_{ADDR,ROUTE}_RUNNING
to the next state in order to wake the caller to do the next step.
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
fs/smb/client/smbdirect.c | 49 ++++++++++++++++++++++-----------------
fs/smb/client/smbdirect.h | 2 --
2 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index 2057dae51e7b..6e0ef7ca8ab8 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -187,31 +187,27 @@ static int smbd_conn_upcall(
case RDMA_CM_EVENT_ADDR_RESOLVED:
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ADDR_RUNNING);
sc->status = SMBDIRECT_SOCKET_RESOLVE_ROUTE_NEEDED;
- info->ri_rc = 0;
- complete(&info->ri_done);
+ wake_up_interruptible(&info->status_wait);
break;
case RDMA_CM_EVENT_ROUTE_RESOLVED:
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ROUTE_RUNNING);
sc->status = SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED;
- info->ri_rc = 0;
- complete(&info->ri_done);
+ wake_up_interruptible(&info->status_wait);
break;
case RDMA_CM_EVENT_ADDR_ERROR:
log_rdma_event(ERR, "connecting failed event=%s\n", event_name);
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ADDR_RUNNING);
sc->status = SMBDIRECT_SOCKET_RESOLVE_ADDR_FAILED;
- info->ri_rc = -EHOSTUNREACH;
- complete(&info->ri_done);
+ wake_up_interruptible(&info->status_wait);
break;
case RDMA_CM_EVENT_ROUTE_ERROR:
log_rdma_event(ERR, "connecting failed event=%s\n", event_name);
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ROUTE_RUNNING);
sc->status = SMBDIRECT_SOCKET_RESOLVE_ROUTE_FAILED;
- info->ri_rc = -ENETUNREACH;
- complete(&info->ri_done);
+ wake_up_interruptible(&info->status_wait);
break;
case RDMA_CM_EVENT_ESTABLISHED:
@@ -597,9 +593,6 @@ static struct rdma_cm_id *smbd_create_id(
*sport = htons(port);
- init_completion(&info->ri_done);
- info->ri_rc = -ETIMEDOUT;
-
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ADDR_NEEDED);
sc->status = SMBDIRECT_SOCKET_RESOLVE_ADDR_RUNNING;
rc = rdma_resolve_addr(id, NULL, (struct sockaddr *)dstaddr,
@@ -608,20 +601,26 @@ static struct rdma_cm_id *smbd_create_id(
log_rdma_event(ERR, "rdma_resolve_addr() failed %i\n", rc);
goto out;
}
- rc = wait_for_completion_interruptible_timeout(
- &info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
+ rc = wait_event_interruptible_timeout(
+ info->status_wait,
+ sc->status != SMBDIRECT_SOCKET_RESOLVE_ADDR_RUNNING,
+ msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
/* e.g. if interrupted returns -ERESTARTSYS */
if (rc < 0) {
log_rdma_event(ERR, "rdma_resolve_addr timeout rc: %i\n", rc);
goto out;
}
- rc = info->ri_rc;
- if (rc) {
+ if (sc->status == SMBDIRECT_SOCKET_RESOLVE_ADDR_RUNNING) {
+ rc = -ETIMEDOUT;
+ log_rdma_event(ERR, "rdma_resolve_addr() completed %i\n", rc);
+ goto out;
+ }
+ if (sc->status != SMBDIRECT_SOCKET_RESOLVE_ROUTE_NEEDED) {
+ rc = -EHOSTUNREACH;
log_rdma_event(ERR, "rdma_resolve_addr() completed %i\n", rc);
goto out;
}
- info->ri_rc = -ETIMEDOUT;
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ROUTE_NEEDED);
sc->status = SMBDIRECT_SOCKET_RESOLVE_ROUTE_RUNNING;
rc = rdma_resolve_route(id, RDMA_RESOLVE_TIMEOUT);
@@ -629,15 +628,22 @@ static struct rdma_cm_id *smbd_create_id(
log_rdma_event(ERR, "rdma_resolve_route() failed %i\n", rc);
goto out;
}
- rc = wait_for_completion_interruptible_timeout(
- &info->ri_done, msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
+ rc = wait_event_interruptible_timeout(
+ info->status_wait,
+ sc->status != SMBDIRECT_SOCKET_RESOLVE_ROUTE_RUNNING,
+ msecs_to_jiffies(RDMA_RESOLVE_TIMEOUT));
/* e.g. if interrupted returns -ERESTARTSYS */
if (rc < 0) {
log_rdma_event(ERR, "rdma_resolve_addr timeout rc: %i\n", rc);
goto out;
}
- rc = info->ri_rc;
- if (rc) {
+ if (sc->status == SMBDIRECT_SOCKET_RESOLVE_ROUTE_RUNNING) {
+ rc = -ETIMEDOUT;
+ log_rdma_event(ERR, "rdma_resolve_route() completed %i\n", rc);
+ goto out;
+ }
+ if (sc->status != SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED) {
+ rc = -ENETUNREACH;
log_rdma_event(ERR, "rdma_resolve_route() completed %i\n", rc);
goto out;
}
@@ -1572,6 +1578,8 @@ static struct smbd_connection *_smbd_get_connection(
sc = &info->socket;
sp = &sc->parameters;
+ init_waitqueue_head(&info->status_wait);
+
sc->status = SMBDIRECT_SOCKET_CREATED;
rc = smbd_ia_open(info, dstaddr, port);
if (rc) {
@@ -1682,7 +1690,6 @@ static struct smbd_connection *_smbd_get_connection(
log_rdma_event(INFO, "connecting to IP %pI4 port %d\n",
&addr_in->sin_addr, port);
- init_waitqueue_head(&info->status_wait);
init_waitqueue_head(&sc->recv_io.reassembly.wait_queue);
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED);
diff --git a/fs/smb/client/smbdirect.h b/fs/smb/client/smbdirect.h
index 82505df4a751..62458a8fd109 100644
--- a/fs/smb/client/smbdirect.h
+++ b/fs/smb/client/smbdirect.h
@@ -45,8 +45,6 @@ enum keep_alive_status {
struct smbd_connection {
struct smbdirect_socket socket;
- int ri_rc;
- struct completion ri_done;
wait_queue_head_t status_wait;
struct work_struct disconnect_work;
--
2.43.0
next prev parent reply other threads:[~2025-08-08 15:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 15:27 [PATCH v2 0/9] smb: client/smbdirect: connect bug fixes/cleanups and smbdirect_socket.status_wait Stefan Metzmacher
2025-08-08 15:27 ` [PATCH v2 1/9] smb: client: return an error if rdma_connect does not return within 5 seconds Stefan Metzmacher
2025-08-08 15:28 ` [PATCH v2 2/9] smb: client: improve logging in smbd_conn_upcall() Stefan Metzmacher
2025-08-08 15:28 ` [PATCH v2 3/9] smb: client: don't call init_waitqueue_head(&info->conn_wait) twice in _smbd_get_connection Stefan Metzmacher
2025-08-08 15:28 ` [PATCH v2 4/9] smb: client: only use a single wait_queue to monitor smbdirect connection status Stefan Metzmacher
2025-08-08 15:28 ` [PATCH v2 5/9] smb: client/smbdirect: replace SMBDIRECT_SOCKET_CONNECTING with more detailed states Stefan Metzmacher
2025-08-08 15:28 ` [PATCH v2 6/9] smb: client: use status_wait and SMBDIRECT_SOCKET_NEGOTIATE_RUNNING for completion Stefan Metzmacher
2025-08-08 15:28 ` Stefan Metzmacher [this message]
2025-08-08 15:28 ` [PATCH v2 8/9] smb: smbdirect: introduce smbdirect_socket.status_wait Stefan Metzmacher
2025-08-08 15:28 ` [PATCH v2 9/9] smb: client: make use of smbdirect_socket.status_wait Stefan Metzmacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0e7f6c3f3ca208a86f86d55f76cf5f50af20fb5a.1754666549.git.metze@samba.org \
--to=metze@samba.org \
--cc=linux-cifs@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=samba-technical@lists.samba.org \
--cc=smfrench@gmail.com \
--cc=stfrench@microsoft.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).