diff mbox series

[04/14] xfs: stricter btree height checking when looking for errors

Message ID 163192857182.416199.9310383108874723785.stgit@magnolia (mailing list archive)
State Superseded, archived
Headers show
Series xfs: support dynamic btree cursor height | expand

Commit Message

Darrick J. Wong Sept. 18, 2021, 1:29 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Since each btree type has its own precomputed maxlevels variable now,
use them instead of the generic XFS_BTREE_MAXLEVELS to check the level
of each per-AG btree.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/scrub/agheader.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Chandan Babu R Sept. 20, 2021, 9:54 a.m. UTC | #1
On 18 Sep 2021 at 06:59, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Since each btree type has its own precomputed maxlevels variable now,
> use them instead of the generic XFS_BTREE_MAXLEVELS to check the level
> of each per-AG btree.

Looks good.

Reviewed-by: Chandan Babu R <chandan.babu@oracle.com>

>
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  fs/xfs/scrub/agheader.c |   13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
>
> diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
> index ae3c9f6e2c69..a2c3af77b6c2 100644
> --- a/fs/xfs/scrub/agheader.c
> +++ b/fs/xfs/scrub/agheader.c
> @@ -555,11 +555,11 @@ xchk_agf(
>  		xchk_block_set_corrupt(sc, sc->sa.agf_bp);
>  
>  	level = be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]);
> -	if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
> +	if (level <= 0 || level > mp->m_ag_maxlevels)
>  		xchk_block_set_corrupt(sc, sc->sa.agf_bp);
>  
>  	level = be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]);
> -	if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
> +	if (level <= 0 || level > mp->m_ag_maxlevels)
>  		xchk_block_set_corrupt(sc, sc->sa.agf_bp);
>  
>  	if (xfs_has_rmapbt(mp)) {
> @@ -568,7 +568,7 @@ xchk_agf(
>  			xchk_block_set_corrupt(sc, sc->sa.agf_bp);
>  
>  		level = be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]);
> -		if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
> +		if (level <= 0 || level > mp->m_rmap_maxlevels)
>  			xchk_block_set_corrupt(sc, sc->sa.agf_bp);
>  	}
>  
> @@ -578,7 +578,7 @@ xchk_agf(
>  			xchk_block_set_corrupt(sc, sc->sa.agf_bp);
>  
>  		level = be32_to_cpu(agf->agf_refcount_level);
> -		if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
> +		if (level <= 0 || level > mp->m_refc_maxlevels)
>  			xchk_block_set_corrupt(sc, sc->sa.agf_bp);
>  	}
>  
> @@ -850,6 +850,7 @@ xchk_agi(
>  	struct xfs_mount	*mp = sc->mp;
>  	struct xfs_agi		*agi;
>  	struct xfs_perag	*pag;
> +	struct xfs_ino_geometry	*igeo = M_IGEO(sc->mp);
>  	xfs_agnumber_t		agno = sc->sm->sm_agno;
>  	xfs_agblock_t		agbno;
>  	xfs_agblock_t		eoag;
> @@ -880,7 +881,7 @@ xchk_agi(
>  		xchk_block_set_corrupt(sc, sc->sa.agi_bp);
>  
>  	level = be32_to_cpu(agi->agi_level);
> -	if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
> +	if (level <= 0 || level > igeo->inobt_maxlevels)
>  		xchk_block_set_corrupt(sc, sc->sa.agi_bp);
>  
>  	if (xfs_has_finobt(mp)) {
> @@ -889,7 +890,7 @@ xchk_agi(
>  			xchk_block_set_corrupt(sc, sc->sa.agi_bp);
>  
>  		level = be32_to_cpu(agi->agi_free_level);
> -		if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
> +		if (level <= 0 || level > igeo->inobt_maxlevels)
>  			xchk_block_set_corrupt(sc, sc->sa.agi_bp);
>  	}
>
diff mbox series

Patch

diff --git a/fs/xfs/scrub/agheader.c b/fs/xfs/scrub/agheader.c
index ae3c9f6e2c69..a2c3af77b6c2 100644
--- a/fs/xfs/scrub/agheader.c
+++ b/fs/xfs/scrub/agheader.c
@@ -555,11 +555,11 @@  xchk_agf(
 		xchk_block_set_corrupt(sc, sc->sa.agf_bp);
 
 	level = be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]);
-	if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
+	if (level <= 0 || level > mp->m_ag_maxlevels)
 		xchk_block_set_corrupt(sc, sc->sa.agf_bp);
 
 	level = be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]);
-	if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
+	if (level <= 0 || level > mp->m_ag_maxlevels)
 		xchk_block_set_corrupt(sc, sc->sa.agf_bp);
 
 	if (xfs_has_rmapbt(mp)) {
@@ -568,7 +568,7 @@  xchk_agf(
 			xchk_block_set_corrupt(sc, sc->sa.agf_bp);
 
 		level = be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]);
-		if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
+		if (level <= 0 || level > mp->m_rmap_maxlevels)
 			xchk_block_set_corrupt(sc, sc->sa.agf_bp);
 	}
 
@@ -578,7 +578,7 @@  xchk_agf(
 			xchk_block_set_corrupt(sc, sc->sa.agf_bp);
 
 		level = be32_to_cpu(agf->agf_refcount_level);
-		if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
+		if (level <= 0 || level > mp->m_refc_maxlevels)
 			xchk_block_set_corrupt(sc, sc->sa.agf_bp);
 	}
 
@@ -850,6 +850,7 @@  xchk_agi(
 	struct xfs_mount	*mp = sc->mp;
 	struct xfs_agi		*agi;
 	struct xfs_perag	*pag;
+	struct xfs_ino_geometry	*igeo = M_IGEO(sc->mp);
 	xfs_agnumber_t		agno = sc->sm->sm_agno;
 	xfs_agblock_t		agbno;
 	xfs_agblock_t		eoag;
@@ -880,7 +881,7 @@  xchk_agi(
 		xchk_block_set_corrupt(sc, sc->sa.agi_bp);
 
 	level = be32_to_cpu(agi->agi_level);
-	if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
+	if (level <= 0 || level > igeo->inobt_maxlevels)
 		xchk_block_set_corrupt(sc, sc->sa.agi_bp);
 
 	if (xfs_has_finobt(mp)) {
@@ -889,7 +890,7 @@  xchk_agi(
 			xchk_block_set_corrupt(sc, sc->sa.agi_bp);
 
 		level = be32_to_cpu(agi->agi_free_level);
-		if (level <= 0 || level > XFS_BTREE_MAXLEVELS)
+		if (level <= 0 || level > igeo->inobt_maxlevels)
 			xchk_block_set_corrupt(sc, sc->sa.agi_bp);
 	}