Skip to content

Commit d838d05

Browse files
Christoph Hellwigkdave
authored andcommitted
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: Qu Wenruo <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 801fcfc commit d838d05

File tree

1 file changed

+21
-40
lines changed

1 file changed

+21
-40
lines changed

fs/btrfs/raid56.c

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,13 +1947,25 @@ static int recover_sectors(struct btrfs_raid_bio *rbio)
19471947
return ret;
19481948
}
19491949

1950-
static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio,
1951-
struct bio_list *bio_list)
1950+
static int recover_rbio(struct btrfs_raid_bio *rbio)
19521951
{
1952+
struct bio_list bio_list = BIO_EMPTY_LIST;
19531953
int total_sector_nr;
19541954
int ret = 0;
19551955

1956-
ASSERT(bio_list_size(bio_list) == 0);
1956+
/*
1957+
* Either we're doing recover for a read failure or degraded write,
1958+
* caller should have set error bitmap correctly.
1959+
*/
1960+
ASSERT(bitmap_weight(rbio->error_bitmap, rbio->nr_sectors));
1961+
1962+
/* For recovery, we need to read all sectors including P/Q. */
1963+
ret = alloc_rbio_pages(rbio);
1964+
if (ret < 0)
1965+
return ret;
1966+
1967+
index_rbio_pages(rbio);
1968+
19571969
/*
19581970
* Read everything that hasn't failed. However this time we will
19591971
* not trust any cached sector.
@@ -1984,47 +1996,16 @@ static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio,
19841996
}
19851997

19861998
sector = rbio_stripe_sector(rbio, stripe, sectornr);
1987-
ret = rbio_add_io_sector(rbio, bio_list, sector, stripe,
1999+
ret = rbio_add_io_sector(rbio, &bio_list, sector, stripe,
19882000
sectornr, REQ_OP_READ);
1989-
if (ret < 0)
1990-
goto error;
2001+
if (ret < 0) {
2002+
bio_list_put(&bio_list);
2003+
return ret;
2004+
}
19912005
}
1992-
return 0;
1993-
error:
1994-
bio_list_put(bio_list);
1995-
return -EIO;
1996-
}
1997-
1998-
static int recover_rbio(struct btrfs_raid_bio *rbio)
1999-
{
2000-
struct bio_list bio_list;
2001-
int ret;
2002-
2003-
/*
2004-
* Either we're doing recover for a read failure or degraded write,
2005-
* caller should have set error bitmap correctly.
2006-
*/
2007-
ASSERT(bitmap_weight(rbio->error_bitmap, rbio->nr_sectors));
2008-
bio_list_init(&bio_list);
2009-
2010-
/* For recovery, we need to read all sectors including P/Q. */
2011-
ret = alloc_rbio_pages(rbio);
2012-
if (ret < 0)
2013-
goto out;
2014-
2015-
index_rbio_pages(rbio);
2016-
2017-
ret = recover_assemble_read_bios(rbio, &bio_list);
2018-
if (ret < 0)
2019-
goto out;
20202006

20212007
submit_read_wait_bio_list(rbio, &bio_list);
2022-
2023-
ret = recover_sectors(rbio);
2024-
2025-
out:
2026-
bio_list_put(&bio_list);
2027-
return ret;
2008+
return recover_sectors(rbio);
20282009
}
20292010

20302011
static void recover_rbio_work(struct work_struct *work)

0 commit comments

Comments
 (0)