ee1deda
From 23688bf4f830a89866fd0ed3501e342a7360fe4f Mon Sep 17 00:00:00 2001
ee1deda
From: Junichi Nomura <j-nomura@ce.jp.nec.com>
ee1deda
Date: Tue, 22 Dec 2015 10:23:44 -0700
ee1deda
Subject: [PATCH] block: ensure to split after potentially bouncing a bio
ee1deda
ee1deda
blk_queue_bio() does split then bounce, which makes the segment
ee1deda
counting based on pages before bouncing and could go wrong. Move
ee1deda
the split to after bouncing, like we do for blk-mq, and the we
ee1deda
fix the issue of having the bio count for segments be wrong.
ee1deda
ee1deda
Fixes: 54efd50bfd87 ("block: make generic_make_request handle arbitrarily sized bios")
ee1deda
Cc: stable@vger.kernel.org
ee1deda
Tested-by: Artem S. Tashkinov <t.artem@lycos.com>
ee1deda
Signed-off-by: Jens Axboe <axboe@fb.com>
ee1deda
---
ee1deda
 block/blk-core.c | 4 ++--
ee1deda
 1 file changed, 2 insertions(+), 2 deletions(-)
ee1deda
ee1deda
diff --git a/block/blk-core.c b/block/blk-core.c
ee1deda
index 3636be469fa2..c487b94c59e3 100644
ee1deda
--- a/block/blk-core.c
ee1deda
+++ b/block/blk-core.c
ee1deda
@@ -1689,8 +1689,6 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio)
ee1deda
 	struct request *req;
ee1deda
 	unsigned int request_count = 0;
ee1deda
 
ee1deda
-	blk_queue_split(q, &bio, q->bio_split);
ee1deda
-
ee1deda
 	/*
ee1deda
 	 * low level driver can indicate that it wants pages above a
ee1deda
 	 * certain limit bounced to low memory (ie for highmem, or even
ee1deda
@@ -1698,6 +1696,8 @@ static blk_qc_t blk_queue_bio(struct request_queue *q, struct bio *bio)
ee1deda
 	 */
ee1deda
 	blk_queue_bounce(q, &bio;;
ee1deda
 
ee1deda
+	blk_queue_split(q, &bio, q->bio_split);
ee1deda
+
ee1deda
 	if (bio_integrity_enabled(bio) && bio_integrity_prep(bio)) {
ee1deda
 		bio->bi_error = -EIO;
ee1deda
 		bio_endio(bio);
ee1deda
-- 
ee1deda
2.5.0
ee1deda