From dbb3f5b28bfad6baa1aa590967d0e10b64979db6 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 5 Jun 2014 17:13:42 +0000 Subject: [PATCH] The code that combines adjacent ranges for BIO_DELETEs to optimize trims to the device assumes the list is sorted. Don't apply the optimization of not sorting the queue when we have SSDs to the delete_queue, since it causes more discard traffic to the drive. While one could argue that the higher levels should coalesce the trims, that's not done today, so some optimization at this level is needed. CR: https://phabric.freebsd.org/D142 --- sys/cam/ata/ata_da.c | 5 +---- sys/cam/scsi/scsi_da.c | 18 ++++-------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index c30be2d8113..7d0d272c0d6 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -729,10 +729,7 @@ adastrategy(struct bio *bp) */ if (bp->bio_cmd == BIO_DELETE && (softc->flags & ADA_FLAG_CAN_TRIM)) { - if (ADA_SIO) - bioq_disksort(&softc->trim_queue, bp); - else - bioq_insert_tail(&softc->trim_queue, bp); + bioq_disksort(&softc->trim_queue, bp); } else { if (ADA_SIO) bioq_disksort(&softc->bio_queue, bp); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index de2035323b3..1a075770203 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1383,10 +1383,7 @@ dastrategy(struct bio *bp) * Place it in the queue of disk activities for this disk */ if (bp->bio_cmd == BIO_DELETE) { - if (DA_SIO) - bioq_disksort(&softc->delete_queue, bp); - else - bioq_insert_tail(&softc->delete_queue, bp); + bioq_disksort(&softc->delete_queue, bp); } else if (DA_SIO) { bioq_disksort(&softc->bio_queue, bp); } else { @@ -2805,16 +2802,9 @@ cmd6workaround(union ccb *ccb) da_delete_method_desc[old_method], da_delete_method_desc[softc->delete_method]); - if (DA_SIO) { - while ((bp = bioq_takefirst(&softc->delete_run_queue)) - != NULL) - bioq_disksort(&softc->delete_queue, bp); - } else { - while ((bp = bioq_takefirst(&softc->delete_run_queue)) - != NULL) - bioq_insert_tail(&softc->delete_queue, bp); - } - bioq_insert_tail(&softc->delete_queue, + while ((bp = bioq_takefirst(&softc->delete_run_queue)) != NULL) + bioq_disksort(&softc->delete_queue, bp); + bioq_disksort(&softc->delete_queue, (struct bio *)ccb->ccb_h.ccb_bp); ccb->ccb_h.ccb_bp = NULL; return (0);