diff mbox series

[2/3] xfs: don't increment m_generation for all errors in xfs_growfs_data

Message ID 20250317054512.1131950-3-hch@lst.de (mailing list archive)
State Accepted
Headers show
Series [1/3] xfs: fix a missing unlock in xfs_growfs_data | expand

Commit Message

hch March 17, 2025, 5:44 a.m. UTC
xfs_growfs_data needs to increment m_generation as soon as the primary
superblock has been updated.  As the update of the secondary superblocks
was part of xfs_growfs_data_private that mean the incremented had to be
done unconditionally once that was called.  Later, commit 83a7f86e39ff
("xfs: separate secondary sb update in growfs") split the secondary
superblock update into a separate helper, so now the increment on error
can be limited to failed calls to xfs_update_secondary_sbs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_fsops.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Carlos Maiolino March 18, 2025, 12:01 p.m. UTC | #1
On Mon, Mar 17, 2025 at 06:44:53AM +0100, Christoph Hellwig wrote:
> xfs_growfs_data needs to increment m_generation as soon as the primary
> superblock has been updated.  As the update of the secondary superblocks
> was part of xfs_growfs_data_private that mean the incremented had to be
> done unconditionally once that was called.  Later, commit 83a7f86e39ff
> ("xfs: separate secondary sb update in growfs") split the secondary
> superblock update into a separate helper, so now the increment on error
> can be limited to failed calls to xfs_update_secondary_sbs.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> ---
>  fs/xfs/xfs_fsops.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
> index d7658b7dcdbd..b6f3d7abdae5 100644
> --- a/fs/xfs/xfs_fsops.c
> +++ b/fs/xfs/xfs_fsops.c
> @@ -311,20 +311,20 @@ xfs_growfs_data(
>  	/* we can't grow the data section when an internal RT section exists */
>  	if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart) {
>  		error = -EINVAL;
> -		goto out_error;
> +		goto out_unlock;
>  	}
> 
>  	/* update imaxpct separately to the physical grow of the filesystem */
>  	if (in->imaxpct != mp->m_sb.sb_imax_pct) {
>  		error = xfs_growfs_imaxpct(mp, in->imaxpct);
>  		if (error)
> -			goto out_error;
> +			goto out_unlock;
>  	}
> 
>  	if (in->newblocks != mp->m_sb.sb_dblocks) {
>  		error = xfs_growfs_data_private(mp, in);
>  		if (error)
> -			goto out_error;
> +			goto out_unlock;
>  	}
> 
>  	/* Post growfs calculations needed to reflect new state in operations */
> @@ -338,13 +338,12 @@ xfs_growfs_data(
>  	/* Update secondary superblocks now the physical grow has completed */
>  	error = xfs_update_secondary_sbs(mp);
> 
> -out_error:
>  	/*
> -	 * Increment the generation unconditionally, the error could be from
> -	 * updating the secondary superblocks, in which case the new size
> -	 * is live already.
> +	 * Increment the generation unconditionally, after trying to update the
> +	 * secondary superblocks, as the new size is live already at this point.
>  	 */
>  	mp->m_generation++;
> +out_unlock:
>  	mutex_unlock(&mp->m_growlock);
>  	return error;
>  }
> --
> 2.45.2
> 
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index d7658b7dcdbd..b6f3d7abdae5 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -311,20 +311,20 @@  xfs_growfs_data(
 	/* we can't grow the data section when an internal RT section exists */
 	if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart) {
 		error = -EINVAL;
-		goto out_error;
+		goto out_unlock;
 	}
 
 	/* update imaxpct separately to the physical grow of the filesystem */
 	if (in->imaxpct != mp->m_sb.sb_imax_pct) {
 		error = xfs_growfs_imaxpct(mp, in->imaxpct);
 		if (error)
-			goto out_error;
+			goto out_unlock;
 	}
 
 	if (in->newblocks != mp->m_sb.sb_dblocks) {
 		error = xfs_growfs_data_private(mp, in);
 		if (error)
-			goto out_error;
+			goto out_unlock;
 	}
 
 	/* Post growfs calculations needed to reflect new state in operations */
@@ -338,13 +338,12 @@  xfs_growfs_data(
 	/* Update secondary superblocks now the physical grow has completed */
 	error = xfs_update_secondary_sbs(mp);
 
-out_error:
 	/*
-	 * Increment the generation unconditionally, the error could be from
-	 * updating the secondary superblocks, in which case the new size
-	 * is live already.
+	 * Increment the generation unconditionally, after trying to update the
+	 * secondary superblocks, as the new size is live already at this point.
 	 */
 	mp->m_generation++;
+out_unlock:
 	mutex_unlock(&mp->m_growlock);
 	return error;
 }