]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: smbdirect: let smbdirect_socket_init() initialize all [delayed_]work_structs...
authorStefan Metzmacher <metze@samba.org>
Tue, 26 Aug 2025 14:30:32 +0000 (16:30 +0200)
committerSteve French <stfrench@microsoft.com>
Sun, 28 Sep 2025 23:29:48 +0000 (18:29 -0500)
This safer to start with and allows common code not care about if the
caller uses these or not. E.g. sc->mr_io.recovery_work is only used
on the client...

Note disable_[delayed_]work_sync() requires a valid function pointer
in INIT_[DELAYED_]WORK(). The non _sync() version don't require it,
but as we need to use the _sync() version on cleanup we better use
it here too, it won't block anyway here...

Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Acked-by: 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>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/common/smbdirect/smbdirect_socket.h

index 5d403b1beceab507af8e3658571b8394cb26287a..14f6e6d2035fb06cc5d43c3acebd1e9fc6d5c64d 100644 (file)
@@ -277,6 +277,14 @@ struct smbdirect_socket {
        } statistics;
 };
 
+static void __smbdirect_socket_disabled_work(struct work_struct *work)
+{
+       /*
+        * Should never be called as disable_[delayed_]work_sync() was used.
+        */
+       WARN_ON_ONCE(1);
+}
+
 static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
 {
        /*
@@ -287,6 +295,14 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
 
        init_waitqueue_head(&sc->status_wait);
 
+       INIT_WORK(&sc->disconnect_work, __smbdirect_socket_disabled_work);
+       disable_work_sync(&sc->disconnect_work);
+
+       INIT_WORK(&sc->idle.immediate_work, __smbdirect_socket_disabled_work);
+       disable_work_sync(&sc->idle.immediate_work);
+       INIT_DELAYED_WORK(&sc->idle.timer_work, __smbdirect_socket_disabled_work);
+       disable_delayed_work_sync(&sc->idle.timer_work);
+
        atomic_set(&sc->send_io.credits.count, 0);
        init_waitqueue_head(&sc->send_io.credits.wait_queue);
 
@@ -298,6 +314,8 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
        spin_lock_init(&sc->recv_io.free.lock);
 
        atomic_set(&sc->recv_io.posted.count, 0);
+       INIT_WORK(&sc->recv_io.posted.refill_work, __smbdirect_socket_disabled_work);
+       disable_work_sync(&sc->recv_io.posted.refill_work);
 
        atomic_set(&sc->recv_io.credits.count, 0);
 
@@ -313,6 +331,8 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
        atomic_set(&sc->mr_io.ready.count, 0);
        init_waitqueue_head(&sc->mr_io.ready.wait_queue);
        atomic_set(&sc->mr_io.used.count, 0);
+       INIT_WORK(&sc->mr_io.recovery_work, __smbdirect_socket_disabled_work);
+       disable_work_sync(&sc->mr_io.recovery_work);
        init_waitqueue_head(&sc->mr_io.cleanup.wait_queue);
 }