git: 9732eb8eae72 - stable/14 - ctl_ha: don't shutdown threads if scheduler is stopped

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Fri, 08 Dec 2023 22:03:03 UTC
The branch stable/14 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=9732eb8eae7294a47cd64af5f11221792a984f71

commit 9732eb8eae7294a47cd64af5f11221792a984f71
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2023-11-23 15:25:54 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2023-12-08 22:02:44 +0000

    ctl_ha: don't shutdown threads if scheduler is stopped
    
    In this case, just return.
    
    Reviewed by:    markj
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D42341
    
    (cherry picked from commit 9d61fd08499609a2c95d1c66f97587932b446f06)
---
 sys/cam/ctl/ctl_ha.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/cam/ctl/ctl_ha.c b/sys/cam/ctl/ctl_ha.c
index 32c83025bb1b..1951f74c45f3 100644
--- a/sys/cam/ctl/ctl_ha.c
+++ b/sys/cam/ctl/ctl_ha.c
@@ -910,13 +910,16 @@ ctl_ha_msg_shutdown(struct ctl_softc *ctl_softc)
 {
 	struct ha_softc *softc = &ha_softc;
 
+	if (SCHEDULER_STOPPED())
+		return;
+
 	/* Disconnect and shutdown threads. */
 	mtx_lock(&softc->ha_lock);
 	if (softc->ha_shutdown < 2) {
 		softc->ha_shutdown = 1;
 		softc->ha_wakeup = 1;
 		wakeup(&softc->ha_wakeup);
-		while (softc->ha_shutdown < 2 && !SCHEDULER_STOPPED()) {
+		while (softc->ha_shutdown < 2) {
 			msleep(&softc->ha_wakeup, &softc->ha_lock, 0,
 			    "shutdown", hz);
 		}