From: Stefan Metzmacher Date: Sat, 20 Sep 2025 03:42:56 +0000 (+0200) Subject: smb: smbdirect: split out smbdirect_connection_recv_io_refill() X-Git-Tag: v7.1-rc1~128^2~118 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a5159795248fec94d4b0995584e038d50cceb1b6;p=thirdparty%2Flinux.git smb: smbdirect: split out smbdirect_connection_recv_io_refill() This will allow us to refill the recv queue in a sync way after negotiation. Cc: Steve French Cc: Tom Talpey Cc: Long Li Cc: Namjae Jeon Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher Acked-by: Namjae Jeon Signed-off-by: Steve French --- diff --git a/fs/smb/common/smbdirect/smbdirect_connection.c b/fs/smb/common/smbdirect/smbdirect_connection.c index 2e90f6a1fcf43..b3e11c4c437de 100644 --- a/fs/smb/common/smbdirect/smbdirect_connection.c +++ b/fs/smb/common/smbdirect/smbdirect_connection.c @@ -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,