]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: set .bi_max_vecs as actual allocated vector number
authorMing Lei <ming.lei@redhat.com>
Mon, 11 Jan 2021 03:05:55 +0000 (11:05 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 25 Jan 2021 04:22:45 +0000 (21:22 -0700)
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 <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c

index 8ccda51dd831bf23f82168f3d86a484bbacdc506..56a06f94fb63e5f6bcdeb3ffa6dc18055cc3c364 100644 (file)
@@ -505,12 +505,13 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs,
                        goto err_free;
 
                bio->bi_flags |= idx << BVEC_POOL_OFFSET;
+               bio->bi_max_vecs = bvec_nr_vecs(idx);
        } else if (nr_iovecs) {
                bvl = bio->bi_inline_vecs;
+               bio->bi_max_vecs = inline_vecs;
        }
 
        bio->bi_pool = bs;
-       bio->bi_max_vecs = nr_iovecs;
        bio->bi_io_vec = bvl;
        return bio;