Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcache: avoid to use bio_for_each_segment_all() in bch_bio_alloc_pages()

bch_bio_alloc_pages() is always called on one new bio, so it is safe
to access the bvec table directly. Given it is the only kind of this
case, open code the bvec table access since bio_for_each_segment_all()
will be changed to support for iterating over multipage bvec.

Acked-by: Coly Li <colyli@suse.de>
Reviewed-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Ming Lei and committed by
Jens Axboe
2e1f4f4d 86af5952

+5 -1
+5 -1
drivers/md/bcache/util.c
··· 270 270 int i; 271 271 struct bio_vec *bv; 272 272 273 - bio_for_each_segment_all(bv, bio, i) { 273 + /* 274 + * This is called on freshly new bio, so it is safe to access the 275 + * bvec table directly. 276 + */ 277 + for (i = 0, bv = bio->bi_io_vec; i < bio->bi_vcnt; bv++, i++) { 274 278 bv->bv_page = alloc_page(gfp_mask); 275 279 if (!bv->bv_page) { 276 280 while (--bv >= bio->bi_io_vec)