]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
smb: smbdirect: split out smbdirect_connection_recv_io_refill()
authorStefan Metzmacher <metze@samba.org>
Sat, 20 Sep 2025 03:42:56 +0000 (05:42 +0200)
committerSteve French <stfrench@microsoft.com>
Thu, 16 Apr 2026 02:58:19 +0000 (21:58 -0500)
This will allow us to refill the recv queue in a sync way
after negotiation.

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 2e90f6a1fcf43bf03f8ce28e486a2f741db596a2..b3e11c4c437de3c1f707837809c3a9a8d05b7930 100644 (file)
@@ -694,16 +694,13 @@ static int smbdirect_connection_post_recv_io(struct smbdirect_recv_io *msg)
        return ret;
 }
 
-__maybe_unused /* this is temporary while this file is included in others */
-static void smbdirect_connection_recv_io_refill_work(struct work_struct *work)
+static int smbdirect_connection_recv_io_refill(struct smbdirect_socket *sc)
 {
-       struct smbdirect_socket *sc =
-               container_of(work, struct smbdirect_socket, recv_io.posted.refill_work);
        int missing;
        int posted = 0;
 
        if (unlikely(sc->first_error))
-               return;
+               return sc->first_error;
 
        /*
         * Find out how much smbdirect_recv_io buffers we should post.
@@ -749,7 +746,7 @@ static void smbdirect_connection_recv_io_refill_work(struct work_struct *work)
                                "smbdirect_connection_post_recv_io failed rc=%d (%1pe)\n",
                                ret, SMBDIRECT_DEBUG_ERR_PTR(ret));
                        smbdirect_connection_put_recv_io(recv_io);
-                       return;
+                       return ret;
                }
 
                atomic_inc(&sc->recv_io.posted.count);
@@ -758,7 +755,7 @@ static void smbdirect_connection_recv_io_refill_work(struct work_struct *work)
 
        /* If nothing was posted we're done */
        if (posted == 0)
-               return;
+               return 0;
 
        atomic_add(posted, &sc->recv_io.credits.available);
 
@@ -781,11 +778,28 @@ static void smbdirect_connection_recv_io_refill_work(struct work_struct *work)
         * grant the credit anyway.
         */
        if (missing == 1 && sc->recv_io.credits.target != 1)
-               return;
+               return 0;
 
-       smbdirect_log_keep_alive(sc, SMBDIRECT_LOG_INFO,
-               "schedule send of an empty message\n");
-       queue_work(sc->workqueue, &sc->idle.immediate_work);
+       return posted;
+}
+
+__maybe_unused /* this is temporary while this file is included in others */
+static void smbdirect_connection_recv_io_refill_work(struct work_struct *work)
+{
+       struct smbdirect_socket *sc =
+               container_of(work, struct smbdirect_socket, recv_io.posted.refill_work);
+       int posted;
+
+       posted = smbdirect_connection_recv_io_refill(sc);
+       if (unlikely(posted < 0)) {
+               smbdirect_socket_schedule_cleanup(sc, posted);
+               return;
+       }
+       if (posted > 0) {
+               smbdirect_log_keep_alive(sc, SMBDIRECT_LOG_INFO,
+                       "schedule send of an empty message\n");
+               queue_work(sc->workqueue, &sc->idle.immediate_work);
+       }
 }
 
 static bool smbdirect_map_sges_single_page(struct smbdirect_map_sges *state,