diff options
author | Christoph Hellwig <hch@lst.de> | 2017-04-05 13:21:03 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-04-08 13:25:38 -0400 |
commit | 3deff1a70d5901342f460f8cc36e5d0c5d51c319 (patch) | |
tree | a74cc58c2a3105a9505028c87f8991378979e33c /drivers/md | |
parent | 02d261034f1c90ac8b052406bd7b18d2564b0b3c (diff) |
md: support REQ_OP_WRITE_ZEROES
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>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/linear.c | 1 | ||||
-rw-r--r-- | drivers/md/md.h | 7 | ||||
-rw-r--r-- | drivers/md/multipath.c | 1 | ||||
-rw-r--r-- | drivers/md/raid0.c | 2 | ||||
-rw-r--r-- | drivers/md/raid1.c | 4 | ||||
-rw-r--r-- | drivers/md/raid10.c | 1 | ||||
-rw-r--r-- | drivers/md/raid5.c | 1 |
7 files changed, 16 insertions, 1 deletions
diff --git a/drivers/md/linear.c b/drivers/md/linear.c index 3e38e0207a3e..377a8a3672e3 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c | |||
@@ -293,6 +293,7 @@ static void linear_make_request(struct mddev *mddev, struct bio *bio) | |||
293 | split, disk_devt(mddev->gendisk), | 293 | split, disk_devt(mddev->gendisk), |
294 | bio_sector); | 294 | bio_sector); |
295 | mddev_check_writesame(mddev, split); | 295 | mddev_check_writesame(mddev, split); |
296 | mddev_check_write_zeroes(mddev, split); | ||
296 | generic_make_request(split); | 297 | generic_make_request(split); |
297 | } | 298 | } |
298 | } while (split != bio); | 299 | } while (split != bio); |
diff --git a/drivers/md/md.h b/drivers/md/md.h index dde8ecb760c8..1e76d64ce180 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -709,4 +709,11 @@ static inline void mddev_check_writesame(struct mddev *mddev, struct bio *bio) | |||
709 | !bdev_get_queue(bio->bi_bdev)->limits.max_write_same_sectors) | 709 | !bdev_get_queue(bio->bi_bdev)->limits.max_write_same_sectors) |
710 | mddev->queue->limits.max_write_same_sectors = 0; | 710 | mddev->queue->limits.max_write_same_sectors = 0; |
711 | } | 711 | } |
712 | |||
713 | static inline void mddev_check_write_zeroes(struct mddev *mddev, struct bio *bio) | ||
714 | { | ||
715 | if (bio_op(bio) == REQ_OP_WRITE_ZEROES && | ||
716 | !bdev_get_queue(bio->bi_bdev)->limits.max_write_zeroes_sectors) | ||
717 | mddev->queue->limits.max_write_zeroes_sectors = 0; | ||
718 | } | ||
712 | #endif /* _MD_MD_H */ | 719 | #endif /* _MD_MD_H */ |
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index 79a12b59250b..e95d521d93e9 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c | |||
@@ -139,6 +139,7 @@ static void multipath_make_request(struct mddev *mddev, struct bio * bio) | |||
139 | mp_bh->bio.bi_end_io = multipath_end_request; | 139 | mp_bh->bio.bi_end_io = multipath_end_request; |
140 | mp_bh->bio.bi_private = mp_bh; | 140 | mp_bh->bio.bi_private = mp_bh; |
141 | mddev_check_writesame(mddev, &mp_bh->bio); | 141 | mddev_check_writesame(mddev, &mp_bh->bio); |
142 | mddev_check_write_zeroes(mddev, &mp_bh->bio); | ||
142 | generic_make_request(&mp_bh->bio); | 143 | generic_make_request(&mp_bh->bio); |
143 | return; | 144 | return; |
144 | } | 145 | } |
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 93347ca7c7a6..ce7a6a56cf73 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -383,6 +383,7 @@ static int raid0_run(struct mddev *mddev) | |||
383 | 383 | ||
384 | blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors); | 384 | blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors); |
385 | blk_queue_max_write_same_sectors(mddev->queue, mddev->chunk_sectors); | 385 | blk_queue_max_write_same_sectors(mddev->queue, mddev->chunk_sectors); |
386 | blk_queue_max_write_zeroes_sectors(mddev->queue, mddev->chunk_sectors); | ||
386 | blk_queue_max_discard_sectors(mddev->queue, mddev->chunk_sectors); | 387 | blk_queue_max_discard_sectors(mddev->queue, mddev->chunk_sectors); |
387 | 388 | ||
388 | blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9); | 389 | 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) | |||
504 | split, disk_devt(mddev->gendisk), | 505 | split, disk_devt(mddev->gendisk), |
505 | bio_sector); | 506 | bio_sector); |
506 | mddev_check_writesame(mddev, split); | 507 | mddev_check_writesame(mddev, split); |
508 | mddev_check_write_zeroes(mddev, split); | ||
507 | generic_make_request(split); | 509 | generic_make_request(split); |
508 | } | 510 | } |
509 | } while (split != bio); | 511 | } while (split != bio); |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index a34f58772022..b59cc100320a 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -3177,8 +3177,10 @@ static int raid1_run(struct mddev *mddev) | |||
3177 | if (IS_ERR(conf)) | 3177 | if (IS_ERR(conf)) |
3178 | return PTR_ERR(conf); | 3178 | return PTR_ERR(conf); |
3179 | 3179 | ||
3180 | if (mddev->queue) | 3180 | if (mddev->queue) { |
3181 | blk_queue_max_write_same_sectors(mddev->queue, 0); | 3181 | blk_queue_max_write_same_sectors(mddev->queue, 0); |
3182 | blk_queue_max_write_zeroes_sectors(mddev->queue, 0); | ||
3183 | } | ||
3182 | 3184 | ||
3183 | rdev_for_each(rdev, mddev) { | 3185 | rdev_for_each(rdev, mddev) { |
3184 | if (!mddev->gendisk) | 3186 | if (!mddev->gendisk) |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index e89a8d78a9ed..28ec3a93acee 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -3749,6 +3749,7 @@ static int raid10_run(struct mddev *mddev) | |||
3749 | blk_queue_max_discard_sectors(mddev->queue, | 3749 | blk_queue_max_discard_sectors(mddev->queue, |
3750 | mddev->chunk_sectors); | 3750 | mddev->chunk_sectors); |
3751 | blk_queue_max_write_same_sectors(mddev->queue, 0); | 3751 | blk_queue_max_write_same_sectors(mddev->queue, 0); |
3752 | blk_queue_max_write_zeroes_sectors(mddev->queue, 0); | ||
3752 | blk_queue_io_min(mddev->queue, chunk_size); | 3753 | blk_queue_io_min(mddev->queue, chunk_size); |
3753 | if (conf->geo.raid_disks % conf->geo.near_copies) | 3754 | if (conf->geo.raid_disks % conf->geo.near_copies) |
3754 | blk_queue_io_opt(mddev->queue, chunk_size * conf->geo.raid_disks); | 3755 | blk_queue_io_opt(mddev->queue, chunk_size * conf->geo.raid_disks); |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 7aeb9691c2e1..1725a54042bb 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -7270,6 +7270,7 @@ static int raid5_run(struct mddev *mddev) | |||
7270 | mddev->queue->limits.discard_zeroes_data = 0; | 7270 | mddev->queue->limits.discard_zeroes_data = 0; |
7271 | 7271 | ||
7272 | blk_queue_max_write_same_sectors(mddev->queue, 0); | 7272 | blk_queue_max_write_same_sectors(mddev->queue, 0); |
7273 | blk_queue_max_write_zeroes_sectors(mddev->queue, 0); | ||
7273 | 7274 | ||
7274 | rdev_for_each(rdev, mddev) { | 7275 | rdev_for_each(rdev, mddev) { |
7275 | disk_stack_limits(mddev->gendisk, rdev->bdev, | 7276 | disk_stack_limits(mddev->gendisk, rdev->bdev, |