mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 16:41:58 +00:00
btrfs: refactor error handling in btrfs_submit_bio
Add a bbio local variable and to prepare for calling functions that return a blk_status_t, rename the existing int used for error handling so that ret can be reused for the blk_status_t, and a label that can be reused for failing the passed in bio. Reviewed-by: Anand Jain <anand.jain@oracle.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
4ae2edf12d
commit
9ba0004bd9
@ -230,20 +230,21 @@ static void btrfs_submit_mirrored_bio(struct btrfs_io_context *bioc, int dev_nr)
|
|||||||
|
|
||||||
void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror_num)
|
void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror_num)
|
||||||
{
|
{
|
||||||
|
struct btrfs_bio *bbio = btrfs_bio(bio);
|
||||||
u64 logical = bio->bi_iter.bi_sector << 9;
|
u64 logical = bio->bi_iter.bi_sector << 9;
|
||||||
u64 length = bio->bi_iter.bi_size;
|
u64 length = bio->bi_iter.bi_size;
|
||||||
u64 map_length = length;
|
u64 map_length = length;
|
||||||
struct btrfs_io_context *bioc = NULL;
|
struct btrfs_io_context *bioc = NULL;
|
||||||
struct btrfs_io_stripe smap;
|
struct btrfs_io_stripe smap;
|
||||||
int ret;
|
blk_status_t ret;
|
||||||
|
int error;
|
||||||
|
|
||||||
btrfs_bio_counter_inc_blocked(fs_info);
|
btrfs_bio_counter_inc_blocked(fs_info);
|
||||||
ret = __btrfs_map_block(fs_info, btrfs_op(bio), logical, &map_length,
|
error = __btrfs_map_block(fs_info, btrfs_op(bio), logical, &map_length,
|
||||||
&bioc, &smap, &mirror_num, 1);
|
&bioc, &smap, &mirror_num, 1);
|
||||||
if (ret) {
|
if (error) {
|
||||||
btrfs_bio_counter_dec(fs_info);
|
ret = errno_to_blk_status(error);
|
||||||
btrfs_bio_end_io(btrfs_bio(bio), errno_to_blk_status(ret));
|
goto fail;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map_length < length) {
|
if (map_length < length) {
|
||||||
@ -255,8 +256,8 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror
|
|||||||
|
|
||||||
if (!bioc) {
|
if (!bioc) {
|
||||||
/* Single mirror read/write fast path */
|
/* Single mirror read/write fast path */
|
||||||
btrfs_bio(bio)->mirror_num = mirror_num;
|
bbio->mirror_num = mirror_num;
|
||||||
btrfs_bio(bio)->device = smap.dev;
|
bbio->device = smap.dev;
|
||||||
bio->bi_iter.bi_sector = smap.physical >> SECTOR_SHIFT;
|
bio->bi_iter.bi_sector = smap.physical >> SECTOR_SHIFT;
|
||||||
bio->bi_private = fs_info;
|
bio->bi_private = fs_info;
|
||||||
bio->bi_end_io = btrfs_simple_end_io;
|
bio->bi_end_io = btrfs_simple_end_io;
|
||||||
@ -278,6 +279,11 @@ void btrfs_submit_bio(struct btrfs_fs_info *fs_info, struct bio *bio, int mirror
|
|||||||
for (dev_nr = 0; dev_nr < total_devs; dev_nr++)
|
for (dev_nr = 0; dev_nr < total_devs; dev_nr++)
|
||||||
btrfs_submit_mirrored_bio(bioc, dev_nr);
|
btrfs_submit_mirrored_bio(bioc, dev_nr);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
btrfs_bio_counter_dec(fs_info);
|
||||||
|
btrfs_bio_end_io(bbio, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user