da(4): Short-circuit unnecessary BIO_FLUSH commands

sys/cam/scsi/scsi_da.c
	Complete BIO_FLUSH commands immediately if the da(4) device hasn't
	been written to since the last flush. If we haven't written to the
	device, there is no reason to send a flush.

Submitted by:	gibbs
Reviewed by:	imp
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D13106
This commit is contained in:
Alan Somers 2017-11-20 22:27:33 +00:00
parent 114aedb30e
commit c95dc95b35
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=326036

View file

@ -3037,6 +3037,18 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
break;
}
case BIO_FLUSH:
/*
* If we don't support sync cache, or the disk
* isn't dirty, FLUSH is a no-op. Use the
* allocated * CCB for the next bio if one is
* available.
*/
if ((softc->quirks & DA_Q_NO_SYNC_CACHE) != 0 ||
(softc->flags & DA_FLAG_DIRTY) == 0) {
biodone(bp);
goto skipstate;
}
/*
* BIO_FLUSH doesn't currently communicate
* range data, so we synchronize the cache
@ -3052,6 +3064,15 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
/*lb_count*/0,
SSD_FULL_SIZE,
da_default_timeout*1000);
/*
* Clear the dirty flag before sending the command.
* Either this sync cache will be successful, or it
* will fail after a retry. If it fails, it is
* unlikely to be successful if retried later, so
* we'll save ourselves time by just marking the
* device clean.
*/
softc->flags &= ~DA_FLAG_DIRTY;
break;
case BIO_ZONE: {
int error, queue_ccb;