git: e0ceec676dc8 - main - cam: don't send scsi commands on shutdown when reboot method RB_NOSYNC

From: Wojciech Macek <wma_at_FreeBSD.org>
Date: Mon, 20 Dec 2021 05:34:31 UTC
The branch main has been updated by wma:

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

commit e0ceec676dc86ddca960a9858ae5e3a4e0c8390d
Author:     Wojciech Macek <wma@FreeBSD.org>
AuthorDate: 2021-12-20 05:32:51 +0000
Commit:     Wojciech Macek <wma@FreeBSD.org>
CommitDate: 2021-12-20 05:32:51 +0000

    cam: don't send scsi commands on shutdown when reboot method RB_NOSYNC
    
    Don't send the SCSI comand SYNCHRONIZE CACHE on devices that are still
    open when RB_NOSYNC is the reboot method. This may avoid recursive panics
    when doadump is called due to a SCSI/CAM/USB error/bug.
    
    Obtained from:          Semihalf
    Sponsored by:           Stormshield
    Reviewed by:            imp
    Differential revision:  https://reviews.freebsd.org/D31549
---
 sys/cam/scsi/scsi_da.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index 0bcbccc7eab9..243e86d18caa 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/cons.h>
 #include <sys/endian.h>
 #include <sys/proc.h>
+#include <sys/reboot.h>
 #include <sys/sbuf.h>
 #include <geom/geom.h>
 #include <geom/geom_disk.h>
@@ -6245,6 +6246,9 @@ dashutdown(void * arg, int howto)
 	union ccb *ccb;
 	int error;
 
+	if ((howto & RB_NOSYNC) != 0)
+		return;
+
 	CAM_PERIPH_FOREACH(periph, &dadriver) {
 		softc = (struct da_softc *)periph->softc;
 		if (SCHEDULER_STOPPED()) {