Author: mav
Date: Mon Oct 21 08:57:27 2013
New Revision: 256836
URL: http://svnweb.freebsd.org/changeset/base/256836

Log:
  MFprojects/camlock:
  Remove hard limit on number of BIOs handled with one ATA TRIM request.

Modified:
  head/sys/cam/ata/ata_da.c

Modified: head/sys/cam/ata/ata_da.c
==============================================================================
--- head/sys/cam/ata/ata_da.c   Mon Oct 21 08:49:46 2013        (r256835)
+++ head/sys/cam/ata/ata_da.c   Mon Oct 21 08:57:27 2013        (r256836)
@@ -123,10 +123,9 @@ struct disk_params {
 
 #define TRIM_MAX_BLOCKS        8
 #define TRIM_MAX_RANGES        (TRIM_MAX_BLOCKS * ATA_DSM_BLK_RANGES)
-#define TRIM_MAX_BIOS  (TRIM_MAX_RANGES * 4)
 struct trim_request {
        uint8_t         data[TRIM_MAX_RANGES * ATA_DSM_RANGE_SIZE];
-       struct bio      *bps[TRIM_MAX_BIOS];
+       TAILQ_HEAD(, bio) bps;
 };
 
 struct ada_softc {
@@ -1427,10 +1426,11 @@ adastart(struct cam_periph *periph, unio
                        struct trim_request *req = &softc->trim_req;
                        struct bio *bp1;
                        uint64_t lastlba = (uint64_t)-1;
-                       int bps = 0, c, lastcount = 0, off, ranges = 0;
+                       int c, lastcount = 0, off, ranges = 0;
 
                        softc->trim_running = 1;
                        bzero(req, sizeof(*req));
+                       TAILQ_INIT(&req->bps);
                        bp1 = bp;
                        do {
                                uint64_t lba = bp1->bio_pblkno;
@@ -1473,10 +1473,9 @@ adastart(struct cam_periph *periph, unio
                                         */
                                }
                                lastlba = lba;
-                               req->bps[bps++] = bp1;
+                               TAILQ_INSERT_TAIL(&req->bps, bp1, bio_queue);
                                bp1 = bioq_first(&softc->trim_queue);
-                               if (bps >= TRIM_MAX_BIOS ||
-                                   bp1 == NULL ||
+                               if (bp1 == NULL ||
                                    bp1->bio_bcount / softc->params.secsize >
                                    (softc->trim_max_ranges - ranges) *
                                    ATA_DSM_RANGE_MAX)
@@ -1764,23 +1763,22 @@ adadone(struct cam_periph *periph, union
                if (softc->outstanding_cmds == 0)
                        softc->flags |= ADA_FLAG_WENT_IDLE;
                if (state == ADA_CCB_TRIM) {
-                       struct trim_request *req =
-                           (struct trim_request *)ataio->data_ptr;
-                       int i;
-
-                       for (i = 1; i < TRIM_MAX_BIOS && req->bps[i]; i++) {
-                               struct bio *bp1 = req->bps[i];
+                       TAILQ_HEAD(, bio) queue;
+                       struct bio *bp1;
 
-                               bp1->bio_error = bp->bio_error;
-                               if (bp->bio_flags & BIO_ERROR) {
+                       TAILQ_INIT(&queue);
+                       TAILQ_CONCAT(&queue, &softc->trim_req.bps, bio_queue);
+                       softc->trim_running = 0;
+                       while ((bp1 = TAILQ_FIRST(&queue)) != NULL) {
+                               TAILQ_REMOVE(&queue, bp1, bio_queue);
+                               bp1->bio_error = error;
+                               if (error != 0) {
                                        bp1->bio_flags |= BIO_ERROR;
                                        bp1->bio_resid = bp1->bio_bcount;
                                } else
                                        bp1->bio_resid = 0;
                                biodone(bp1);
                        }
-                       softc->trim_running = 0;
-                       biodone(bp);
                        adaschedule(periph);
                } else
                        biodone(bp);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to