diff mbox

[v1,54/54] block: enable multipage bvecs

Message ID 1482854706-14128-23-git-send-email-tom.leiming@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ming Lei Dec. 27, 2016, 4:05 p.m. UTC
This patch pulls the trigger for multipage bvecs.

Any request queue which doesn't set QUEUE_FLAG_NO_MP
should support to handle multipage bvecs.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 block/bio.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox

Patch

diff --git a/block/bio.c b/block/bio.c
index 9acc3db0f2df..a2ad9c577aff 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -843,6 +843,11 @@  int bio_add_page(struct bio *bio, struct page *page,
 	 * a consecutive offset.  Optimize this special case.
 	 */
 	if (bio->bi_vcnt > 0) {
+		struct request_queue *q = NULL;
+
+		if (bio->bi_bdev)
+			q = bdev_get_queue(bio->bi_bdev);
+
 		bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
 
 		if (page == bv->bv_page &&
@@ -850,6 +855,14 @@  int bio_add_page(struct bio *bio, struct page *page,
 			bv->bv_len += len;
 			goto done;
 		}
+
+		/* disable multipage bvec too if cluster isn't enabled */
+		if (q && !blk_queue_no_mp(q) && blk_queue_cluster(q) &&
+		    (bvec_to_phys(bv) + bv->bv_len ==
+		     page_to_phys(page) + offset)) {
+			bv->bv_len += len;
+			goto done;
+		}
 	}
 
 	if (bio->bi_vcnt >= bio->bi_max_vecs)