Skip to content

Commit 801fcfc

Browse files
Christoph Hellwigkdave
authored andcommitted
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: 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 1c76fb7 commit 801fcfc

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

fs/btrfs/raid56.c

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,14 @@ static void bio_get_trace_info(struct btrfs_raid_bio *rbio, struct bio *bio,
11831183
trace_info->stripe_nr = -1;
11841184
}
11851185

1186+
static inline void bio_list_put(struct bio_list *bio_list)
1187+
{
1188+
struct bio *bio;
1189+
1190+
while ((bio = bio_list_pop(bio_list)))
1191+
bio_put(bio);
1192+
}
1193+
11861194
/* Generate PQ for one vertical stripe. */
11871195
static void generate_pq_vertical(struct btrfs_raid_bio *rbio, int sectornr)
11881196
{
@@ -1228,7 +1236,6 @@ static void generate_pq_vertical(struct btrfs_raid_bio *rbio, int sectornr)
12281236
static int rmw_assemble_write_bios(struct btrfs_raid_bio *rbio,
12291237
struct bio_list *bio_list)
12301238
{
1231-
struct bio *bio;
12321239
/* The total sector number inside the full stripe. */
12331240
int total_sector_nr;
12341241
int sectornr;
@@ -1317,8 +1324,7 @@ static int rmw_assemble_write_bios(struct btrfs_raid_bio *rbio,
13171324

13181325
return 0;
13191326
error:
1320-
while ((bio = bio_list_pop(bio_list)))
1321-
bio_put(bio);
1327+
bio_list_put(bio_list);
13221328
return -EIO;
13231329
}
13241330

@@ -1521,7 +1527,6 @@ static void submit_read_wait_bio_list(struct btrfs_raid_bio *rbio,
15211527
static int rmw_assemble_read_bios(struct btrfs_raid_bio *rbio,
15221528
struct bio_list *bio_list)
15231529
{
1524-
struct bio *bio;
15251530
int total_sector_nr;
15261531
int ret = 0;
15271532

@@ -1548,8 +1553,7 @@ static int rmw_assemble_read_bios(struct btrfs_raid_bio *rbio,
15481553
return 0;
15491554

15501555
cleanup:
1551-
while ((bio = bio_list_pop(bio_list)))
1552-
bio_put(bio);
1556+
bio_list_put(bio_list);
15531557
return ret;
15541558
}
15551559

@@ -1946,7 +1950,6 @@ static int recover_sectors(struct btrfs_raid_bio *rbio)
19461950
static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio,
19471951
struct bio_list *bio_list)
19481952
{
1949-
struct bio *bio;
19501953
int total_sector_nr;
19511954
int ret = 0;
19521955

@@ -1988,16 +1991,13 @@ static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio,
19881991
}
19891992
return 0;
19901993
error:
1991-
while ((bio = bio_list_pop(bio_list)))
1992-
bio_put(bio);
1993-
1994+
bio_list_put(bio_list);
19941995
return -EIO;
19951996
}
19961997

19971998
static int recover_rbio(struct btrfs_raid_bio *rbio)
19981999
{
19992000
struct bio_list bio_list;
2000-
struct bio *bio;
20012001
int ret;
20022002

20032003
/*
@@ -2023,9 +2023,7 @@ static int recover_rbio(struct btrfs_raid_bio *rbio)
20232023
ret = recover_sectors(rbio);
20242024

20252025
out:
2026-
while ((bio = bio_list_pop(&bio_list)))
2027-
bio_put(bio);
2028-
2026+
bio_list_put(&bio_list);
20292027
return ret;
20302028
}
20312029

@@ -2198,7 +2196,6 @@ static void fill_data_csums(struct btrfs_raid_bio *rbio)
21982196
static int rmw_read_wait_recover(struct btrfs_raid_bio *rbio)
21992197
{
22002198
struct bio_list bio_list;
2201-
struct bio *bio;
22022199
int ret;
22032200

22042201
bio_list_init(&bio_list);
@@ -2223,9 +2220,7 @@ static int rmw_read_wait_recover(struct btrfs_raid_bio *rbio)
22232220
ret = recover_sectors(rbio);
22242221
return ret;
22252222
out:
2226-
while ((bio = bio_list_pop(&bio_list)))
2227-
bio_put(bio);
2228-
2223+
bio_list_put(&bio_list);
22292224
return ret;
22302225
}
22312226

@@ -2496,7 +2491,6 @@ static int finish_parity_scrub(struct btrfs_raid_bio *rbio, int need_check)
24962491
struct sector_ptr p_sector = { 0 };
24972492
struct sector_ptr q_sector = { 0 };
24982493
struct bio_list bio_list;
2499-
struct bio *bio;
25002494
int is_replace = 0;
25012495
int ret;
25022496

@@ -2627,8 +2621,7 @@ static int finish_parity_scrub(struct btrfs_raid_bio *rbio, int need_check)
26272621
return 0;
26282622

26292623
cleanup:
2630-
while ((bio = bio_list_pop(&bio_list)))
2631-
bio_put(bio);
2624+
bio_list_put(&bio_list);
26322625
return ret;
26332626
}
26342627

@@ -2726,7 +2719,6 @@ static int recover_scrub_rbio(struct btrfs_raid_bio *rbio)
27262719
static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio,
27272720
struct bio_list *bio_list)
27282721
{
2729-
struct bio *bio;
27302722
int total_sector_nr;
27312723
int ret = 0;
27322724

@@ -2767,8 +2759,7 @@ static int scrub_assemble_read_bios(struct btrfs_raid_bio *rbio,
27672759
}
27682760
return 0;
27692761
error:
2770-
while ((bio = bio_list_pop(bio_list)))
2771-
bio_put(bio);
2762+
bio_list_put(bio_list);
27722763
return ret;
27732764
}
27742765

@@ -2778,7 +2769,6 @@ static int scrub_rbio(struct btrfs_raid_bio *rbio)
27782769
struct bio_list bio_list;
27792770
int sector_nr;
27802771
int ret;
2781-
struct bio *bio;
27822772

27832773
bio_list_init(&bio_list);
27842774

@@ -2817,9 +2807,7 @@ static int scrub_rbio(struct btrfs_raid_bio *rbio)
28172807
return ret;
28182808

28192809
cleanup:
2820-
while ((bio = bio_list_pop(&bio_list)))
2821-
bio_put(bio);
2822-
2810+
bio_list_put(&bio_list);
28232811
return ret;
28242812
}
28252813

0 commit comments

Comments
 (0)