mirror of
https://github.com/torvalds/linux.git
synced 2024-12-03 17:41:22 +00:00
btrfs: raid56: avoid double for loop inside __raid56_parity_recover()
The double for loop can be easily converted to single for loop as we're really iterating the sectors in their bytenr order. The only exception is the full stripe skip, however that can also easily be done inside the loop. Add an ASSERT() along with a comment for that specific case. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
3692004465
commit
ef340fccbe
@ -2115,8 +2115,7 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
|
|||||||
int bios_to_read = 0;
|
int bios_to_read = 0;
|
||||||
struct bio_list bio_list;
|
struct bio_list bio_list;
|
||||||
int ret;
|
int ret;
|
||||||
int sectornr;
|
int total_sector_nr;
|
||||||
int stripe;
|
|
||||||
struct bio *bio;
|
struct bio *bio;
|
||||||
|
|
||||||
bio_list_init(&bio_list);
|
bio_list_init(&bio_list);
|
||||||
@ -2132,29 +2131,29 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
|
|||||||
* stripe cache, it is possible that some or all of these
|
* stripe cache, it is possible that some or all of these
|
||||||
* pages are going to be uptodate.
|
* pages are going to be uptodate.
|
||||||
*/
|
*/
|
||||||
for (stripe = 0; stripe < rbio->real_stripes; stripe++) {
|
for (total_sector_nr = 0; total_sector_nr < rbio->nr_sectors;
|
||||||
|
total_sector_nr++) {
|
||||||
|
int stripe = total_sector_nr / rbio->stripe_nsectors;
|
||||||
|
int sectornr = total_sector_nr % rbio->stripe_nsectors;
|
||||||
|
struct sector_ptr *sector;
|
||||||
|
|
||||||
if (rbio->faila == stripe || rbio->failb == stripe) {
|
if (rbio->faila == stripe || rbio->failb == stripe) {
|
||||||
atomic_inc(&rbio->error);
|
atomic_inc(&rbio->error);
|
||||||
|
/* Skip the current stripe. */
|
||||||
|
ASSERT(sectornr == 0);
|
||||||
|
total_sector_nr += rbio->stripe_nsectors - 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
/* The RMW code may have already read this page in. */
|
||||||
|
sector = rbio_stripe_sector(rbio, stripe, sectornr);
|
||||||
|
if (sector->uptodate)
|
||||||
|
continue;
|
||||||
|
|
||||||
for (sectornr = 0; sectornr < rbio->stripe_nsectors; sectornr++) {
|
ret = rbio_add_io_sector(rbio, &bio_list, sector, stripe,
|
||||||
struct sector_ptr *sector;
|
sectornr, rbio->stripe_len,
|
||||||
|
REQ_OP_READ);
|
||||||
/*
|
if (ret < 0)
|
||||||
* the rmw code may have already read this
|
goto cleanup;
|
||||||
* page in
|
|
||||||
*/
|
|
||||||
sector = rbio_stripe_sector(rbio, stripe, sectornr);
|
|
||||||
if (sector->uptodate)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ret = rbio_add_io_sector(rbio, &bio_list, sector,
|
|
||||||
stripe, sectornr, rbio->stripe_len,
|
|
||||||
REQ_OP_READ);
|
|
||||||
if (ret < 0)
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bios_to_read = bio_list_size(&bio_list);
|
bios_to_read = bio_list_size(&bio_list);
|
||||||
|
Loading…
Reference in New Issue
Block a user