summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2025-08-08 18:48:14 +0200
committerSteve French <stfrench@microsoft.com>2025-09-28 18:29:48 -0500
commit00e4c7a87d1fa8d5668e2922578ff4aff6efb8a2 (patch)
tree40f2f6205a3bd8975fffdb6e3b81ca516558819e
parentafff34dc025b5f0476645f44b4d9cbc83dd54e71 (diff)
downloadlinux-00e4c7a87d1fa8d5668e2922578ff4aff6efb8a2.tar.gz
linux-00e4c7a87d1fa8d5668e2922578ff4aff6efb8a2.zip
smb: client: use status_wait and SMBDIRECT_SOCKET_NEGOTIATE_RUNNING for completion
We can use the state change from SMBDIRECT_SOCKET_NEGOTIATE_RUNNING to SMBDIRECT_SOCKET_CONNECTED or SMBDIRECT_SOCKET_NEGOTIATE_FAILED in order to notify the caller if the negotiation is over. 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 Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r--fs/smb/client/smbdirect.c19
-rw-r--r--fs/smb/client/smbdirect.h3
2 files changed, 10 insertions, 12 deletions
diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c
index 09f8b12dd4f1..cfb45bc99376 100644
--- a/fs/smb/client/smbdirect.c
+++ b/fs/smb/client/smbdirect.c
@@ -582,6 +582,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
u32 data_offset = 0;
u32 data_length = 0;
u32 remaining_data_length = 0;
+ bool negotiate_done = false;
log_rdma_recv(INFO, "response=0x%p type=%d wc status=%d wc opcode %d byte_len=%d pkey_index=%u\n",
response, sc->recv_io.expected, wc->status, wc->opcode,
@@ -604,16 +605,16 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
case SMBDIRECT_EXPECT_NEGOTIATE_REP:
dump_smbdirect_negotiate_resp(smbdirect_recv_io_payload(response));
sc->recv_io.reassembly.full_packet_received = true;
- info->negotiate_done =
+ negotiate_done =
process_negotiation_response(response, wc->byte_len);
put_receive_buffer(info, response);
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_NEGOTIATE_RUNNING);
- if (!info->negotiate_done)
+ if (!negotiate_done)
sc->status = SMBDIRECT_SOCKET_NEGOTIATE_FAILED;
else
sc->status = SMBDIRECT_SOCKET_CONNECTED;
- complete(&info->negotiate_completion);
+ wake_up_interruptible(&info->status_wait);
return;
/* SMBD data transfer packet */
@@ -1253,17 +1254,17 @@ static int smbd_negotiate(struct smbd_connection *info)
return rc;
}
- init_completion(&info->negotiate_completion);
- info->negotiate_done = false;
rc = smbd_post_send_negotiate_req(info);
if (rc)
return rc;
- rc = wait_for_completion_interruptible_timeout(
- &info->negotiate_completion, SMBD_NEGOTIATE_TIMEOUT * HZ);
- log_rdma_event(INFO, "wait_for_completion_timeout rc=%d\n", rc);
+ rc = wait_event_interruptible_timeout(
+ info->status_wait,
+ sc->status != SMBDIRECT_SOCKET_NEGOTIATE_RUNNING,
+ secs_to_jiffies(SMBD_NEGOTIATE_TIMEOUT));
+ log_rdma_event(INFO, "wait_event_interruptible_timeout rc=%d\n", rc);
- if (info->negotiate_done)
+ if (sc->status == SMBDIRECT_SOCKET_CONNECTED)
return 0;
if (rc == 0)
diff --git a/fs/smb/client/smbdirect.h b/fs/smb/client/smbdirect.h
index 4ca9b2b2c57f..c9b0c6b61e7e 100644
--- a/fs/smb/client/smbdirect.h
+++ b/fs/smb/client/smbdirect.h
@@ -49,9 +49,6 @@ struct smbd_connection {
struct completion ri_done;
wait_queue_head_t status_wait;
- struct completion negotiate_completion;
- bool negotiate_done;
-
struct work_struct disconnect_work;
struct work_struct post_send_credits_work;