]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smb: client: make use of smb: smbdirect_socket.recv_io.free.{list,lock}
authorStefan Metzmacher <metze@samba.org>
Tue, 5 Aug 2025 16:11:35 +0000 (18:11 +0200)
committerSteve French <stfrench@microsoft.com>
Wed, 6 Aug 2025 20:04:13 +0000 (15:04 -0500)
This will be used by the server too in order to have common
helper functions in future.

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
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 2589834882cb11659ee957d081141b8e34f0c550..073331080e3a5bcf148069ca9d4cfc9763a69d99 100644 (file)
@@ -1165,19 +1165,20 @@ static struct smbdirect_recv_io *_get_first_reassembly(struct smbd_connection *i
  */
 static struct smbdirect_recv_io *get_receive_buffer(struct smbd_connection *info)
 {
+       struct smbdirect_socket *sc = &info->socket;
        struct smbdirect_recv_io *ret = NULL;
        unsigned long flags;
 
-       spin_lock_irqsave(&info->receive_queue_lock, flags);
-       if (!list_empty(&info->receive_queue)) {
+       spin_lock_irqsave(&sc->recv_io.free.lock, flags);
+       if (!list_empty(&sc->recv_io.free.list)) {
                ret = list_first_entry(
-                       &info->receive_queue,
+                       &sc->recv_io.free.list,
                        struct smbdirect_recv_io, list);
                list_del(&ret->list);
                info->count_receive_queue--;
                info->count_get_receive_buffer++;
        }
-       spin_unlock_irqrestore(&info->receive_queue_lock, flags);
+       spin_unlock_irqrestore(&sc->recv_io.free.lock, flags);
 
        return ret;
 }
@@ -1202,11 +1203,11 @@ static void put_receive_buffer(
                response->sge.length = 0;
        }
 
-       spin_lock_irqsave(&info->receive_queue_lock, flags);
-       list_add_tail(&response->list, &info->receive_queue);
+       spin_lock_irqsave(&sc->recv_io.free.lock, flags);
+       list_add_tail(&response->list, &sc->recv_io.free.list);
        info->count_receive_queue++;
        info->count_put_receive_buffer++;
-       spin_unlock_irqrestore(&info->receive_queue_lock, flags);
+       spin_unlock_irqrestore(&sc->recv_io.free.lock, flags);
 
        queue_work(info->workqueue, &info->post_send_credits_work);
 }
@@ -1223,8 +1224,8 @@ static int allocate_receive_buffers(struct smbd_connection *info, int num_buf)
        info->reassembly_data_length = 0;
        info->reassembly_queue_length = 0;
 
-       INIT_LIST_HEAD(&info->receive_queue);
-       spin_lock_init(&info->receive_queue_lock);
+       INIT_LIST_HEAD(&sc->recv_io.free.list);
+       spin_lock_init(&sc->recv_io.free.lock);
        info->count_receive_queue = 0;
 
        init_waitqueue_head(&info->wait_receive_queues);
@@ -1236,16 +1237,16 @@ static int allocate_receive_buffers(struct smbd_connection *info, int num_buf)
 
                response->socket = sc;
                response->sge.length = 0;
-               list_add_tail(&response->list, &info->receive_queue);
+               list_add_tail(&response->list, &sc->recv_io.free.list);
                info->count_receive_queue++;
        }
 
        return 0;
 
 allocate_failed:
-       while (!list_empty(&info->receive_queue)) {
+       while (!list_empty(&sc->recv_io.free.list)) {
                response = list_first_entry(
-                               &info->receive_queue,
+                               &sc->recv_io.free.list,
                                struct smbdirect_recv_io, list);
                list_del(&response->list);
                info->count_receive_queue--;
index f53781f98e643ba3f9e349deae6664f0f7ccdf03..3381e01f5b83750693592d9f01dcb3be8a8cfe1b 100644 (file)
@@ -105,10 +105,7 @@ struct smbd_connection {
        wait_queue_head_t wait_post_send;
 
        /* Receive queue */
-       struct list_head receive_queue;
        int count_receive_queue;
-       spinlock_t receive_queue_lock;
-
        wait_queue_head_t wait_receive_queues;
 
        /* Reassembly queue */