]> git.baikalelectronics.ru Git - kernel.git/commitdiff
md: support REQ_OP_WRITE_ZEROES
authorChristoph Hellwig <hch@lst.de>
Wed, 5 Apr 2017 17:21:03 +0000 (19:21 +0200)
committerJens Axboe <axboe@fb.com>
Sat, 8 Apr 2017 17:25:38 +0000 (11:25 -0600)
Copy & paste from the REQ_OP_WRITE_SAME code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/md/linear.c
drivers/md/md.h
drivers/md/multipath.c
drivers/md/raid0.c
drivers/md/raid1.c
drivers/md/raid10.c
drivers/md/raid5.c

index 3e38e0207a3eb44339ad6431dc3557ae27d05612..377a8a3672e3da107119cadaf6f8add62eca6f5b 100644 (file)
@@ -293,6 +293,7 @@ static void linear_make_request(struct mddev *mddev, struct bio *bio)
                                                      split, disk_devt(mddev->gendisk),
                                                      bio_sector);
                        mddev_check_writesame(mddev, split);
+                       mddev_check_write_zeroes(mddev, split);
                        generic_make_request(split);
                }
        } while (split != bio);
index dde8ecb760c87113ba36d50c0d6867bc6e215f02..1e76d64ce1803be229477fd83887514980390dee 100644 (file)
@@ -709,4 +709,11 @@ static inline void mddev_check_writesame(struct mddev *mddev, struct bio *bio)
            !bdev_get_queue(bio->bi_bdev)->limits.max_write_same_sectors)
                mddev->queue->limits.max_write_same_sectors = 0;
 }
+
+static inline void mddev_check_write_zeroes(struct mddev *mddev, struct bio *bio)
+{
+       if (bio_op(bio) == REQ_OP_WRITE_ZEROES &&
+           !bdev_get_queue(bio->bi_bdev)->limits.max_write_zeroes_sectors)
+               mddev->queue->limits.max_write_zeroes_sectors = 0;
+}
 #endif /* _MD_MD_H */
index 79a12b59250bbca870be857eb7cf350c0c9b53ad..e95d521d93e9b912caa561121593b2b7e54dd3a6 100644 (file)
@@ -139,6 +139,7 @@ static void multipath_make_request(struct mddev *mddev, struct bio * bio)
        mp_bh->bio.bi_end_io = multipath_end_request;
        mp_bh->bio.bi_private = mp_bh;
        mddev_check_writesame(mddev, &mp_bh->bio);
+       mddev_check_write_zeroes(mddev, &mp_bh->bio);
        generic_make_request(&mp_bh->bio);
        return;
 }
index 93347ca7c7a617e097ccafcbedbecdfa396d4968..ce7a6a56cf7385284bb702ab888e4f3ce2cf4821 100644 (file)
@@ -383,6 +383,7 @@ static int raid0_run(struct mddev *mddev)
 
                blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors);
                blk_queue_max_write_same_sectors(mddev->queue, mddev->chunk_sectors);
+               blk_queue_max_write_zeroes_sectors(mddev->queue, mddev->chunk_sectors);
                blk_queue_max_discard_sectors(mddev->queue, mddev->chunk_sectors);
 
                blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9);
@@ -504,6 +505,7 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio)
                                                      split, disk_devt(mddev->gendisk),
                                                      bio_sector);
                        mddev_check_writesame(mddev, split);
+                       mddev_check_write_zeroes(mddev, split);
                        generic_make_request(split);
                }
        } while (split != bio);
index a34f58772022c9f40243e1d117a3473332bd76a2..b59cc100320af206e5ef9fddec7ebb6ca7d054d7 100644 (file)
@@ -3177,8 +3177,10 @@ static int raid1_run(struct mddev *mddev)
        if (IS_ERR(conf))
                return PTR_ERR(conf);
 
-       if (mddev->queue)
+       if (mddev->queue) {
                blk_queue_max_write_same_sectors(mddev->queue, 0);
+               blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
+       }
 
        rdev_for_each(rdev, mddev) {
                if (!mddev->gendisk)
index e89a8d78a9ed537f417c414b2081ef5f9a97f291..28ec3a93aceeac962245fe2f9934296a284b5bac 100644 (file)
@@ -3749,6 +3749,7 @@ static int raid10_run(struct mddev *mddev)
                blk_queue_max_discard_sectors(mddev->queue,
                                              mddev->chunk_sectors);
                blk_queue_max_write_same_sectors(mddev->queue, 0);
+               blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
                blk_queue_io_min(mddev->queue, chunk_size);
                if (conf->geo.raid_disks % conf->geo.near_copies)
                        blk_queue_io_opt(mddev->queue, chunk_size * conf->geo.raid_disks);
index 7aeb9691c2e1c7c3180343a16eb759363aae9592..1725a54042bb26f92bb0355c664a3ce2a9c1aff7 100644 (file)
@@ -7270,6 +7270,7 @@ static int raid5_run(struct mddev *mddev)
                mddev->queue->limits.discard_zeroes_data = 0;
 
                blk_queue_max_write_same_sectors(mddev->queue, 0);
+               blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
 
                rdev_for_each(rdev, mddev) {
                        disk_stack_limits(mddev->gendisk, rdev->bdev,