FreeBSD/sys/cam/scsi/scsi_da.c
/*
 * Step through all DA peripheral drivers, and if the device is still open,
 * sync the disk cache to physical media.
 */
Step through all DA peripheral drivers, and if the device is still open,
sync the disk cache to physical media.
Step through all DA peripheral drivers and if the device is still open sync the disk cache to physical media .
static void
dashutdown(void * arg, int howto)
{
	struct cam_periph *periph;
	struct da_softc *softc;
	union ccb *ccb;
	int error;
	CAM_PERIPH_FOREACH(periph, &dadriver) {
		softc = (struct da_softc *)periph->softc;
		if (SCHEDULER_STOPPED()) {
			if (!cam_periph_owned(periph) &&
			    (softc->flags & DA_FLAG_OPEN)) {
				dadump(softc->disk, NULL, 0, 0, 0);
			}
			continue;
		}
		cam_periph_lock(periph);
		if (((softc->flags & DA_FLAG_OPEN) == 0)
		 || (softc->quirks & DA_Q_NO_SYNC_CACHE)) {
			cam_periph_unlock(periph);
			continue;
		}
		ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
		scsi_synchronize_cache(&ccb->csio,
				       0,
				       dadone,
				       MSG_SIMPLE_Q_TAG,
				       0, 
				       0,
				       SSD_FULL_SIZE,
				       60 * 60 * 1000);
		error = cam_periph_runccb(ccb, daerror, 0,
		     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);
	}
}
static void dashutdown ( void * arg , int howto ) { struct cam_periph * periph ; struct da_softc * softc ; union ccb * ccb ; int error ; CAM_PERIPH_FOREACH ( periph , & dadriver ) { softc = ( struct da_softc * ) periph -> softc ; if ( SCHEDULER_STOPPED ( ) ) { if ( ! cam_periph_owned ( periph ) && ( softc -> flags & DA_FLAG_OPEN ) ) { dadump ( softc -> disk , NULL , 0 , 0 , 0 ) ; } continue ; } cam_periph_lock ( periph ) ; if ( ( ( softc -> flags & DA_FLAG_OPEN ) == 0 ) || ( softc -> quirks & DA_Q_NO_SYNC_CACHE ) ) { cam_periph_unlock ( periph ) ; continue ; } ccb = cam_periph_getccb ( periph , CAM_PRIORITY_NORMAL ) ; scsi_synchronize_cache ( & ccb -> csio , 0 , dadone , MSG_SIMPLE_Q_TAG , 0 , 0 , SSD_FULL_SIZE , 60 * 60 * 1000 ) ; error = cam_periph_runccb ( ccb , daerror , 0 , SF_NO_RECOVERY | SF_NO_RETRY | SF_QUIET_IR , softc -> disk -> d_devstat ) ; if ( error != 0 ) xpt_print ( periph -> path , " \n " ) ; xpt_release_ccb ( ccb ) ; cam_periph_unlock ( periph ) ; } }
Step through all DA peripheral drivers, and if the device is still open,
 sync the disk cache to physical media.
Step through all DA peripheral drivers and if the device is still open sync the disk cache to physical media .
/* If we paniced with the lock held, do not recurse. */ /*
		 * We only sync the cache if the drive is still open, and
		 * if the drive is capable of it..
		 */ /*retries*/ /*cbfcnp*/ /*begin_lba*/ /* whole disk */ /*lb_count*/ /*cam_flags*/ /*sense_flags*/