diff mbox series

[4/8] btrfs: cleanup recover_rbio

Message ID 20221213084123.309790-5-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
The bio_list is only filled by recover_assemble_read_bios when
successful, so don't try to walk it and put the bios on any
failure before the successful call to recover_assemble_read_bios.
Also initialize bio_list at initialization time.

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

Comments

Qu Wenruo Dec. 13, 2022, 8:50 a.m. UTC | #1
On 2022/12/13 16:41, Christoph Hellwig wrote:
> The bio_list is only filled by recover_assemble_read_bios when
> successful, so don't try to walk it and put the bios on any
> failure before the successful call to recover_assemble_read_bios.
> Also initialize bio_list at initialization time.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>   fs/btrfs/raid56.c | 10 +++-------
>   1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
> index e0966126ab27a4..5dab0685e17dd5 100644
> --- a/fs/btrfs/raid56.c
> +++ b/fs/btrfs/raid56.c
> @@ -1987,7 +1987,7 @@ static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio,
>   
>   static int recover_rbio(struct btrfs_raid_bio *rbio)
>   {
> -	struct bio_list bio_list;
> +	struct bio_list bio_list = BIO_EMPTY_LIST;
>   	struct bio *bio;
>   	int ret;
>   
> @@ -1996,28 +1996,24 @@ static int recover_rbio(struct btrfs_raid_bio *rbio)
>   	 * caller should have set error bitmap correctly.
>   	 */
>   	ASSERT(bitmap_weight(rbio->error_bitmap, rbio->nr_sectors));
> -	bio_list_init(&bio_list);
>   
>   	/* For recovery, we need to read all sectors including P/Q. */
>   	ret = alloc_rbio_pages(rbio);
>   	if (ret < 0)
> -		goto out;
> +		return ret;
>   
>   	index_rbio_pages(rbio);
>   
>   	ret = recover_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);
>   
>   	ret = recover_sectors(rbio);
> -
> -out:
>   	while ((bio = bio_list_pop(&bio_list)))
>   		bio_put(bio);
> -
>   	return ret;
>   }
>
diff mbox series

Patch

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index e0966126ab27a4..5dab0685e17dd5 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1987,7 +1987,7 @@  static int recover_assemble_read_bios(struct btrfs_raid_bio *rbio,
 
 static int recover_rbio(struct btrfs_raid_bio *rbio)
 {
-	struct bio_list bio_list;
+	struct bio_list bio_list = BIO_EMPTY_LIST;
 	struct bio *bio;
 	int ret;
 
@@ -1996,28 +1996,24 @@  static int recover_rbio(struct btrfs_raid_bio *rbio)
 	 * caller should have set error bitmap correctly.
 	 */
 	ASSERT(bitmap_weight(rbio->error_bitmap, rbio->nr_sectors));
-	bio_list_init(&bio_list);
 
 	/* For recovery, we need to read all sectors including P/Q. */
 	ret = alloc_rbio_pages(rbio);
 	if (ret < 0)
-		goto out;
+		return ret;
 
 	index_rbio_pages(rbio);
 
 	ret = recover_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);
 
 	ret = recover_sectors(rbio);
-
-out:
 	while ((bio = bio_list_pop(&bio_list)))
 		bio_put(bio);
-
 	return ret;
 }