Skip to content

Commit 8f4e80d

Browse files
Ming Leiaxboe
authored andcommitted
block: bounce: make sure that bvec table is updated
Block bounce needs to allocate new page for doing IO, and the new page has to be updated to bvec table. Commit 6dc4f10 switches __blk_queue_bounce() to use the new bio_for_each_segment_all() interface. Unfortunately the new bio_for_each_segment_all() can't be used to update bvec table. This patch fixes this issue by retrieving bvec from the table directly, then the new allocated page can be updated to the bio. This way is safe because the cloned bio is single page bvec. Fixes: 6dc4f10 ("block: allow bio_for_each_segment_all() to iterate over multi-page bvec") Cc: Christoph Hellwig <hch@lst.de> Cc: Omar Sandoval <osandov@fb.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 037b262 commit 8f4e80d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

block/bounce.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
295295
bool bounce = false;
296296
int sectors = 0;
297297
bool passthrough = bio_is_passthrough(*bio_orig);
298-
struct bvec_iter_all iter_all;
299298

300299
bio_for_each_segment(from, *bio_orig, iter) {
301300
if (i++ < BIO_MAX_PAGES)
@@ -315,7 +314,12 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
315314
bio = bounce_clone_bio(*bio_orig, GFP_NOIO, passthrough ? NULL :
316315
&bounce_bio_set);
317316

318-
bio_for_each_segment_all(to, bio, i, iter_all) {
317+
/*
318+
* Bvec table can't be updated by bio_for_each_segment_all(),
319+
* so retrieve bvec from the table directly. This way is safe
320+
* because the 'bio' is single-page bvec.
321+
*/
322+
for (i = 0, to = bio->bi_io_vec; i < bio->bi_vcnt; to++, i++) {
319323
struct page *page = to->bv_page;
320324

321325
if (page_to_pfn(page) <= q->limits.bounce_pfn)

0 commit comments

Comments
 (0)