]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: make use of smbdirect_socket.send_io.credits.{count,wait_queue}
authorStefan Metzmacher <metze@samba.org>
Mon, 11 Aug 2025 15:11:08 +0000 (17:11 +0200)
committerSteve French <stfrench@microsoft.com>
Sun, 28 Sep 2025 23:29:49 +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 d48438e6efdb7963528c0497ca44b661adbf2e78..01a582e172cbf923a600cddb155bb6f6502f936e 100644 (file)
@@ -493,7 +493,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
                        sc->recv_io.reassembly.queue_length);
                seq_printf(m, "\nCurrent Credits send_credits: %u "
                        "receive_credits: %u receive_credit_target: %u",
-                       atomic_read(&server->smbd_conn->send_credits),
+                       atomic_read(&sc->send_io.credits.count),
                        atomic_read(&server->smbd_conn->receive_credits),
                        server->smbd_conn->receive_credit_target);
                seq_printf(m, "\nPending send_pending: %u ",
index 947fd301c70bb1678862e034fde5530e457a67be..a4508f8b7499cc0d6f29f60cfd1e3a239a55af8f 100644 (file)
@@ -349,7 +349,7 @@ static int smbd_conn_upcall(
                sc->status = SMBDIRECT_SOCKET_DISCONNECTED;
                wake_up_all(&sc->status_wait);
                wake_up_all(&sc->recv_io.reassembly.wait_queue);
-               wake_up_all(&info->wait_send_queue);
+               wake_up_all(&sc->send_io.credits.wait_queue);
                break;
 
        default:
@@ -473,7 +473,7 @@ static bool process_negotiation_response(
                log_rdma_event(ERR, "error: credits_granted==0\n");
                return false;
        }
-       atomic_set(&info->send_credits, le16_to_cpu(packet->credits_granted));
+       atomic_set(&sc->send_io.credits.count, le16_to_cpu(packet->credits_granted));
 
        atomic_set(&info->receive_credits, 0);
 
@@ -651,12 +651,12 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
                        le16_to_cpu(data_transfer->credits_requested);
                if (le16_to_cpu(data_transfer->credits_granted)) {
                        atomic_add(le16_to_cpu(data_transfer->credits_granted),
-                               &info->send_credits);
+                               &sc->send_io.credits.count);
                        /*
                         * We have new send credits granted from remote peer
                         * If any sender is waiting for credits, unblock it
                         */
-                       wake_up(&info->wait_send_queue);
+                       wake_up(&sc->send_io.credits.wait_queue);
                }
 
                log_incoming(INFO, "data flags %d data_offset %d data_length %d remaining_data_length %d\n",
@@ -1021,8 +1021,8 @@ static int smbd_post_send_iter(struct smbd_connection *info,
 
 wait_credit:
        /* Wait for send credits. A SMBD packet needs one credit */
-       rc = wait_event_interruptible(info->wait_send_queue,
-               atomic_read(&info->send_credits) > 0 ||
+       rc = wait_event_interruptible(sc->send_io.credits.wait_queue,
+               atomic_read(&sc->send_io.credits.count) > 0 ||
                sc->status != SMBDIRECT_SOCKET_CONNECTED);
        if (rc)
                goto err_wait_credit;
@@ -1032,8 +1032,8 @@ wait_credit:
                rc = -EAGAIN;
                goto err_wait_credit;
        }
-       if (unlikely(atomic_dec_return(&info->send_credits) < 0)) {
-               atomic_inc(&info->send_credits);
+       if (unlikely(atomic_dec_return(&sc->send_io.credits.count) < 0)) {
+               atomic_inc(&sc->send_io.credits.count);
                goto wait_credit;
        }
 
@@ -1162,7 +1162,7 @@ err_alloc:
 
 err_wait_send_queue:
        /* roll back send credits and pending */
-       atomic_inc(&info->send_credits);
+       atomic_inc(&sc->send_io.credits.count);
 
 err_wait_credit:
        return rc;
@@ -1843,7 +1843,6 @@ static struct smbd_connection *_smbd_get_connection(
                goto allocate_cache_failed;
        }
 
-       init_waitqueue_head(&info->wait_send_queue);
        INIT_DELAYED_WORK(&info->idle_timer_work, idle_connection_timer);
        queue_delayed_work(info->workqueue, &info->idle_timer_work,
                msecs_to_jiffies(sp->keepalive_interval_msec));
index 2ce6b7ab898a3804de1360b691e2a4469afc672e..7075bdc92193b9f47476245b6d5e571101fe0643 100644 (file)
@@ -53,7 +53,6 @@ struct smbd_connection {
        /* dynamic connection parameters defined in [MS-SMBD] 3.1.1.1 */
        enum keep_alive_status keep_alive_requested;
        int protocol;
-       atomic_t send_credits;
        atomic_t receive_credits;
        int receive_credit_target;
 
@@ -88,8 +87,6 @@ struct smbd_connection {
 
        bool send_immediate;
 
-       wait_queue_head_t wait_send_queue;
-
        struct workqueue_struct *workqueue;
        struct delayed_work idle_timer_work;