]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: use status_wait and SMBDIRECT_SOCKET_NEGOTIATE_RUNNING for completion
authorStefan Metzmacher <metze@samba.org>
Fri, 8 Aug 2025 16:48:14 +0000 (18:48 +0200)
committerSteve French <stfrench@microsoft.com>
Sun, 28 Sep 2025 23:29:48 +0000 (18:29 -0500)
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>
fs/smb/client/smbdirect.c
fs/smb/client/smbdirect.h

index 09f8b12dd4f10932caf4eb87defd1c17d0620593..cfb45bc9937666b4eb2204bacab5ca363919863a 100644 (file)
@@ -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)
index 4ca9b2b2c57f936d72f37001ed2ccd1b3db3e26e..c9b0c6b61e7e5cfd49545edb6d16b911840a1e9c 100644 (file)
@@ -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;