Commit 28793b19 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: decide bio cloning inside submit_stripe_bio

Remove the orig_bio argument as it can be derived from the bioc, and
the clone argument as it can be calculated from bioc and dev_nr.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 32747c44
...@@ -6788,13 +6788,12 @@ static void btrfs_submit_dev_bio(struct btrfs_device *dev, struct bio *bio) ...@@ -6788,13 +6788,12 @@ static void btrfs_submit_dev_bio(struct btrfs_device *dev, struct bio *bio)
submit_bio(bio); submit_bio(bio);
} }
static void submit_stripe_bio(struct btrfs_io_context *bioc, static void submit_stripe_bio(struct btrfs_io_context *bioc, int dev_nr)
struct bio *orig_bio, int dev_nr, bool clone)
{ {
struct bio *bio; struct bio *orig_bio = bioc->orig_bio, *bio;
/* Reuse the bio embedded into the btrfs_bio for the last mirror */ /* Reuse the bio embedded into the btrfs_bio for the last mirror */
if (!clone) { if (dev_nr == bioc->num_stripes - 1) {
bio = orig_bio; bio = orig_bio;
btrfs_bio(bio)->device = bioc->stripes[dev_nr].dev; btrfs_bio(bio)->device = bioc->stripes[dev_nr].dev;
bio->bi_end_io = btrfs_end_bio; bio->bi_end_io = btrfs_end_bio;
...@@ -6850,11 +6849,8 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror ...@@ -6850,11 +6849,8 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror
BUG(); BUG();
} }
for (dev_nr = 0; dev_nr < total_devs; dev_nr++) { for (dev_nr = 0; dev_nr < total_devs; dev_nr++)
const bool should_clone = (dev_nr < total_devs - 1); submit_stripe_bio(bioc, dev_nr);
submit_stripe_bio(bioc, bio, dev_nr, should_clone);
}
} }
static bool dev_args_match_fs_devices(const struct btrfs_dev_lookup_args *args, static bool dev_args_match_fs_devices(const struct btrfs_dev_lookup_args *args,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment