Commit 801fcfc5 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba

btrfs: raid56: add a bio_list_put helper

Add a helper to put all bios in a list. This does not need to be added
to block layer as there are no other users of such code.
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 1c76fb7b
...@@ -1183,6 +1183,14 @@ static void bio_get_trace_info(struct btrfs_raid_bio *rbio, struct bio *bio, ...@@ -1183,6 +1183,14 @@ static void bio_get_trace_info(struct btrfs_raid_bio *rbio, struct bio *bio,
trace_info->stripe_nr = -1; trace_info->stripe_nr = -1;
} }
static inline void bio_list_put(struct bio_list *bio_list)
{
struct bio *bio;
while ((bio = bio_list_pop(bio_list)))
bio_put(bio);
}
/* Generate PQ for one vertical stripe. */ /* Generate PQ for one vertical stripe. */
static void generate_pq_vertical(struct btrfs_raid_bio *rbio, int sectornr) static void generate_pq_vertical(struct btrfs_raid_bio *rbio, int sectornr)
{ {
...@@ -1228,7 +1236,6 @@ static void generate_pq_vertical(struct btrfs_raid_bio *rbio, int sectornr) ...@@ -1228,7 +1236,6 @@ static void generate_pq_vertical(struct btrfs_raid_bio *rbio, int sectornr)
static int rmw_assemble_write_bios(struct btrfs_raid_bio *rbio, static int rmw_assemble_write_bios(struct btrfs_raid_bio *rbio,
struct bio_list *bio_list) struct bio_list *bio_list)
{ {
struct bio *bio;
/* The total sector number inside the full stripe. */ /* The total sector number inside the full stripe. */
int total_sector_nr; int total_sector_nr;
int sectornr; int sectornr;
...@@ -1317,8 +1324,7 @@ static int rmw_assemble_write_bios(struct btrfs_raid_bio *rbio, ...@@ -1317,8 +1324,7 @@ static int rmw_assemble_write_bios(struct btrfs_raid_bio *rbio,
return 0; return 0;
error: error:
while ((bio = bio_list_pop(bio_list))) bio_list_put(bio_list);
bio_put(bio);
return -EIO; return -EIO;
} }
...@@ -1521,7 +1527,6 @@ static void submit_read_wait_bio_list(struct btrfs_raid_bio *rbio, ...@@ -1521,7 +1527,6 @@ static void submit_read_wait_bio_list(struct btrfs_raid_bio *rbio,
static int rmw_assemble_read_bios(struct btrfs_raid_bio *rbio, static int rmw_assemble_read_bios(struct btrfs_raid_bio *rbio,
struct bio_list *bio_list) struct bio_list *bio_list)
{ {
struct bio *bio;
int total_sector_nr; int total_sector_nr;
int ret = 0; int ret = 0;
...@@ -1548,8 +1553,7 @@ static int rmw_assemble_read_bios(struct btrfs_raid_bio *rbio, ...@@ -1548,8 +1553,7 @@ static int rmw_assemble_read_bios(struct btrfs_raid_bio *rbio,
return 0; return 0;
cleanup: cleanup:
while ((bio = bio_list_pop(bio_list))) bio_list_put(bio_list);
bio_put(bio);
return ret; return ret;
} }
...@@ -1946,7 +1950,6 @@ static int recover_sectors(struct btrfs_raid_bio *rbio) ...@@ -1946,7 +1950,6 @@ static int recover_sectors(struct btrfs_raid_bio *rbio)
static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio, static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio,
struct bio_list *bio_list) struct bio_list *bio_list)
{ {
struct bio *bio;
int total_sector_nr; int total_sector_nr;
int ret = 0; int ret = 0;
...@@ -1988,16 +1991,13 @@ static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio, ...@@ -1988,16 +1991,13 @@ static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio,
} }
return 0; return 0;
error: error:
while ((bio = bio_list_pop(bio_list))) bio_list_put(bio_list);
bio_put(bio);
return -EIO; return -EIO;
} }
static int recover_rbio(struct btrfs_raid_bio *rbio) static int recover_rbio(struct btrfs_raid_bio *rbio)
{ {
struct bio_list bio_list; struct bio_list bio_list;
struct bio *bio;
int ret; int ret;
/* /*
...@@ -2023,9 +2023,7 @@ static int recover_rbio(struct btrfs_raid_bio *rbio) ...@@ -2023,9 +2023,7 @@ static int recover_rbio(struct btrfs_raid_bio *rbio)
ret = recover_sectors(rbio); ret = recover_sectors(rbio);
out: out:
while ((bio = bio_list_pop(&bio_list))) bio_list_put(&bio_list);
bio_put(bio);
return ret; return ret;
} }
...@@ -2198,7 +2196,6 @@ static void fill_data_csums(struct btrfs_raid_bio *rbio) ...@@ -2198,7 +2196,6 @@ static void fill_data_csums(struct btrfs_raid_bio *rbio)
static int rmw_read_wait_recover(struct btrfs_raid_bio *rbio) static int rmw_read_wait_recover(struct btrfs_raid_bio *rbio)
{ {
struct bio_list bio_list; struct bio_list bio_list;
struct bio *bio;
int ret; int ret;
bio_list_init(&bio_list); bio_list_init(&bio_list);
...@@ -2223,9 +2220,7 @@ static int rmw_read_wait_recover(struct btrfs_raid_bio *rbio) ...@@ -2223,9 +2220,7 @@ static int rmw_read_wait_recover(struct btrfs_raid_bio *rbio)
ret = recover_sectors(rbio); ret = recover_sectors(rbio);
return ret; return ret;
out: out:
while ((bio = bio_list_pop(&bio_list))) bio_list_put(&bio_list);
bio_put(bio);
return ret; return ret;
} }
...@@ -2496,7 +2491,6 @@ static int finish_parity_scrub(struct btrfs_raid_bio *rbio, int need_check) ...@@ -2496,7 +2491,6 @@ static int finish_parity_scrub(struct btrfs_raid_bio *rbio, int need_check)
struct sector_ptr p_sector = { 0 }; struct sector_ptr p_sector = { 0 };
struct sector_ptr q_sector = { 0 }; struct sector_ptr q_sector = { 0 };
struct bio_list bio_list; struct bio_list bio_list;
struct bio *bio;
int is_replace = 0; int is_replace = 0;
int ret; int ret;
...@@ -2627,8 +2621,7 @@ static int finish_parity_scrub(struct btrfs_raid_bio *rbio, int need_check) ...@@ -2627,8 +2621,7 @@ static int finish_parity_scrub(struct btrfs_raid_bio *rbio, int need_check)
return 0; return 0;
cleanup: cleanup:
while ((bio = bio_list_pop(&bio_list))) bio_list_put(&bio_list);
bio_put(bio);
return ret; return ret;
} }
...@@ -2726,7 +2719,6 @@ static int recover_scrub_rbio(struct btrfs_raid_bio *rbio) ...@@ -2726,7 +2719,6 @@ static int recover_scrub_rbio(struct btrfs_raid_bio *rbio)
static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio, static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio,
struct bio_list *bio_list) struct bio_list *bio_list)
{ {
struct bio *bio;
int total_sector_nr; int total_sector_nr;
int ret = 0; int ret = 0;
...@@ -2767,8 +2759,7 @@ static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio, ...@@ -2767,8 +2759,7 @@ static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio,
} }
return 0; return 0;
error: error:
while ((bio = bio_list_pop(bio_list))) bio_list_put(bio_list);
bio_put(bio);
return ret; return ret;
} }
...@@ -2778,7 +2769,6 @@ static int scrub_rbio(struct btrfs_raid_bio *rbio) ...@@ -2778,7 +2769,6 @@ static int scrub_rbio(struct btrfs_raid_bio *rbio)
struct bio_list bio_list; struct bio_list bio_list;
int sector_nr; int sector_nr;
int ret; int ret;
struct bio *bio;
bio_list_init(&bio_list); bio_list_init(&bio_list);
...@@ -2817,9 +2807,7 @@ static int scrub_rbio(struct btrfs_raid_bio *rbio) ...@@ -2817,9 +2807,7 @@ static int scrub_rbio(struct btrfs_raid_bio *rbio)
return ret; return ret;
cleanup: cleanup:
while ((bio = bio_list_pop(&bio_list))) bio_list_put(&bio_list);
bio_put(bio);
return ret; return ret;
} }
......
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