Skip to content

Commit 25c2e34

Browse files
metze-sambasmfrench
authored andcommitted
smb: smbdirect: fix the logic in smbdirect_socket_destroy_sync() without an error
If smbdirect_socket_destroy_sync() and sc->first_error was not set we should set -ESHUTDOWN, that's a better condition doing it only implicitly with the sc->status < SMBDIRECT_SOCKET_DISCONNECTING check. Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: David Howells <dhowells@redhat.com> Cc: Henrique Carvalho <henrique.carvalho@suse.com> 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>
1 parent 3892007 commit 25c2e34

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

fs/smb/common/smbdirect/smbdirect_socket.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,20 @@ void smbdirect_socket_destroy_sync(struct smbdirect_socket *sc)
600600
*/
601601
WARN_ON_ONCE(in_interrupt());
602602

603-
smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
604-
"cancelling and disable disconnect_work\n");
605-
disable_work_sync(&sc->disconnect_work);
603+
/*
604+
* First we try to disable the work
605+
* without disable_work_sync() in a
606+
* non blocking way, if it's already
607+
* running it will be handles by
608+
* disable_work_sync() below.
609+
*
610+
* Here we just want to make sure queue_work() in
611+
* smbdirect_socket_schedule_cleanup_lvl()
612+
* is a no-op.
613+
*/
614+
disable_work(&sc->disconnect_work);
606615

607-
smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
608-
"destroying rdma session\n");
609-
if (sc->status < SMBDIRECT_SOCKET_DISCONNECTING) {
616+
if (!sc->first_error)
610617
/*
611618
* SMBDIRECT_LOG_INFO is enough here
612619
* as this is the typical case where
@@ -615,8 +622,15 @@ void smbdirect_socket_destroy_sync(struct smbdirect_socket *sc)
615622
smbdirect_socket_schedule_cleanup_lvl(sc,
616623
SMBDIRECT_LOG_INFO,
617624
-ESHUTDOWN);
625+
626+
smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
627+
"cancelling and disable disconnect_work\n");
628+
disable_work_sync(&sc->disconnect_work);
629+
630+
smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
631+
"destroying rdma session\n");
632+
if (sc->status < SMBDIRECT_SOCKET_DISCONNECTING)
618633
smbdirect_socket_cleanup_work(&sc->disconnect_work);
619-
}
620634
if (sc->status < SMBDIRECT_SOCKET_DISCONNECTED) {
621635
smbdirect_log_rdma_event(sc, SMBDIRECT_LOG_INFO,
622636
"wait for transport being disconnected\n");

0 commit comments

Comments
 (0)