diff mbox series

[3/8] btrfs: cleanup rmw_read_wait_recover

Message ID 20221213084123.309790-4-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/8] btrfs: cleanup raid56_parity_write | expand

Commit Message

Christoph Hellwig Dec. 13, 2022, 8:41 a.m. UTC
rmw_assemble_read_bios already cleans up the bio_list on failure, so the
loop to do so in rmw_read_wait_recover will never do anything and can be
removed.  Also initialize the bio_list at initialization time, and
directly return the value from recover_sectors instead of assigning it to
ret first.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/raid56.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 5035e2b20a5e02..e0966126ab27a4 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -2189,12 +2189,9 @@  static void fill_data_csums(struct btrfs_raid_bio *rbio)
 
 static int rmw_read_wait_recover(struct btrfs_raid_bio *rbio)
 {
-	struct bio_list bio_list;
-	struct bio *bio;
+	struct bio_list bio_list = BIO_EMPTY_LIST;
 	int ret;
 
-	bio_list_init(&bio_list);
-
 	/*
 	 * Fill the data csums we need for data verification.  We need to fill
 	 * the csum_bitmap/csum_buf first, as our endio function will try to
@@ -2204,7 +2201,7 @@  static int rmw_read_wait_recover(struct btrfs_raid_bio *rbio)
 
 	ret = rmw_assemble_read_bios(rbio, &bio_list);
 	if (ret < 0)
-		goto out;
+		return ret;
 
 	submit_read_bios(rbio, &bio_list);
 	wait_event(rbio->io_wait, atomic_read(&rbio->stripes_pending) == 0);
@@ -2213,13 +2210,7 @@  static int rmw_read_wait_recover(struct btrfs_raid_bio *rbio)
 	 * We may or may not have any corrupted sectors (including missing dev
 	 * and csum mismatch), just let recover_sectors() to handle them all.
 	 */
-	ret = recover_sectors(rbio);
-	return ret;
-out:
-	while ((bio = bio_list_pop(&bio_list)))
-		bio_put(bio);
-
-	return ret;
+	return recover_sectors(rbio);
 }
 
 static void raid_wait_write_end_io(struct bio *bio)