Skip to content

Commit 6920b4a

Browse files
metze-sambasmfrench
authored andcommitted
smb: smbdirect: let smbdirect_socket_init() initialize all [delayed_]work_structs as disabled
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 <[email protected]> Cc: Tom Talpey <[email protected]> Cc: Long Li <[email protected]> Acked-by: Namjae Jeon <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Stefan Metzmacher <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent ed3350f commit 6920b4a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

fs/smb/common/smbdirect/smbdirect_socket.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,14 @@ struct smbdirect_socket {
277277
} statistics;
278278
};
279279

280+
static void __smbdirect_socket_disabled_work(struct work_struct *work)
281+
{
282+
/*
283+
* Should never be called as disable_[delayed_]work_sync() was used.
284+
*/
285+
WARN_ON_ONCE(1);
286+
}
287+
280288
static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
281289
{
282290
/*
@@ -287,6 +295,14 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
287295

288296
init_waitqueue_head(&sc->status_wait);
289297

298+
INIT_WORK(&sc->disconnect_work, __smbdirect_socket_disabled_work);
299+
disable_work_sync(&sc->disconnect_work);
300+
301+
INIT_WORK(&sc->idle.immediate_work, __smbdirect_socket_disabled_work);
302+
disable_work_sync(&sc->idle.immediate_work);
303+
INIT_DELAYED_WORK(&sc->idle.timer_work, __smbdirect_socket_disabled_work);
304+
disable_delayed_work_sync(&sc->idle.timer_work);
305+
290306
atomic_set(&sc->send_io.credits.count, 0);
291307
init_waitqueue_head(&sc->send_io.credits.wait_queue);
292308

@@ -298,6 +314,8 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
298314
spin_lock_init(&sc->recv_io.free.lock);
299315

300316
atomic_set(&sc->recv_io.posted.count, 0);
317+
INIT_WORK(&sc->recv_io.posted.refill_work, __smbdirect_socket_disabled_work);
318+
disable_work_sync(&sc->recv_io.posted.refill_work);
301319

302320
atomic_set(&sc->recv_io.credits.count, 0);
303321

@@ -313,6 +331,8 @@ static __always_inline void smbdirect_socket_init(struct smbdirect_socket *sc)
313331
atomic_set(&sc->mr_io.ready.count, 0);
314332
init_waitqueue_head(&sc->mr_io.ready.wait_queue);
315333
atomic_set(&sc->mr_io.used.count, 0);
334+
INIT_WORK(&sc->mr_io.recovery_work, __smbdirect_socket_disabled_work);
335+
disable_work_sync(&sc->mr_io.recovery_work);
316336
init_waitqueue_head(&sc->mr_io.cleanup.wait_queue);
317337
}
318338

0 commit comments

Comments
 (0)