block: have drivers use blk_queue_max_discard_sectors()
authorJens Axboe <axboe@fb.com>
Tue, 14 Jul 2015 14:15:12 +0000 (08:15 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 17 Jul 2015 14:41:53 +0000 (08:41 -0600)
Some drivers use it now, others just set the limits field manually.
But in preparation for splitting this into a hard and soft limit,
ensure that they all call the proper function for setting the hw
limit for discards.

Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
12 files changed:
drivers/block/brd.c
drivers/block/drbd/drbd_nl.c
drivers/block/loop.c
drivers/block/nbd.c
drivers/block/nvme-core.c
drivers/block/rbd.c
drivers/block/skd_main.c
drivers/block/zram/zram_drv.c
drivers/md/bcache/super.c
drivers/mmc/card/queue.c
drivers/mtd/mtd_blkdevs.c
drivers/scsi/sd.c

index 64ab4951e9d678f737423439bce5fce7b28f72fc..e573e470bd8ab037ad35ee6b64c34e3d4b6d9425 100644 (file)
@@ -500,7 +500,7 @@ static struct brd_device *brd_alloc(int i)
        blk_queue_physical_block_size(brd->brd_queue, PAGE_SIZE);
 
        brd->brd_queue->limits.discard_granularity = PAGE_SIZE;
-       brd->brd_queue->limits.max_discard_sectors = UINT_MAX;
+       blk_queue_max_discard_sectors(brd->brd_queue, UINT_MAX);
        brd->brd_queue->limits.discard_zeroes_data = 1;
        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, brd->brd_queue);
 
index 74df8cfad414f7242a1354c4c34fd4d8273d74ca..e80cbefbc2b548761fe5f531773b1022a21353eb 100644 (file)
@@ -1156,14 +1156,14 @@ static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backi
                        /* For now, don't allow more than one activity log extent worth of data
                         * to be discarded in one go. We may need to rework drbd_al_begin_io()
                         * to allow for even larger discard ranges */
-                       q->limits.max_discard_sectors = DRBD_MAX_DISCARD_SECTORS;
+                       blk_queue_max_discard_sectors(q, DRBD_MAX_DISCARD_SECTORS);
 
                        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
                        /* REALLY? Is stacking secdiscard "legal"? */
                        if (blk_queue_secdiscard(b))
                                queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD, q);
                } else {
-                       q->limits.max_discard_sectors = 0;
+                       blk_queue_max_discard_sectors(q, 0);
                        queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q);
                        queue_flag_clear_unlocked(QUEUE_FLAG_SECDISCARD, q);
                }
index f7a4c9d7f721816666a76e2d667adf9153e162e9..f9889b6bc02c316bed46e130c9f5c7ce38b7b93b 100644 (file)
@@ -675,7 +675,7 @@ static void loop_config_discard(struct loop_device *lo)
            lo->lo_encrypt_key_size) {
                q->limits.discard_granularity = 0;
                q->limits.discard_alignment = 0;
-               q->limits.max_discard_sectors = 0;
+               blk_queue_max_discard_sectors(q, 0);
                q->limits.discard_zeroes_data = 0;
                queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q);
                return;
@@ -683,7 +683,7 @@ static void loop_config_discard(struct loop_device *lo)
 
        q->limits.discard_granularity = inode->i_sb->s_blocksize;
        q->limits.discard_alignment = 0;
-       q->limits.max_discard_sectors = UINT_MAX >> 9;
+       blk_queue_max_discard_sectors(q, UINT_MAX >> 9);
        q->limits.discard_zeroes_data = 1;
        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
 }
index 0e385d8e9b86ec1f2d6be66b26107acf90a939d2..f169faf9838a74f83136379f0528fe3ae30976aa 100644 (file)
@@ -822,7 +822,7 @@ static int __init nbd_init(void)
                queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue);
                queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, disk->queue);
                disk->queue->limits.discard_granularity = 512;
-               disk->queue->limits.max_discard_sectors = UINT_MAX;
+               blk_queue_max_discard_sectors(disk->queue, UINT_MAX);
                disk->queue->limits.discard_zeroes_data = 0;
                blk_queue_max_hw_sectors(disk->queue, 65536);
                disk->queue->limits.max_sectors = 256;
index 7920c2741b47d436b2ef37e99019f33938f2db04..d844ec4a2b85eead7eaf781fe52421f9ba5d9cac 100644 (file)
@@ -1935,7 +1935,7 @@ static void nvme_config_discard(struct nvme_ns *ns)
        ns->queue->limits.discard_zeroes_data = 0;
        ns->queue->limits.discard_alignment = logical_block_size;
        ns->queue->limits.discard_granularity = logical_block_size;
