smb: server: split ksmbd_rdma_stop_listening() out of ksmbd_rdma_destroy()
Subsystems (3)
Stefan Metzmacher
reviewerPATCH 1/1 smb: server: split ksmbd_rdma_stop_listening() out of ksmbd_rdma_destroy()
We can't call destroy_workqueue(smb_direct_wq); before stop_sessions()!
Otherwise already existing connections try to use smb_direct_wq as a NULL pointer.
--- fs/smb/server/connection.c | 3 ++- fs/smb/server/transport_rdma.c | 5 ++++- fs/smb/server/transport_rdma.h | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-)
fs/smb/server/connection.c +2 -1
@@ -517,7 +517,8 @@ void ksmbd_conn_transport_destroy(void) {mutex_lock (&init_lock);ksmbd_tcp_destroy (); -ksmbd_rdma_destroy (); +ksmbd_rdma_stop_listening ();stop_sessions (); +ksmbd_rdma_destroy ();mutex_unlock (&init_lock); }
fs/smb/server/transport_rdma.c +4 -1
@@ -2200,7 +2200,7 @@ int ksmbd_rdma_init(void)return 0 ; } -void ksmbd_rdma_destroy (void ) +void ksmbd_rdma_stop_listening (void ) {if (!smb_direct_listener.cm_id)return ;
@@ -2209,7 +2209,10 @@ void ksmbd_rdma_destroy(void)rdma_destroy_id (smb_direct_listener.cm_id); smb_direct_listener.cm_id =NULL ; +} +void ksmbd_rdma_destroy (void ) +{if (smb_direct_wq) {destroy_workqueue (smb_direct_wq); smb_direct_wq =NULL ;
fs/smb/server/transport_rdma.h +3 -1
@@ -13,13 +13,15 @@#ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init (void ); +void ksmbd_rdma_stop_listening (void );void ksmbd_rdma_destroy (void );bool ksmbd_rdma_capable_netdev (struct net_device *netdev);void init_smbd_max_io_size (unsigned int sz);unsigned int get_smbd_max_read_write_size (void );#else static inline int ksmbd_rdma_init (void ) {return 0 ; } -static inline int ksmbd_rdma_destroy (void ) {return 0 ; } +static inline void ksmbd_rdma_stop_listening(void) { return }; +static inline void ksmbd_rdma_destroy (void ) {return ; }static inline bool ksmbd_rdma_capable_netdev (struct net_device *netdev) {return false; }static inline void init_smbd_max_io_size (unsigned int sz) { }static inline unsigned int get_smbd_max_read_write_size (void ) {return 0 ; }
Signature · 1 line
2.43.0
Quoted 6 lines · Stefan Metzmacher via samba-technical
We can't call
destroy_workqueue(smb_direct_wq); beforestop_sessions()!Otherwise already existing connections try to use
smb_direct_wqas a NULL pointer.
Quoted 7 lines
Cc Namjae Jeon <[email protected]>Cc Steve French <[email protected]>Cc Tom Talpey <[email protected]>Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")Signed-off-by Stefan Metzmacher <[email protected]>
Applied it to #ksmbd-for-next-next.
Thanks!
Quoted 63 lines · Stefan Metzmacher
We can't call
destroy_workqueue(smb_direct_wq); beforestop_sessions()!Otherwise already existing connections try to use
smb_direct_wqas a NULL pointer.Cc Namjae Jeon <[email protected]>Cc Steve French <[email protected]>Cc Tom Talpey <[email protected]>Fixes 0626e6641f6b ("cifsd: add server handler for central processing and tranport layers")Signed-off-by Stefan Metzmacher <[email protected]>--- fs/smb/server/connection.c | 3 ++- fs/smb/server/transport_rdma.c | 5 ++++- fs/smb/server/transport_rdma.h | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-)fs/smb/server/connection.c +2
-1@@ -517,7 +517,8 @@ void ksmbd_conn_transport_destroy(void) {mutex_lock (&init_lock);ksmbd_tcp_destroy (); -ksmbd_rdma_destroy (); +ksmbd_rdma_stop_listening ();stop_sessions (); +ksmbd_rdma_destroy ();mutex_unlock (&init_lock); }fs/smb/server/transport_rdma.c +4
-1@@ -2200,7 +2200,7 @@ int ksmbd_rdma_init(void)return 0 ; } -void ksmbd_rdma_destroy (void ) +void ksmbd_rdma_stop_listening (void ) {if (!smb_direct_listener.cm_id)return ;@@ -2209,7 +2209,10 @@ void ksmbd_rdma_destroy(void)rdma_destroy_id (smb_direct_listener.cm_id); smb_direct_listener.cm_id =NULL ; +} +void ksmbd_rdma_destroy (void ) +{if (smb_direct_wq) {destroy_workqueue (smb_direct_wq); smb_direct_wq =NULL ;fs/smb/server/transport_rdma.h +0
-0@@ -13,13 +13,15 @@#ifdef CONFIG_SMB_SERVER_SMBDIRECT
fs/smb/server/transport_rdma.h line 23
Quoted 10 lines
fs/smb/server/transport_rdma.h +2
-1int ksmbd_rdma_init (void ); +void ksmbd_rdma_stop_listening (void );void ksmbd_rdma_destroy (void );bool ksmbd_rdma_capable_netdev (struct net_device *netdev);void init_smbd_max_io_size (unsigned int sz);unsigned int get_smbd_max_read_write_size (void );#else static inline int ksmbd_rdma_init (void ) {return 0 ; } -static inline int ksmbd_rdma_destroy (void ) {return 0 ; } +static inline void ksmbd_rdma_stop_listening(void) { return };
^^ return; (nothing at all would be even better)
This seems to have broken our internal linux-next builds.
Thanks,
Pedro
Stefan Metzmacher
reviewerHi Pedro,
Quoted 11 lines
Quoted 11 lines
fs/smb/server/transport_rdma.c +2
-0+void ksmbd_rdma_destroy (void ) +{if (smb_direct_wq) {destroy_workqueue (smb_direct_wq); smb_direct_wq =NULL ;fs/smb/server/transport_rdma.h +0
-0@@ -13,13 +13,15 @@
Quoted 13 lines
fs/smb/server/transport_rdma.h line 23
Quoted 11 lines
fs/smb/server/transport_rdma.h +2
-1#ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init (void ); +void ksmbd_rdma_stop_listening (void );void ksmbd_rdma_destroy (void );bool ksmbd_rdma_capable_netdev (struct net_device *netdev);void init_smbd_max_io_size (unsigned int sz);unsigned int get_smbd_max_read_write_size (void );#else static inline int ksmbd_rdma_init (void ) {return 0 ; } -static inline int ksmbd_rdma_destroy (void ) {return 0 ; } +static inline void ksmbd_rdma_stop_listening(void) { return };^^ return; (nothing at all would be even better)
This seems to have broken our internal linux-next builds.
Sorry for that!
Steve can you remove 'return' so that the line is this:
static inline void ksmbd_rdma_stop_listening(void) { }
Thanks!
metze
Steve French
Acked-by Namjae JeonQuoted 2 lines
Steve can you remove 'return' so that the line is this:
static inline voidksmbd_rdma_stop_listening(void){
Done, and have updated ksmbd-for-next
Updated patch also attached, let me know if any problems.
Also let me know if you have rebased versions of the other smbdirect patches for 6.18-rc so I can get them in linux-next
Quoted 35 lines · Stefan Metzmacher
Hi Pedro,
Quoted 11 lines
Quoted 11 lines
(quoted diff) +2
-0+void ksmbd_rdma_destroy(void) +{ if (smb_direct_wq) { destroy_workqueue(smb_direct_wq); smb_direct_wq = NULL;fs/smb/server/transport_rdma.h +0
-0@@ -13,13 +13,15 @@Quoted 13 lines
fs/smb/server/transport_rdma.h line 23
Quoted 11 lines
fs/smb/server/transport_rdma.h +2
-1#ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init (void ); +void ksmbd_rdma_stop_listening (void );void ksmbd_rdma_destroy (void );bool ksmbd_rdma_capable_netdev (struct net_device *netdev);void init_smbd_max_io_size (unsigned int sz);unsigned int get_smbd_max_read_write_size (void );#else static inline int ksmbd_rdma_init (void ) {return 0 ; } -static inline int ksmbd_rdma_destroy (void ) {return 0 ; } +static inline void ksmbd_rdma_stop_listening(void) { return };^^ return; (nothing at all would be even better)
This seems to have broken our internal linux-next builds.Sorry for that!
Steve can you remove 'return' so that the line is this:
static inline voidksmbd_rdma_stop_listening(void){ }Thanks!
metze
Signature · 3 lines
Thanks, Steve
From a49501023f50d39e06c420ac09b74185d06ee0e6 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <[email protected]>
Date: Tue, 12 Aug 2025 18:45:46 +0200
Subject: [PATCH] smb: server: split ksmbd_rdma_stop_listening() out of
ksmbd_rdma_destroy()
We can't call destroy_workqueue(smb_direct_wq); before stop_sessions()!
Otherwise already existing connections try to use smb_direct_wq as a NULL pointer.
--- fs/smb/server/connection.c | 3 ++- fs/smb/server/transport_rdma.c | 5 ++++- fs/smb/server/transport_rdma.h | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-)
fs/smb/server/connection.c +2 -1
@@ -504,7 +504,8 @@ void ksmbd_conn_transport_destroy(void) {mutex_lock (&init_lock);ksmbd_tcp_destroy (); -ksmbd_rdma_destroy (); +ksmbd_rdma_stop_listening ();stop_sessions (); +ksmbd_rdma_destroy ();mutex_unlock (&init_lock); }
fs/smb/server/transport_rdma.c +4 -1
@@ -2194,7 +2194,7 @@ int ksmbd_rdma_init(void)return 0 ; } -void ksmbd_rdma_destroy (void ) +void ksmbd_rdma_stop_listening (void ) {if (!smb_direct_listener.cm_id)return ;
@@ -2203,7 +2203,10 @@ void ksmbd_rdma_destroy(void)rdma_destroy_id (smb_direct_listener.cm_id); smb_direct_listener.cm_id =NULL ; +} +void ksmbd_rdma_destroy (void ) +{if (smb_direct_wq) {destroy_workqueue (smb_direct_wq); smb_direct_wq =NULL ;
fs/smb/server/transport_rdma.h +3 -1
@@ -54,13 +54,15 @@ struct smb_direct_data_transfer {#ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init (void ); +void ksmbd_rdma_stop_listening (void );void ksmbd_rdma_destroy (void );bool ksmbd_rdma_capable_netdev (struct net_device *netdev);void init_smbd_max_io_size (unsigned int sz);unsigned int get_smbd_max_read_write_size (void );#else static inline int ksmbd_rdma_init (void ) {return 0 ; } -static inline int ksmbd_rdma_destroy (void ) {return 0 ; } +static inline void ksmbd_rdma_stop_listening (void ) { }; +static inline void ksmbd_rdma_destroy (void ) {return ; }static inline bool ksmbd_rdma_capable_netdev (struct net_device *netdev) {return false; }static inline void init_smbd_max_io_size (unsigned int sz) { }static inline unsigned int get_smbd_max_read_write_size (void ) {return 0 ; }
Signature · 1 line
2.43.0
Stefan Metzmacher
reviewerAm 15.08.25 um 18:52 schrieb Steve French:
Quoted 6 lines
Quoted 2 lines
Steve can you remove 'return' so that the line is this:
static inline voidksmbd_rdma_stop_listening(void){Done, and have updated ksmbd-for-next
Updated patch also attached, let me know if any problems.
Maybe also remove the 'return;' from the inline ksmbd_rdma_destroy function?
Quoted 2 lines
Also let me know if you have rebased versions of the other smbdirect patches for 6.18-rc so I can get them in linux-next
I guess I'll base on Monday on 6.17-rc2 and will post what I have then.
Thanks!
metze
Steve French
Acked-by Namjae JeonQuoted 1 line
Maybe also remove the 'return;' from the inline
ksmbd_rdma_destroyfunction?
Done (updated cifs-2.6.git for-next with attached)
It does look a little strange that a trailing ';' is only after the ksmbd_rdma_stop_listening() line - is that intentional
fs/smb/server/transport_rdma.h +3 -1
@@ -54,13 +54,15 @@ struct smb_direct_data_transfer {#ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init (void ); +void ksmbd_rdma_stop_listening (void );void ksmbd_rdma_destroy (void );bool ksmbd_rdma_capable_netdev (struct net_device *netdev);void init_smbd_max_io_size (unsigned int sz);unsigned int get_smbd_max_read_write_size (void );#else static inline int ksmbd_rdma_init (void ) {return 0 ; } -static inline int ksmbd_rdma_destroy (void ) {return 0 ; } +static inline void ksmbd_rdma_stop_listening (void ) { }; +static inline void ksmbd_rdma_destroy (void ) { } static inline bool ksmbd_rdma_capable_netdev(struct net_device
*netdev) { return false; }
static inline void init_smbd_max_io_size(unsigned int sz) { } static inline unsigned int get_smbd_max_read_write_size(void) { return 0; }
Quoted 19 lines · Stefan Metzmacher
Am 15.08.25 um 18:52 schrieb Steve French:
Quoted 6 lines
Quoted 2 lines
Steve can you remove 'return' so that the line is this:
static inline voidksmbd_rdma_stop_listening(void){Done, and have updated ksmbd-for-next
Updated patch also attached, let me know if any problems.
Maybe also remove the 'return;' from the inline
ksmbd_rdma_destroyfunction?Quoted 2 lines
Also let me know if you have rebased versions of the other smbdirect patches for 6.18-rc so I can get them in linux-next
I guess I'll base on Monday on 6.17-rc2 and will post what I have then.
Thanks!
metze
Signature · 3 lines
Thanks, Steve
From 656205db650a9942a33b5cc5bc9012c331746596 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <[email protected]>
Date: Tue, 12 Aug 2025 18:45:46 +0200
Subject: [PATCH] smb: server: split ksmbd_rdma_stop_listening() out of
ksmbd_rdma_destroy()
We can't call destroy_workqueue(smb_direct_wq); before stop_sessions()!
Otherwise already existing connections try to use smb_direct_wq as a NULL pointer.
--- fs/smb/server/connection.c | 3 ++- fs/smb/server/transport_rdma.c | 5 ++++- fs/smb/server/transport_rdma.h | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-)
fs/smb/server/connection.c +2 -1
@@ -504,7 +504,8 @@ void ksmbd_conn_transport_destroy(void) {mutex_lock (&init_lock);ksmbd_tcp_destroy (); -ksmbd_rdma_destroy (); +ksmbd_rdma_stop_listening ();stop_sessions (); +ksmbd_rdma_destroy ();mutex_unlock (&init_lock); }
fs/smb/server/transport_rdma.c +4 -1
@@ -2194,7 +2194,7 @@ int ksmbd_rdma_init(void)return 0 ; } -void ksmbd_rdma_destroy (void ) +void ksmbd_rdma_stop_listening (void ) {if (!smb_direct_listener.cm_id)return ;
@@ -2203,7 +2203,10 @@ void ksmbd_rdma_destroy(void)rdma_destroy_id (smb_direct_listener.cm_id); smb_direct_listener.cm_id =NULL ; +} +void ksmbd_rdma_destroy (void ) +{if (smb_direct_wq) {destroy_workqueue (smb_direct_wq); smb_direct_wq =NULL ;
fs/smb/server/transport_rdma.h +3 -1
@@ -54,13 +54,15 @@ struct smb_direct_data_transfer {#ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init (void ); +void ksmbd_rdma_stop_listening (void );void ksmbd_rdma_destroy (void );bool ksmbd_rdma_capable_netdev (struct net_device *netdev);void init_smbd_max_io_size (unsigned int sz);unsigned int get_smbd_max_read_write_size (void );#else static inline int ksmbd_rdma_init (void ) {return 0 ; } -static inline int ksmbd_rdma_destroy (void ) {return 0 ; } +static inline void ksmbd_rdma_stop_listening (void ) { }; +static inline void ksmbd_rdma_destroy (void ) { }static inline bool ksmbd_rdma_capable_netdev (struct net_device *netdev) {return false; }static inline void init_smbd_max_io_size (unsigned int sz) { }static inline unsigned int get_smbd_max_read_write_size (void ) {return 0 ; }
Signature · 1 line
2.43.0
Stefan Metzmacher
reviewerAm 15.08.25 um 20:52 schrieb Steve French:
Quoted 15 lines
Quoted 1 line
Maybe also remove the 'return;' from the inline
ksmbd_rdma_destroyfunction?Done (updated cifs-2.6.git for-next with attached)
It does look a little strange that a trailing ';' is only after the
ksmbd_rdma_stop_listening()line - is that intentionalfs/smb/server/transport_rdma.h +0
-0@@ -54,13 +54,15 @@ struct smb_direct_data_transfer {#ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init (void );
fs/smb/server/transport_rdma.h struct smb_direct_data_transfer { · line 65
Quoted 10 lines
fs/smb/server/transport_rdma.h +3
-1+void ksmbd_rdma_stop_listening (void );void ksmbd_rdma_destroy (void );bool ksmbd_rdma_capable_netdev (struct net_device *netdev);void init_smbd_max_io_size (unsigned int sz);unsigned int get_smbd_max_read_write_size (void );#else static inline int ksmbd_rdma_init (void ) {return 0 ; } -static inline int ksmbd_rdma_destroy (void ) {return 0 ; } +static inline void ksmbd_rdma_stop_listening (void ) { }; +static inline void ksmbd_rdma_destroy (void ) { }
No it needs to be just { } in both cases.
Thanks!
metze
Steve French
Acked-by Namjae Jeonupdated ksmbd-for-next (also can see attached patch)
Quoted 34 lines · Stefan Metzmacher
Am 15.08.25 um 20:52 schrieb Steve French:
Quoted 15 lines
Quoted 1 line
Maybe also remove the 'return;' from the inline
ksmbd_rdma_destroyfunction?Done (updated cifs-2.6.git for-next with attached)
It does look a little strange that a trailing ';' is only after the
ksmbd_rdma_stop_listening()line - is that intentionalfs/smb/server/transport_rdma.h +0
-0@@ -54,13 +54,15 @@ struct smb_direct_data_transfer {#ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init (void );fs/smb/server/transport_rdma.h struct smb_direct_data_transfer { · line 65
Quoted 10 lines
fs/smb/server/transport_rdma.h +3
-1+void ksmbd_rdma_stop_listening (void );void ksmbd_rdma_destroy (void );bool ksmbd_rdma_capable_netdev (struct net_device *netdev);void init_smbd_max_io_size (unsigned int sz);unsigned int get_smbd_max_read_write_size (void );#else static inline int ksmbd_rdma_init (void ) {return 0 ; } -static inline int ksmbd_rdma_destroy (void ) {return 0 ; } +static inline void ksmbd_rdma_stop_listening (void ) { }; +static inline void ksmbd_rdma_destroy (void ) { }No it needs to be just { } in both cases.
Thanks!
metze
Signature · 3 lines
Thanks, Steve
From 473b1f20f5919ca58deea2d23d39f75b11aef831 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <[email protected]>
Date: Tue, 12 Aug 2025 18:45:46 +0200
Subject: [PATCH] smb: server: split ksmbd_rdma_stop_listening() out of
ksmbd_rdma_destroy()
We can't call destroy_workqueue(smb_direct_wq); before stop_sessions()!
Otherwise already existing connections try to use smb_direct_wq as a NULL pointer.
--- fs/smb/server/connection.c | 3 ++- fs/smb/server/transport_rdma.c | 5 ++++- fs/smb/server/transport_rdma.h | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-)
fs/smb/server/connection.c +2 -1
@@ -504,7 +504,8 @@ void ksmbd_conn_transport_destroy(void) {mutex_lock (&init_lock);ksmbd_tcp_destroy (); -ksmbd_rdma_destroy (); +ksmbd_rdma_stop_listening ();stop_sessions (); +ksmbd_rdma_destroy ();mutex_unlock (&init_lock); }
fs/smb/server/transport_rdma.c +4 -1
@@ -2194,7 +2194,7 @@ int ksmbd_rdma_init(void)return 0 ; } -void ksmbd_rdma_destroy (void ) +void ksmbd_rdma_stop_listening (void ) {if (!smb_direct_listener.cm_id)return ;
@@ -2203,7 +2203,10 @@ void ksmbd_rdma_destroy(void)rdma_destroy_id (smb_direct_listener.cm_id); smb_direct_listener.cm_id =NULL ; +} +void ksmbd_rdma_destroy (void ) +{if (smb_direct_wq) {destroy_workqueue (smb_direct_wq); smb_direct_wq =NULL ;
fs/smb/server/transport_rdma.h +3 -1
@@ -54,13 +54,15 @@ struct smb_direct_data_transfer {#ifdef CONFIG_SMB_SERVER_SMBDIRECT int ksmbd_rdma_init (void ); +void ksmbd_rdma_stop_listening (void );void ksmbd_rdma_destroy (void );bool ksmbd_rdma_capable_netdev (struct net_device *netdev);void init_smbd_max_io_size (unsigned int sz);unsigned int get_smbd_max_read_write_size (void );#else static inline int ksmbd_rdma_init (void ) {return 0 ; } -static inline int ksmbd_rdma_destroy (void ) {return 0 ; } +static inline void ksmbd_rdma_stop_listening (void ) { } +static inline void ksmbd_rdma_destroy (void ) { }static inline bool ksmbd_rdma_capable_netdev (struct net_device *netdev) {return false; }static inline void init_smbd_max_io_size (unsigned int sz) { }static inline unsigned int get_smbd_max_read_write_size (void ) {return 0 ; }
Signature · 1 line
2.43.0