Skip to content

Commit 52f0c19

Browse files
Christoph Hellwigkdave
authored andcommitted
btrfs: raid56: submit the read bios from scrub_assemble_read_bios
Instead of filling in a bio_list and submitting the bios in the only caller, do that in scrub_assemble_read_bios. This removes the need to pass the bio_list, and also makes it clear that the extra bio_list cleanup in the caller is entirely pointless. Rename the function to scrub_read_bios to make it clear that the bios are not only assembled. 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 02efa3a commit 52f0c19

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

fs/btrfs/raid56.c

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,14 +2674,12 @@ static int recover_scrub_rbio(struct btrfs_raid_bio *rbio)
26742674
return ret;
26752675
}
26762676

2677-
static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio,
2678-
struct bio_list *bio_list)
2677+
static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio)
26792678
{
2679+
struct bio_list bio_list = BIO_EMPTY_LIST;
26802680
int total_sector_nr;
26812681
int ret = 0;
26822682

2683-
ASSERT(bio_list_size(bio_list) == 0);
2684-
26852683
/* Build a list of bios to read all the missing parts. */
26862684
for (total_sector_nr = 0; total_sector_nr < rbio->nr_sectors;
26872685
total_sector_nr++) {
@@ -2710,42 +2708,38 @@ static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio,
27102708
if (sector->uptodate)
27112709
continue;
27122710

2713-
ret = rbio_add_io_sector(rbio, bio_list, sector, stripe,
2711+
ret = rbio_add_io_sector(rbio, &bio_list, sector, stripe,
27142712
sectornr, REQ_OP_READ);
2715-
if (ret)
2716-
goto error;
2713+
if (ret) {
2714+
bio_list_put(&bio_list);
2715+
return ret;
2716+
}
27172717
}
2718+
2719+
submit_read_wait_bio_list(rbio, &bio_list);
27182720
return 0;
2719-
error:
2720-
bio_list_put(bio_list);
2721-
return ret;
27222721
}
27232722

27242723
static int scrub_rbio(struct btrfs_raid_bio *rbio)
27252724
{
27262725
bool need_check = false;
2727-
struct bio_list bio_list;
27282726
int sector_nr;
27292727
int ret;
27302728

2731-
bio_list_init(&bio_list);
2732-
27332729
ret = alloc_rbio_essential_pages(rbio);
27342730
if (ret)
2735-
goto cleanup;
2731+
return ret;
27362732

27372733
bitmap_clear(rbio->error_bitmap, 0, rbio->nr_sectors);
27382734

2739-
ret = scrub_assemble_read_bios(rbio, &bio_list);
2735+
ret = scrub_assemble_read_bios(rbio);
27402736
if (ret < 0)
2741-
goto cleanup;
2742-
2743-
submit_read_wait_bio_list(rbio, &bio_list);
2737+
return ret;
27442738

27452739
/* We may have some failures, recover the failed sectors first. */
27462740
ret = recover_scrub_rbio(rbio);
27472741
if (ret < 0)
2748-
goto cleanup;
2742+
return ret;
27492743

27502744
/*
27512745
* We have every sector properly prepared. Can finish the scrub
@@ -2763,10 +2757,6 @@ static int scrub_rbio(struct btrfs_raid_bio *rbio)
27632757
}
27642758
}
27652759
return ret;
2766-
2767-
cleanup:
2768-
bio_list_put(&bio_list);
2769-
return ret;
27702760
}
27712761

27722762
static void scrub_rbio_work_locked(struct work_struct *work)

0 commit comments

Comments
 (0)