diff options
author | Christoph Hellwig <hch@lst.de> | 2017-02-08 14:46:49 +0100 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-02-08 13:43:08 -0700 |
commit | 1e739730c5b9ea80a2f25e9cf6e1025d47e3d8ed (patch) | |
tree | 4f48ed6c92153fb9941185182e918232eb3472f4 /block/blk-merge.c | |
parent | 34fe7c05400663e01e23cddd1fea68bb7a2b3d29 (diff) | |
download | linux-stable-1e739730c5b9ea80a2f25e9cf6e1025d47e3d8ed.tar.gz linux-stable-1e739730c5b9ea80a2f25e9cf6e1025d47e3d8ed.tar.bz2 linux-stable-1e739730c5b9ea80a2f25e9cf6e1025d47e3d8ed.zip |
block: optionally merge discontiguous discard bios into a single request
Add a new merge strategy that merges discard bios into a request until the
maximum number of discard ranges (or the maximum discard size) is reached
from the plug merging code. I/O scheduler merging is not wired up yet
but might also be useful, although not for fast devices like NVMe which
are the only user for now.
Note that for now we don't support limiting the size of each discard range,
but if needed that can be added later.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-merge.c')
-rw-r--r-- | block/blk-merge.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c index 6cbd90ad5f90..2afa262425d1 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -803,7 +803,10 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) enum elv_merge blk_try_merge(struct request *rq, struct bio *bio) { - if (blk_rq_pos(rq) + blk_rq_sectors(rq) == bio->bi_iter.bi_sector) + if (req_op(rq) == REQ_OP_DISCARD && + queue_max_discard_segments(rq->q) > 1) + return ELEVATOR_DISCARD_MERGE; + else if (blk_rq_pos(rq) + blk_rq_sectors(rq) == bio->bi_iter.bi_sector) return ELEVATOR_BACK_MERGE; else if (blk_rq_pos(rq) - bio_sectors(bio) == bio->bi_iter.bi_sector) return ELEVATOR_FRONT_MERGE; |