Skip to content

Commit baa2c7c

Browse files
Ming Leiaxboe
Ming Lei
authored andcommitted
block: set .bi_max_vecs as actual allocated vector number
bvec_alloc() may allocate more bio vectors than requested, so set .bi_max_vecs as actual allocated vector number, instead of the requested number. This way can help fs build bigger bio because new bio often won't be allocated until the current one becomes full. Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Ming Lei <[email protected]> Reviewed-by: Pavel Begunkov <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 9f180e3 commit baa2c7c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

block/bio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,13 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs,
505505
goto err_free;
506506

507507
bio->bi_flags |= idx << BVEC_POOL_OFFSET;
508+
bio->bi_max_vecs = bvec_nr_vecs(idx);
508509
} else if (nr_iovecs) {
509510
bvl = bio->bi_inline_vecs;
511+
bio->bi_max_vecs = inline_vecs;
510512
}
511513

512514
bio->bi_pool = bs;
513-
bio->bi_max_vecs = nr_iovecs;
514515
bio->bi_io_vec = bvl;
515516
return bio;
516517

0 commit comments

Comments
 (0)