mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
block: pass a block_device and opf to bio_alloc
Pass the block_device and operation that we plan to use this bio for to bio_alloc to optimize the assignment. NULL/0 can be passed, both for the passthrough case on a raw request_queue and to temporarily avoid refactoring some nasty code. Also move the gfp_mask argument after the nr_vecs argument for a much more logical calling convention matching what most of the kernel does. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Link: https://lore.kernel.org/r/20220124091107.642561-18-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
b77c88c210
commit
07888c665b
@@ -268,14 +268,15 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
|
||||
if (nvmet_use_inline_bvec(req)) {
|
||||
bio = &req->b.inline_bio;
|
||||
bio_init(bio, req->inline_bvec, ARRAY_SIZE(req->inline_bvec));
|
||||
bio_set_dev(bio, req->ns->bdev);
|
||||
bio->bi_opf = op;
|
||||
} else {
|
||||
bio = bio_alloc(GFP_KERNEL, bio_max_segs(sg_cnt));
|
||||
bio = bio_alloc(req->ns->bdev, bio_max_segs(sg_cnt), op,
|
||||
GFP_KERNEL);
|
||||
}
|
||||
bio_set_dev(bio, req->ns->bdev);
|
||||
bio->bi_iter.bi_sector = sector;
|
||||
bio->bi_private = req;
|
||||
bio->bi_end_io = nvmet_bio_done;
|
||||
bio->bi_opf = op;
|
||||
|
||||
blk_start_plug(&plug);
|
||||
if (req->metadata_len)
|
||||
@@ -296,10 +297,9 @@ static void nvmet_bdev_execute_rw(struct nvmet_req *req)
|
||||
}
|
||||
}
|
||||
|
||||
bio = bio_alloc(GFP_KERNEL, bio_max_segs(sg_cnt));
|
||||
bio_set_dev(bio, req->ns->bdev);
|
||||
bio = bio_alloc(req->ns->bdev, bio_max_segs(sg_cnt),
|
||||
op, GFP_KERNEL);
|
||||
bio->bi_iter.bi_sector = sector;
|
||||
bio->bi_opf = op;
|
||||
|
||||
bio_chain(bio, prev);
|
||||
submit_bio(prev);
|
||||
|
||||
Reference in New Issue
Block a user