diff options
Diffstat (limited to 'sys/cam/scsi/scsi_da.c')
-rw-r--r-- | sys/cam/scsi/scsi_da.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index ae80b65..8d0f35e 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -89,7 +89,8 @@ typedef enum { DA_FLAG_OPEN = 0x100, DA_FLAG_SCTX_INIT = 0x200, DA_FLAG_CAN_RC16 = 0x400, - DA_FLAG_PROBED = 0x800 + DA_FLAG_PROBED = 0x800, + DA_FLAG_DIRTY = 0x1000 } da_flags; typedef enum { @@ -1237,6 +1238,7 @@ daclose(struct disk *dp) { struct cam_periph *periph; struct da_softc *softc; + int error; periph = (struct cam_periph *)dp->d_drv1; cam_periph_lock(periph); @@ -1251,8 +1253,9 @@ daclose(struct disk *dp) CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH, ("daclose\n")); - if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0 - && (softc->flags & DA_FLAG_PACK_INVALID) == 0) { + if ((softc->flags & DA_FLAG_DIRTY) != 0 && + (softc->quirks & DA_Q_NO_SYNC_CACHE) == 0 && + (softc->flags & DA_FLAG_PACK_INVALID) == 0) { union ccb *ccb; ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL); @@ -1266,9 +1269,11 @@ daclose(struct disk *dp) SSD_FULL_SIZE, 5 * 60 * 1000); - cam_periph_runccb(ccb, daerror, /*cam_flags*/0, + error = cam_periph_runccb(ccb, daerror, /*cam_flags*/0, /*sense_flags*/SF_RETRY_UA | SF_QUIET_IR, softc->disk->d_devstat); + if (error == 0) + softc->flags &= ~DA_FLAG_DIRTY; xpt_release_ccb(ccb); } @@ -2240,8 +2245,10 @@ skipstate: } switch (bp->bio_cmd) { - case BIO_READ: case BIO_WRITE: + softc->flags |= DA_FLAG_DIRTY; + /* FALLTHROUGH */ + case BIO_READ: scsi_read_write(&start_ccb->csio, /*retries*/da_retry_count, /*cbfcnp*/dadone, |