]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: make use of smbdirect_socket.send_io.pending.{count,{dec,zero}_wait_queue}
authorStefan Metzmacher <metze@samba.org>
Mon, 11 Aug 2025 13:19:51 +0000 (15:19 +0200)
committerSteve French <stfrench@microsoft.com>
Sun, 28 Sep 2025 23:29:48 +0000 (18:29 -0500)
This will be used by the server too and will allow to create
common helper functions.

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/cifs_debug.c
fs/smb/client/smbdirect.c
fs/smb/client/smbdirect.h

index 265e063e95bd06e8cf8a5784064e340e99486e15..d48438e6efdb7963528c0497ca44b661adbf2e78 100644 (file)
@@ -497,7 +497,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
                        atomic_read(&server->smbd_conn->receive_credits),
                        server->smbd_conn->receive_credit_target);
                seq_printf(m, "\nPending send_pending: %u ",
-                       atomic_read(&server->smbd_conn->send_pending));
+                       atomic_read(&sc->send_io.pending.count));
                seq_printf(m, "\nReceive buffers count_receive_queue: %u ",
                        server->smbd_conn->count_receive_queue);
                seq_printf(m, "\nMR responder_resources: %u "
index 89375f3bd30a08526e489c9612322ce984173ff9..947fd301c70bb1678862e034fde5530e457a67be 100644 (file)
@@ -418,10 +418,10 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc)
                return;
        }
 
-       if (atomic_dec_and_test(&info->send_pending))
-               wake_up(&info->wait_send_pending);
+       if (atomic_dec_and_test(&sc->send_io.pending.count))
+               wake_up(&sc->send_io.pending.zero_wait_queue);
 
-       wake_up(&info->wait_post_send);
+       wake_up(&sc->send_io.pending.dec_wait_queue);
 
        mempool_free(request, sc->send_io.mem.pool);
 }
@@ -908,14 +908,14 @@ static int smbd_post_send_negotiate_req(struct smbd_connection *info)
                request->sge[0].addr,
                request->sge[0].length, request->sge[0].lkey);
 
-       atomic_inc(&info->send_pending);
+       atomic_inc(&sc->send_io.pending.count);
        rc = ib_post_send(sc->ib.qp, &send_wr, NULL);
        if (!rc)
                return 0;
 
        /* if we reach here, post send failed */
        log_rdma_send(ERR, "ib_post_send failed rc=%d\n", rc);
-       atomic_dec(&info->send_pending);
+       atomic_dec(&sc->send_io.pending.count);
        ib_dma_unmap_single(sc->ib.dev, request->sge[0].addr,
                request->sge[0].length, DMA_TO_DEVICE);
 
@@ -1038,8 +1038,8 @@ wait_credit:
        }
 
 wait_send_queue:
-       wait_event(info->wait_post_send,
-               atomic_read(&info->send_pending) < sp->send_credit_target ||
+       wait_event(sc->send_io.pending.dec_wait_queue,
+               atomic_read(&sc->send_io.pending.count) < sp->send_credit_target ||
                sc->status != SMBDIRECT_SOCKET_CONNECTED);
 
        if (sc->status != SMBDIRECT_SOCKET_CONNECTED) {
@@ -1048,9 +1048,9 @@ wait_send_queue:
                goto err_wait_send_queue;
        }
 
-       if (unlikely(atomic_inc_return(&info->send_pending) >
+       if (unlikely(atomic_inc_return(&sc->send_io.pending.count) >
                                sp->send_credit_target)) {
-               atomic_dec(&info->send_pending);
+               atomic_dec(&sc->send_io.pending.count);
                goto wait_send_queue;
        }
 
@@ -1157,8 +1157,8 @@ err_dma:
        atomic_sub(new_credits, &info->receive_credits);
 
 err_alloc:
-       if (atomic_dec_and_test(&info->send_pending))
-               wake_up(&info->wait_send_pending);
+       if (atomic_dec_and_test(&sc->send_io.pending.count))
+               wake_up(&sc->send_io.pending.zero_wait_queue);
 
 err_wait_send_queue:
        /* roll back send credits and pending */
@@ -1848,11 +1848,6 @@ static struct smbd_connection *_smbd_get_connection(
        queue_delayed_work(info->workqueue, &info->idle_timer_work,
                msecs_to_jiffies(sp->keepalive_interval_msec));
 
-       init_waitqueue_head(&info->wait_send_pending);
-       atomic_set(&info->send_pending, 0);
-
-       init_waitqueue_head(&info->wait_post_send);
-
        INIT_WORK(&info->post_send_credits_work, smbd_post_send_credits);
        info->new_credits_offered = 0;
        spin_lock_init(&info->lock_new_credits_offered);
@@ -2151,8 +2146,8 @@ int smbd_send(struct TCP_Server_Info *server,
         * that means all the I/Os have been out and we are good to return
         */
 
-       wait_event(info->wait_send_pending,
-               atomic_read(&info->send_pending) == 0 ||
+       wait_event(sc->send_io.pending.zero_wait_queue,
+               atomic_read(&sc->send_io.pending.count) == 0 ||
                sc->status != SMBDIRECT_SOCKET_CONNECTED);
 
        if (sc->status != SMBDIRECT_SOCKET_CONNECTED && rc == 0)
index 1c63188664df95c3a80f6513ae163dd6434f2b42..2ce6b7ab898a3804de1360b691e2a4469afc672e 100644 (file)
@@ -82,11 +82,6 @@ struct smbd_connection {
        /* Used by transport to wait until all MRs are returned */
        wait_queue_head_t wait_for_mr_cleanup;
 
-       /* Activity accounting */
-       atomic_t send_pending;
-       wait_queue_head_t wait_send_pending;
-       wait_queue_head_t wait_post_send;
-
        /* Receive queue */
        int count_receive_queue;
        wait_queue_head_t wait_receive_queues;