git: 15e0215800fb - stable/13 - cam: don't send scsi commands on shutdown when reboot method RB_NOSYNC

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Sat, 23 Apr 2022 23:03:44 UTC
The branch stable/13 has been updated by mav:

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

commit 15e0215800fbda50e841d6f94d7dfc853174941b
Author:     Wojciech Macek <wma@FreeBSD.org>
AuthorDate: 2021-12-20 05:32:51 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-04-23 23:03:22 +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
    
    (cherry picked from commit e0ceec676dc86ddca960a9858ae5e3a4e0c8390d)
---
 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 8b1e1c0e0d46..a8a7e34bf6f0 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>
@@ -6241,6 +6242,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()) {