[PATCH v2 015/127] smb: smbdirect: introduce smbdirect_connection_idle_timer_work()
Stefan Metzmacher
metze at samba.org
Wed Oct 29 13:19:53 UTC 2025
This is basically a copy of idle_connection_timer() in the client
and smb_direct_idle_connection_timer() in the server.
The only difference is that the server does not have logging.
Currently the callers set their own timer function after
smbdirect_socket_prepare_create(), but that will change
in the next steps...
Cc: Steve French <smfrench at gmail.com>
Cc: Tom Talpey <tom at talpey.com>
Cc: Long Li <longli at microsoft.com>
Cc: Namjae Jeon <linkinjeon at kernel.org>
Cc: linux-cifs at vger.kernel.org
Cc: samba-technical at lists.samba.org
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Signed-off-by: Steve French <stfrench at microsoft.com>
---
.../common/smbdirect/smbdirect_connection.c | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/fs/smb/common/smbdirect/smbdirect_connection.c b/fs/smb/common/smbdirect/smbdirect_connection.c
index 27f8545ee30d..79be89a3946e 100644
--- a/fs/smb/common/smbdirect/smbdirect_connection.c
+++ b/fs/smb/common/smbdirect/smbdirect_connection.c
@@ -9,6 +9,7 @@
static void smbdirect_connection_schedule_disconnect(struct smbdirect_socket *sc,
int error);
static void smbdirect_connection_disconnect_work(struct work_struct *work);
+static void smbdirect_connection_idle_timer_work(struct work_struct *work);
__maybe_unused /* this is temporary while this file is included in orders */
static void smbdirect_socket_prepare_create(struct smbdirect_socket *sc,
@@ -29,6 +30,8 @@ static void smbdirect_socket_prepare_create(struct smbdirect_socket *sc,
sc->workqueue = workqueue;
INIT_WORK(&sc->disconnect_work, smbdirect_connection_disconnect_work);
+
+ INIT_DELAYED_WORK(&sc->idle.timer_work, smbdirect_connection_idle_timer_work);
}
__maybe_unused /* this is temporary while this file is included in orders */
@@ -276,3 +279,34 @@ static void smbdirect_connection_disconnect_work(struct work_struct *work)
*/
smbdirect_connection_wake_up_all(sc);
}
+
+static void smbdirect_connection_idle_timer_work(struct work_struct *work)
+{
+ struct smbdirect_socket *sc =
+ container_of(work, struct smbdirect_socket, idle.timer_work.work);
+ const struct smbdirect_socket_parameters *sp = &sc->parameters;
+
+ if (sc->idle.keepalive != SMBDIRECT_KEEPALIVE_NONE) {
+ smbdirect_log_keep_alive(sc, SMBDIRECT_LOG_ERR,
+ "%s => timeout sc->idle.keepalive=%s\n",
+ smbdirect_socket_status_string(sc->status),
+ sc->idle.keepalive == SMBDIRECT_KEEPALIVE_SENT ?
+ "SENT" : "PENDING");
+ smbdirect_connection_schedule_disconnect(sc, -ETIMEDOUT);
+ return;
+ }
+
+ if (sc->status != SMBDIRECT_SOCKET_CONNECTED)
+ return;
+
+ /*
+ * Now use the keepalive timeout (instead of keepalive interval)
+ * in order to wait for a response
+ */
+ sc->idle.keepalive = SMBDIRECT_KEEPALIVE_PENDING;
+ mod_delayed_work(sc->workqueue, &sc->idle.timer_work,
+ msecs_to_jiffies(sp->keepalive_timeout_msec));
+ smbdirect_log_keep_alive(sc, SMBDIRECT_LOG_INFO,
+ "schedule send of empty idle message\n");
+ queue_work(sc->workqueue, &sc->idle.immediate_work);
+}
--
2.43.0
More information about the samba-technical
mailing list