diff mbox series

[2/3] btrfs: cleanup rmw_rbio

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

Commit Message

Christoph Hellwig Dec. 12, 2022, 7:06 a.m. UTC
Remove the write goto label by moving the data page allocation and data
read into the branch.

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

Comments

Qu Wenruo Dec. 12, 2022, 7:35 a.m. UTC | #1
On 2022/12/12 15:06, Christoph Hellwig wrote:
> Remove the write goto label by moving the data page allocation and data
> read into the branch.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

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

Thanks,
Qu
> ---
>   fs/btrfs/raid56.c | 28 +++++++++++++---------------
>   1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
> index 5603ba1af55584..5035e2b20a5e02 100644
> --- a/fs/btrfs/raid56.c
> +++ b/fs/btrfs/raid56.c
> @@ -2293,24 +2293,22 @@ static int rmw_rbio(struct btrfs_raid_bio *rbio)
>   	 * Either full stripe write, or we have every data sector already
>   	 * cached, can go to write path immediately.
>   	 */
> -	if (rbio_is_full(rbio) || !need_read_stripe_sectors(rbio))
> -		goto write;
> -
> -	/*
> -	 * Now we're doing sub-stripe write, also need all data stripes to do
> -	 * the full RMW.
> -	 */
> -	ret = alloc_rbio_data_pages(rbio);
> -	if (ret < 0)
> -		return ret;
> +	if (!rbio_is_full(rbio) && need_read_stripe_sectors(rbio)) {
> +		/*
> +		 * Now we're doing sub-stripe write, also need all data stripes
> +		 * to do the full RMW.
> +		 */
> +		ret = alloc_rbio_data_pages(rbio);
> +		if (ret < 0)
> +			return ret;
>   
> -	index_rbio_pages(rbio);
> +		index_rbio_pages(rbio);
>   
> -	ret = rmw_read_wait_recover(rbio);
> -	if (ret < 0)
> -		return ret;
> +		ret = rmw_read_wait_recover(rbio);
> +		if (ret < 0)
> +			return ret;
> +	}
>   
> -write:
>   	/*
>   	 * At this stage we're not allowed to add any new bios to the
>   	 * bio list any more, anyone else that wants to change this stripe
diff mbox series

Patch

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 5603ba1af55584..5035e2b20a5e02 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -2293,24 +2293,22 @@  static int rmw_rbio(struct btrfs_raid_bio *rbio)
 	 * Either full stripe write, or we have every data sector already
 	 * cached, can go to write path immediately.
 	 */
-	if (rbio_is_full(rbio) || !need_read_stripe_sectors(rbio))
-		goto write;
-
-	/*
-	 * Now we're doing sub-stripe write, also need all data stripes to do
-	 * the full RMW.
-	 */
-	ret = alloc_rbio_data_pages(rbio);
-	if (ret < 0)
-		return ret;
+	if (!rbio_is_full(rbio) && need_read_stripe_sectors(rbio)) {
+		/*
+		 * Now we're doing sub-stripe write, also need all data stripes
+		 * to do the full RMW.
+		 */
+		ret = alloc_rbio_data_pages(rbio);
+		if (ret < 0)
+			return ret;
 
-	index_rbio_pages(rbio);
+		index_rbio_pages(rbio);
 
-	ret = rmw_read_wait_recover(rbio);
-	if (ret < 0)
-		return ret;
+		ret = rmw_read_wait_recover(rbio);
+		if (ret < 0)
+			return ret;
+	}
 
-write:
 	/*
 	 * At this stage we're not allowed to add any new bios to the
 	 * bio list any more, anyone else that wants to change this stripe