From: Stefan Metzmacher Date: Fri, 8 Aug 2025 16:48:14 +0000 (+0200) Subject: smb: client: use status_wait and SMBDIRECT_SOCKET_NEGOTIATE_RUNNING for completion X-Git-Tag: v6.18-rc1~225^2~133 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=00e4c7a87d1fa8d5668e2922578ff4aff6efb8a2;p=thirdparty%2Flinux.git 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 Cc: Tom Talpey Cc: Long Li Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Acked-by: Namjae Jeon Signed-off-by: Stefan Metzmacher Signed-off-by: Steve French --- diff --git a/fs/smb/client/smbdirect.c b/fs/smb/client/smbdirect.c index 09f8b12dd4f10..cfb45bc993766 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 4ca9b2b2c57f9..c9b0c6b61e7e5 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;