summaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_bio_io.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2022-01-24 10:11:05 +0100
committerJens Axboe <axboe@kernel.dk>2022-02-02 07:49:59 -0700
commit07888c665b405b1cd3577ddebfeb74f4717a84c4 (patch)
treefe3700fcd1b741ddd3caa84a184a8aaaf9e098d7 /fs/xfs/xfs_bio_io.c
parentb77c88c2100ce6a5ec8126c13599b5a7f6663e32 (diff)
downloadlinux-07888c665b405b1cd3577ddebfeb74f4717a84c4.tar.gz
linux-07888c665b405b1cd3577ddebfeb74f4717a84c4.tar.bz2
linux-07888c665b405b1cd3577ddebfeb74f4717a84c4.zip
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>
Diffstat (limited to 'fs/xfs/xfs_bio_io.c')
-rw-r--r--fs/xfs/xfs_bio_io.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/xfs/xfs_bio_io.c b/fs/xfs/xfs_bio_io.c
index 667e297f59b1..eff4a9f21dcf 100644
--- a/fs/xfs/xfs_bio_io.c
+++ b/fs/xfs/xfs_bio_io.c
@@ -61,10 +61,9 @@ xfs_rw_bdev(
if (is_vmalloc && op == REQ_OP_WRITE)
flush_kernel_vmap_range(data, count);
- bio = bio_alloc(GFP_KERNEL, bio_max_vecs(left));
- bio_set_dev(bio, bdev);
+ bio = bio_alloc(bdev, bio_max_vecs(left), op | REQ_META | REQ_SYNC,
+ GFP_KERNEL);
bio->bi_iter.bi_sector = sector;
- bio->bi_opf = op | REQ_META | REQ_SYNC;
do {
struct page *page = kmem_to_page(data);
@@ -74,10 +73,9 @@ xfs_rw_bdev(
while (bio_add_page(bio, page, len, off) != len) {
struct bio *prev = bio;
- bio = bio_alloc(GFP_KERNEL, bio_max_vecs(left));
- bio_copy_dev(bio, prev);
+ bio = bio_alloc(prev->bi_bdev, bio_max_vecs(left),
+ prev->bi_opf, GFP_KERNEL);
bio->bi_iter.bi_sector = bio_end_sector(prev);
- bio->bi_opf = prev->bi_opf;
bio_chain(prev, bio);
submit_bio(prev);