[PATCH V7 22/24] block: enable multipage bvecs

From: Ming Lei
Date: Wed Jun 27 2018 - 08:50:32 EST


This patch pulls the trigger for multipage bvecs.

Now any request queue which supports queue cluster will see multipage
bvecs.

Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
---
block/bio.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 22c6c83a7c8b..1dc3361fd5f9 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -765,12 +765,23 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page,

if (bio->bi_vcnt > 0) {
struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
-
- if (page == bv->bv_page && off == bv->bv_offset + bv->bv_len) {
- bv->bv_len += len;
- bio->bi_iter.bi_size += len;
- return true;
- }
+ struct request_queue *q = NULL;
+
+ if (page == bv->bv_page && off == bv->bv_offset + bv->bv_len)
+ goto merge;
+
+ if (bio->bi_disk)
+ q = bio->bi_disk->queue;
+
+ /* disable multipage bvec too if cluster isn't enabled */
+ if (!q || !blk_queue_cluster(q) ||
+ (bvec_to_phys(bv) + bv->bv_len !=
+ page_to_phys(page) + off))
+ return false;
+ merge:
+ bv->bv_len += len;
+ bio->bi_iter.bi_size += len;
+ return true;
}
return false;
}
--
2.9.5