btrfs: pass a block_device to btrfs_bio_clone
authorChristoph Hellwig <hch@lst.de>
Mon, 4 Apr 2022 04:45:24 +0000 (06:45 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2022 15:03:12 +0000 (17:03 +0200)
Pass the block_device to bio_alloc_clone instead of setting it later.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/volumes.c

index 3d3599717d4a19e17f15352f4d7d78a51bb1ce93..3a25465cdad74c2e83683bd3c48b8d19e3a738db 100644 (file)
@@ -3192,13 +3192,13 @@ struct bio *btrfs_bio_alloc(unsigned int nr_iovecs)
        return bio;
 }
 
-struct bio *btrfs_bio_clone(struct bio *bio)
+struct bio *btrfs_bio_clone(struct block_device *bdev, struct bio *bio)
 {
        struct btrfs_bio *bbio;
        struct bio *new;
 
        /* Bio allocation backed by a bioset does not fail */
-       new = bio_alloc_clone(bio->bi_bdev, bio, GFP_NOFS, &btrfs_bioset);
+       new = bio_alloc_clone(bdev, bio, GFP_NOFS, &btrfs_bioset);
        bbio = btrfs_bio(new);
        btrfs_bio_init(bbio);
        bbio->iter = bio->bi_iter;
index 1331902c75815e23ce2a7c09f31410ff78ea951b..05253612ce7bbacb6c7695773b0e7fcb6a71cea8 100644 (file)
@@ -280,7 +280,7 @@ void extent_clear_unlock_delalloc(struct btrfs_inode *inode, u64 start, u64 end,
 
 int btrfs_alloc_page_array(unsigned int nr_pages, struct page **page_array);
 struct bio *btrfs_bio_alloc(unsigned int nr_iovecs);
-struct bio *btrfs_bio_clone(struct bio *bio);
+struct bio *btrfs_bio_clone(struct block_device *bdev, struct bio *bio);
 struct bio *btrfs_bio_clone_partial(struct bio *orig, u64 offset, u64 size);
 
 void end_extent_writepage(struct page *page, int err, u64 start, u64 end);
index 76d2a40113dfe8f39ac6584e356cca7b9fdca90b..d8edd99a1c4958e41a8aad3d2c6b8d5ceb24ae73 100644 (file)
@@ -6824,12 +6824,13 @@ blk_status_t btrfs_map_bio(struct btrfs_fs_info *fs_info, struct bio *bio,
                        continue;
                }
 
-               if (dev_nr < total_devs - 1)
-                       bio = btrfs_bio_clone(first_bio);
-               else
+               if (dev_nr < total_devs - 1) {
+                       bio = btrfs_bio_clone(dev->bdev, first_bio);
+               } else {
                        bio = first_bio;
+                       bio_set_dev(bio, dev->bdev);
+               }
 
-               bio_set_dev(bio, dev->bdev);
                submit_stripe_bio(bioc, bio, bioc->stripes[dev_nr].physical, dev);
        }
        btrfs_bio_counter_dec(fs_info);