Commit d838d05e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: raid56: fold recover_assemble_read_bios into recover_rbio

There is very little extra code in recover_rbio, and a large part of it
is the superfluous extra cleanup of the bio list.  Merge the two
functions, and only clean up the bio list after it has been added to
but before it has been emptied again by submit_read_wait_bio_list.
Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.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 801fcfc5
......@@ -1947,13 +1947,25 @@ static int recover_sectors(struct btrfs_raid_bio *rbio)
return ret;
}
static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio,
struct bio_list *bio_list)
static int recover_rbio(struct btrfs_raid_bio *rbio)
{
struct bio_list bio_list = BIO_EMPTY_LIST;
int total_sector_nr;
int ret = 0;
ASSERT(bio_list_size(bio_list) == 0);
/*
* Either we're doing recover for a read failure or degraded write,
* caller should have set error bitmap correctly.
*/
ASSERT(bitmap_weight(rbio->error_bitmap, rbio->nr_sectors));
/* For recovery, we need to read all sectors including P/Q. */
ret = alloc_rbio_pages(rbio);
if (ret < 0)
return ret;
index_rbio_pages(rbio);
/*
* Read everything that hasn't failed. However this time we will
* not trust any cached sector.
......@@ -1984,47 +1996,16 @@ static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio,
}
sector = rbio_stripe_sector(rbio, stripe, sectornr);
ret = rbio_add_io_sector(rbio, bio_list, sector, stripe,
ret = rbio_add_io_sector(rbio, &bio_list, sector, stripe,
sectornr, REQ_OP_READ);
if (ret < 0)
goto error;
if (ret < 0) {
bio_list_put(&bio_list);
return ret;
}
}
return 0;
error:
bio_list_put(bio_list);
return -EIO;
}
static int recover_rbio(struct btrfs_raid_bio *rbio)
{
struct bio_list bio_list;
int ret;
/*
* Either we're doing recover for a read failure or degraded write,
* caller should have set error bitmap correctly.
*/
ASSERT(bitmap_weight(rbio->error_bitmap, rbio->nr_sectors));
bio_list_init(&bio_list);
/* For recovery, we need to read all sectors including P/Q. */
ret = alloc_rbio_pages(rbio);
if (ret < 0)
goto out;
index_rbio_pages(rbio);
ret = recover_assemble_read_bios(rbio, &bio_list);
if (ret < 0)
goto out;
submit_read_wait_bio_list(rbio, &bio_list);
ret = recover_sectors(rbio);
out:
bio_list_put(&bio_list);
return ret;
return recover_sectors(rbio);
}
static void recover_rbio_work(struct work_struct *work)
......
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