]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: remove separate empty_packet_queue
authorStefan Metzmacher <metze@samba.org>
Mon, 4 Aug 2025 12:10:13 +0000 (14:10 +0200)
committerSteve French <stfrench@microsoft.com>
Wed, 6 Aug 2025 20:04:13 +0000 (15:04 -0500)
There's no need to maintain two lists, we can just
have a single list of receive buffers, which are free to use.

It just added unneeded complexity and resulted in
ib_dma_unmap_single() not being called from recv_done()
for empty keepalive packets.

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
Fixes: f198186aa9bb ("CIFS: SMBD: Establish SMB Direct connection")
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 80d6a51b8c11d9728f33d54a71255026ea9f8603..65421703593aa41e03fd39f2d91721fb0d7253c1 100644 (file)
@@ -481,10 +481,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
                        server->smbd_conn->receive_credit_target);
                seq_printf(m, "\nPending send_pending: %x ",
                        atomic_read(&server->smbd_conn->send_pending));
-               seq_printf(m, "\nReceive buffers count_receive_queue: %x "
-                       "count_empty_packet_queue: %x",
-                       server->smbd_conn->count_receive_queue,
-                       server->smbd_conn->count_empty_packet_queue);
+               seq_printf(m, "\nReceive buffers count_receive_queue: %x ",
+                       server->smbd_conn->count_receive_queue);
                seq_printf(m, "\nMR responder_resources: %x "
                        "max_frmr_depth: %x mr_type: %x",
                        server->smbd_conn->responder_resources,
index e99e783f1b0e1cda60a6149f3999093711ceadc8..0ab490c0a9b0eb6d2da679d8af7d7777114bc92a 100644 (file)
@@ -13,8 +13,6 @@
 #include "cifsproto.h"
 #include "smb2proto.h"
 
-static struct smbd_response *get_empty_queue_buffer(
-               struct smbd_connection *info);
 static struct smbd_response *get_receive_buffer(
                struct smbd_connection *info);
 static void put_receive_buffer(
@@ -23,8 +21,6 @@ static void put_receive_buffer(
 static int allocate_receive_buffers(struct smbd_connection *info, int num_buf);
 static void destroy_receive_buffers(struct smbd_connection *info);
 
-static void put_empty_packet(
-               struct smbd_connection *info, struct smbd_response *response);
 static void enqueue_reassembly(
                struct smbd_connection *info,
                struct smbd_response *response, int data_length);
@@ -393,7 +389,6 @@ static bool process_negotiation_response(
 static void smbd_post_send_credits(struct work_struct *work)
 {
        int ret = 0;
-       int use_receive_queue = 1;
        int rc;
        struct smbd_response *response;
        struct smbd_connection *info =
@@ -409,18 +404,9 @@ static void smbd_post_send_credits(struct work_struct *work)
        if (info->receive_credit_target >
                atomic_read(&info->receive_credits)) {
                while (true) {
-                       if (use_receive_queue)
-                               response = get_receive_buffer(info);
-                       else
-                               response = get_empty_queue_buffer(info);
-                       if (!response) {
-                               /* now switch to empty packet queue */
-                               if (use_receive_queue) {
-                                       use_receive_queue = 0;
-                                       continue;
-                               } else
-                                       break;
-                       }
+                       response = get_receive_buffer(info);
+                       if (!response)
+                               break;
 
                        response->type = SMBD_TRANSFER_DATA;
                        response->first_segment = false;
@@ -511,7 +497,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
                                response,
                                data_length);
                } else
-                       put_empty_packet(info, response);
+                       put_receive_buffer(info, response);
 
                if (data_length)
                        wake_up_interruptible(&info->wait_reassembly_queue);
@@ -1115,17 +1101,6 @@ static int smbd_negotiate(struct smbd_connection *info)
        return rc;
 }
 
-static void put_empty_packet(
-               struct smbd_connection *info, struct smbd_response *response)
-{
-       spin_lock(&info->empty_packet_queue_lock);
-       list_add_tail(&response->list, &info->empty_packet_queue);
-       info->count_empty_packet_queue++;
-       spin_unlock(&info->empty_packet_queue_lock);
-
-       queue_work(info->workqueue, &info->post_send_credits_work);
-}
-
 /*
  * Implement Connection.FragmentReassemblyBuffer defined in [MS-SMBD] 3.1.1.1
  * This is a queue for reassembling upper layer payload and present to upper
@@ -1174,25 +1149,6 @@ static struct smbd_response *_get_first_reassembly(struct smbd_connection *info)
        return ret;
 }
 
-static struct smbd_response *get_empty_queue_buffer(
-               struct smbd_connection *info)
-{
-       struct smbd_response *ret = NULL;
-       unsigned long flags;
-
-       spin_lock_irqsave(&info->empty_packet_queue_lock, flags);
-       if (!list_empty(&info->empty_packet_queue)) {
-               ret = list_first_entry(
-                       &info->empty_packet_queue,
-                       struct smbd_response, list);
-               list_del(&ret->list);
-               info->count_empty_packet_queue--;
-       }
-       spin_unlock_irqrestore(&info->empty_packet_queue_lock, flags);
-
-       return ret;
-}
-
 /*
  * Get a receive buffer
  * For each remote send, we need to post a receive. The receive buffers are
@@ -1257,10 +1213,6 @@ static int allocate_receive_buffers(struct smbd_connection *info, int num_buf)
        spin_lock_init(&info->receive_queue_lock);
        info->count_receive_queue = 0;
 
-       INIT_LIST_HEAD(&info->empty_packet_queue);
-       spin_lock_init(&info->empty_packet_queue_lock);
-       info->count_empty_packet_queue = 0;
-
        init_waitqueue_head(&info->wait_receive_queues);
 
        for (i = 0; i < num_buf; i++) {
@@ -1294,9 +1246,6 @@ static void destroy_receive_buffers(struct smbd_connection *info)
 
        while ((response = get_receive_buffer(info)))
                mempool_free(response, info->response_mempool);
-
-       while ((response = get_empty_queue_buffer(info)))
-               mempool_free(response, info->response_mempool);
 }
 
 /* Implement idle connection timer [MS-SMBD] 3.1.6.2 */
@@ -1383,8 +1332,7 @@ void smbd_destroy(struct TCP_Server_Info *server)
 
        log_rdma_event(INFO, "free receive buffers\n");
        wait_event(info->wait_receive_queues,
-               info->count_receive_queue + info->count_empty_packet_queue
-                       == sp->recv_credit_max);
+               info->count_receive_queue == sp->recv_credit_max);
        destroy_receive_buffers(info);
 
        /*
index 75b3f491c3ad65f88a49b1e6ee50177ffc12b71d..ea04ce8a9763a6e3c06d5c1735280988cc1ba378 100644 (file)
@@ -110,10 +110,6 @@ struct smbd_connection {
        int count_receive_queue;
        spinlock_t receive_queue_lock;
 
-       struct list_head empty_packet_queue;
-       int count_empty_packet_queue;
-       spinlock_t empty_packet_queue_lock;
-
        wait_queue_head_t wait_receive_queues;
 
        /* Reassembly queue */