git: 2ce1c45b3411 - main - iscsi: adjust shutdown_pre_sync handler

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 23 Nov 2023 16:08:02 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=2ce1c45b3411410a5d0a4d08198a3b0010d493b7

commit 2ce1c45b3411410a5d0a4d08198a3b0010d493b7
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-11-23 15:26:12 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-11-23 16:07:42 +0000

    iscsi: adjust shutdown_pre_sync handler
    
    Don't attempt to service reconnections if RB_NOSYNC is set. More
    crucially, don't do it if the scheduler is stopped, as the maintenance
    thread will never run again.
    
    Reviewed by:    jhb
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D42342
---
 sys/dev/iscsi/iscsi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c
index 311b339caf7a..38973898a9d1 100644
--- a/sys/dev/iscsi/iscsi.c
+++ b/sys/dev/iscsi/iscsi.c
@@ -44,6 +44,7 @@
 #include <sys/mbuf.h>
 #include <sys/mutex.h>
 #include <sys/module.h>
+#include <sys/proc.h>
 #include <sys/reboot.h>
 #include <sys/socket.h>
 #include <sys/sockopt.h>
@@ -2680,11 +2681,12 @@ iscsi_terminate_sessions(struct iscsi_softc *sc)
 }
 
 static void
-iscsi_shutdown_pre(struct iscsi_softc *sc)
+iscsi_shutdown_pre(struct iscsi_softc *sc, int howto)
 {
 	struct iscsi_session *is;
 
-	if (!fail_on_shutdown)
+	if (!fail_on_shutdown || (howto & RB_NOSYNC) != 0 ||
+	    SCHEDULER_STOPPED())
 		return;
 
 	/*