[Midnightbsd-cvs] src [9123] trunk/sys/cam: make pre-shutdown flush and spindown routines to not use xpt_polled_action.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Oct 1 20:37:13 EDT 2016


Revision: 9123
          http://svnweb.midnightbsd.org/src/?rev=9123
Author:   laffer1
Date:     2016-10-01 20:37:13 -0400 (Sat, 01 Oct 2016)
Log Message:
-----------
make pre-shutdown flush and spindown routines to not use xpt_polled_action.

Modified Paths:
--------------
    trunk/sys/cam/ata/ata_da.c
    trunk/sys/cam/scsi/scsi_da.c

Modified: trunk/sys/cam/ata/ata_da.c
===================================================================
--- trunk/sys/cam/ata/ata_da.c	2016-10-02 00:36:37 UTC (rev 9122)
+++ trunk/sys/cam/ata/ata_da.c	2016-10-02 00:37:13 UTC (rev 9123)
@@ -1971,11 +1971,10 @@
 {
 	struct cam_periph *periph;
 	struct ada_softc *softc;
+	union ccb *ccb;
 	int error;
 
 	CAM_PERIPH_FOREACH(periph, &adadriver) {
-		union ccb ccb;
-
 		/* If we paniced with lock held - not recurse here. */
 		if (cam_periph_owned(periph))
 			continue;
@@ -1991,10 +1990,8 @@
 			continue;
 		}
 
-		xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
-
-		ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
-		cam_fill_ataio(&ccb.ataio,
+		ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
+		cam_fill_ataio(&ccb->ataio,
 				    0,
 				    adadone,
 				    CAM_DIR_NONE,
@@ -2002,20 +1999,17 @@
 				    NULL,
 				    0,
 				    ada_default_timeout*1000);
-
 		if (softc->flags & ADA_FLAG_CAN_48BIT)
-			ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE48, 0, 0, 0);
+			ata_48bit_cmd(&ccb->ataio, ATA_FLUSHCACHE48, 0, 0, 0);
 		else
-			ata_28bit_cmd(&ccb.ataio, ATA_FLUSHCACHE, 0, 0, 0);
-		xpt_polled_action(&ccb);
+			ata_28bit_cmd(&ccb->ataio, ATA_FLUSHCACHE, 0, 0, 0);
 
-		error = cam_periph_error(&ccb,
-		    0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
-		if ((ccb.ccb_h.status & CAM_DEV_QFRZN) != 0)
-			cam_release_devq(ccb.ccb_h.path, /*relsim_flags*/0,
-			    /*reduction*/0, /*timeout*/0, /*getcount_only*/0);
+		error = cam_periph_runccb(ccb, adaerror, /*cam_flags*/0,
+		    /*sense_flags*/ SF_NO_RECOVERY | SF_NO_RETRY,
+		    softc->disk->d_devstat);
 		if (error != 0)
 			xpt_print(periph->path, "Synchronize cache failed\n");
+		xpt_release_ccb(ccb);
 		cam_periph_unlock(periph);
 	}
 }
@@ -2025,11 +2019,10 @@
 {
 	struct cam_periph *periph;
 	struct ada_softc *softc;
+	union ccb *ccb;
 	int error;
 
 	CAM_PERIPH_FOREACH(periph, &adadriver) {
-		union ccb ccb;
-
 		/* If we paniced with lock held - not recurse here. */
 		if (cam_periph_owned(periph))
 			continue;
@@ -2046,10 +2039,8 @@
 		if (bootverbose)
 			xpt_print(periph->path, "spin-down\n");
 
-		xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
-
-		ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
-		cam_fill_ataio(&ccb.ataio,
+		ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
+		cam_fill_ataio(&ccb->ataio,
 				    0,
 				    adadone,
 				    CAM_DIR_NONE | flags,
@@ -2057,17 +2048,14 @@
 				    NULL,
 				    0,
 				    ada_default_timeout*1000);
+		ata_28bit_cmd(&ccb->ataio, cmd, 0, 0, 0);
 
-		ata_28bit_cmd(&ccb.ataio, cmd, 0, 0, 0);
-		xpt_polled_action(&ccb);
-
-		error = cam_periph_error(&ccb,
-		    0, SF_NO_RECOVERY | SF_NO_RETRY, NULL);
-		if ((ccb.ccb_h.status & CAM_DEV_QFRZN) != 0)
-			cam_release_devq(ccb.ccb_h.path, /*relsim_flags*/0,
-			    /*reduction*/0, /*timeout*/0, /*getcount_only*/0);
+		error = cam_periph_runccb(ccb, adaerror, /*cam_flags*/0,
+		    /*sense_flags*/ SF_NO_RECOVERY | SF_NO_RETRY,
+		    softc->disk->d_devstat);
 		if (error != 0)
 			xpt_print(periph->path, "Spin-down disk failed\n");
+		xpt_release_ccb(ccb);
 		cam_periph_unlock(periph);
 	}
 }

Modified: trunk/sys/cam/scsi/scsi_da.c
===================================================================
--- trunk/sys/cam/scsi/scsi_da.c	2016-10-02 00:36:37 UTC (rev 9122)
+++ trunk/sys/cam/scsi/scsi_da.c	2016-10-02 00:37:13 UTC (rev 9123)
@@ -2834,11 +2834,10 @@
 {
 	struct cam_periph *periph;
 	struct da_softc *softc;
+	union ccb *ccb;
 	int error;
 
 	CAM_PERIPH_FOREACH(periph, &dadriver) {
-		union ccb ccb;
-
 		cam_periph_lock(periph);
 		softc = (struct da_softc *)periph->softc;
 
@@ -2852,10 +2851,8 @@
 			continue;
 		}
 
-		xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
-
-		ccb.ccb_h.ccb_state = DA_CCB_DUMP;
-		scsi_synchronize_cache(&ccb.csio,
+		ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
+		scsi_synchronize_cache(&ccb->csio,
 				       /*retries*/0,
 				       /*cbfcnp*/dadone,
 				       MSG_SIMPLE_Q_TAG,
@@ -2864,15 +2861,12 @@
 				       SSD_FULL_SIZE,
 				       60 * 60 * 1000);
 
-		xpt_polled_action(&ccb);
-
-		error = cam_periph_error(&ccb,
-		    0, SF_NO_RECOVERY | SF_NO_RETRY | SF_QUIET_IR, NULL);
-		if ((ccb.ccb_h.status & CAM_DEV_QFRZN) != 0)
-			cam_release_devq(ccb.ccb_h.path, /*relsim_flags*/0,
-			    /*reduction*/0, /*timeout*/0, /*getcount_only*/0);
+		error = cam_periph_runccb(ccb, daerror, /*cam_flags*/0,
+		    /*sense_flags*/ SF_NO_RECOVERY | SF_NO_RETRY | SF_QUIET_IR,
+		    softc->disk->d_devstat);
 		if (error != 0)
 			xpt_print(periph->path, "Synchronize cache failed\n");
+		xpt_release_ccb(ccb);
 		cam_periph_unlock(periph);
 	}
 }



More information about the Midnightbsd-cvs mailing list