-       ns->queue->limits.max_discard_sectors = 0xffffffff;
+       blk_queue_max_discard_sectors(ns->queue, 0xffffffff);
        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, ns->queue);
 }
 
index d94529d5c8e951378eaf62d74b708edf271a550f..dcc86937f55ca323184c89d27db2e25d60c59493 100644 (file)
@@ -3803,7 +3803,7 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
        q->limits.discard_granularity = segment_size;
        q->limits.discard_alignment = segment_size;
-       q->limits.max_discard_sectors = segment_size / SECTOR_SIZE;
+       blk_queue_max_discard_sectors(q, segment_size / SECTOR_SIZE);
        q->limits.discard_zeroes_data = 1;
 
        blk_queue_merge_bvec(q, rbd_merge_bvec);
index 1e46eb2305c04a8e63e378befb95a905fdf01850..586f9168ffa4828def11d1cfed6526f8ec8ab05f 100644 (file)
@@ -4422,7 +4422,7 @@ static int skd_cons_disk(struct skd_device *skdev)
        /* DISCARD Flag initialization. */
        q->limits.discard_granularity = 8192;
        q->limits.discard_alignment = 0;
-       q->limits.max_discard_sectors = UINT_MAX >> 9;
+       blk_queue_max_discard_sectors(q, UINT_MAX >> 9);
        q->limits.discard_zeroes_data = 1;
        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
        queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
index fb655e8d1e3b17bf4cda9fd09593bc7dc770f78d..f439ad2800da935dcb4158171c0c679037ba91e2 100644 (file)
@@ -1244,7 +1244,7 @@ static int zram_add(void)
        blk_queue_io_min(zram->disk->queue, PAGE_SIZE);
        blk_queue_io_opt(zram->disk->queue, PAGE_SIZE);
        zram->disk->queue->limits.discard_granularity = PAGE_SIZE;
-       zram->disk->queue->limits.max_discard_sectors = UINT_MAX;
+       blk_queue_max_discard_sectors(zram->disk->queue, UINT_MAX);
        /*
         * zram_bio_discard() will clear all logical blocks if logical block
         * size is identical with physical block size(PAGE_SIZE). But if it is
index 94980bfca43473c5ad141171300d71f6bd5cae55..fc8e545ced1840120dbd70b5845667aad16fd2b7 100644 (file)
@@ -830,7 +830,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
        q->limits.max_sectors           = UINT_MAX;
        q->limits.max_segment_size      = UINT_MAX;
        q->limits.max_segments          = BIO_MAX_PAGES;
-       q->limits.max_discard_sectors   = UINT_MAX;
+       blk_queue_max_discard_sectors(q, UINT_MAX);
        q->limits.discard_granularity   = 512;
        q->limits.io_min                = block_size;
        q->limits.logical_block_size    = block_size;
index b5a2b145d89f6b32c42c67e25cc029c1ef6744ea..5daf302835b1e8c9a98ccff15acae3306143bd69 100644 (file)
@@ -165,7 +165,7 @@ static void mmc_queue_setup_discard(struct request_queue *q,
                return;
 
        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
-       q->limits.max_discard_sectors = max_discard;
+       blk_queue_max_discard_sectors(q, max_discard);
        if (card->erased_byte == 0 && !mmc_can_discard(card))
                q->limits.discard_zeroes_data = 1;
        q->limits.discard_granularity = card->pref_erase << 9;
index 41acc507b22ed942bee2f0df6f43dda073efeb99..1b96cf771d2b53bf50d692b6cd7a53bf5ebf2d8f 100644 (file)
@@ -423,7 +423,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 
        if (tr->discard) {
                queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, new->rq);
-               new->rq->limits.max_discard_sectors = UINT_MAX;
+               blk_queue_max_discard_sectors(new->rq, UINT_MAX);
        }
 
        gd->queue = new->rq;
index 3b2fcb4fada0491c4500b42555fdef542b4399d2..160e44e7b24a215ddad5b98c925385a58535c74a 100644 (file)
@@ -647,7 +647,7 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
        switch (mode) {
 
        case SD_LBP_DISABLE:
-               q->limits.max_discard_sectors = 0;
+               blk_queue_max_discard_sectors(q, 0);
                queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, q);
                return;
 
@@ -675,7 +675,7 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
                break;
        }
 
-       q->limits.max_discard_sectors = max_blocks * (logical_block_size >> 9);
+       blk_queue_max_discard_sectors(q, max_blocks * (logical_block_size >> 9));
        queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
 }