]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smb: smbdirect: introduce smbdirect_connection_{get,put}_recv_io()
authorStefan Metzmacher <metze@samba.org>
Tue, 26 Aug 2025 17:05:01 +0000 (19:05 +0200)
committerSteve French <stfrench@microsoft.com>
Thu, 16 Apr 2026 02:58:18 +0000 (21:58 -0500)
These are basically copies of {get,put}_receive_buffer() in the client
and they are very similar to {get_free,put}_recvmsg() in the server.

The only difference to {get_free,put}_recvmsg() are the
updating of the sc->statistics.*.

In addition smbdirect_connection_get_recv_io() uses
list_first_entry_or_null() in order to simplify the code.
We also only use it on a healthy connection.

smbdirect_connection_put_recv_io() uses msg->socket instead
of an explicit argument. And it disables any complex_work.

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-cifs@vger.kernel.org
Cc: samba-technical@lists.samba.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/common/smbdirect/smbdirect_connection.c

index 0a96f5db6ff377d707f4131ef55844c8202d6e54..96f00c342a899fab14d444146085f737ea11ec10 100644 (file)
@@ -5,3 +5,45 @@
  */
 
 #include "smbdirect_internal.h"
+
+__maybe_unused /* this is temporary while this file is included in others */
+static struct smbdirect_recv_io *smbdirect_connection_get_recv_io(struct smbdirect_socket *sc)
+{
+       struct smbdirect_recv_io *msg = NULL;
+       unsigned long flags;
+
+       spin_lock_irqsave(&sc->recv_io.free.lock, flags);
+       if (likely(!sc->first_error))
+               msg = list_first_entry_or_null(&sc->recv_io.free.list,
+                                              struct smbdirect_recv_io,
+                                              list);
+       if (likely(msg)) {
+               list_del(&msg->list);
+               sc->statistics.get_receive_buffer++;
+       }
+       spin_unlock_irqrestore(&sc->recv_io.free.lock, flags);
+
+       return msg;
+}
+
+__maybe_unused /* this is temporary while this file is included in others */
+static void smbdirect_connection_put_recv_io(struct smbdirect_recv_io *msg)
+{
+       struct smbdirect_socket *sc = msg->socket;
+       unsigned long flags;
+
+       if (likely(msg->sge.length != 0)) {
+               ib_dma_unmap_single(sc->ib.dev,
+                                   msg->sge.addr,
+                                   msg->sge.length,
+                                   DMA_FROM_DEVICE);
+               msg->sge.length = 0;
+       }
+
+       spin_lock_irqsave(&sc->recv_io.free.lock, flags);
+       list_add_tail(&msg->list, &sc->recv_io.free.list);
+       sc->statistics.put_receive_buffer++;
+       spin_unlock_irqrestore(&sc->recv_io.free.lock, flags);
+
+       queue_work(sc->workqueue, &sc->recv_io.posted.refill_work);
+}