Author: mav
Date: Tue Jan 21 00:22:08 2014
New Revision: 260962
URL: http://svnweb.freebsd.org/changeset/base/260962

Log:
  MFC r256836:
  Remove hard limit on number of BIOs handled with one ATA TRIM request.

Modified:
  stable/9/sys/cam/ata/ata_da.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/sys/cam/ata/ata_da.c
==============================================================================
--- stable/9/sys/cam/ata/ata_da.c       Tue Jan 21 00:16:41 2014        
(r260961)
+++ stable/9/sys/cam/ata/ata_da.c       Tue Jan 21 00:22:08 2014        
(r260962)
@@ -124,10 +124,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 {
@@ -1424,10 +1423,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;
@@ -1470,10 +1470,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)
@@ -1762,23 +1761,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);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "[email protected]"

Reply via email to