[PATCH 32/36] xfs: fix minor bug in xfs_verify_agbno

Darrick J. Wong
2024-10-11T01:10:01Z

There's a minor bug in xfs_verify_agbno -- min_block ought to be the
first agblock number in the AG that can be used by non-static metadata.
Unfortunately, we set it to the last agblock of the static metadata.
Fortunately this works due to the <= check, but this isn't technically
correct.

Instead, change the check to < and set it to the next agblock past the
static metadata. This hasn't been an issue up to now, but we're going
to move these things into the generic group struct, and this will cause
problems with rtgroups, where min_block can be zero for an rtgroup.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/libxfs/xfs_ag.c | 2 +-
fs/xfs/libxfs/xfs_ag.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
index a0b2b54309522f..ebf645a3dd8963 100644
--- a/fs/xfs/libxfs/xfs_ag.c
+++ b/fs/xfs/libxfs/xfs_ag.c
@@ -221,7 +221,7 @@ xfs_perag_alloc(
* Pre-calculated geometry
*/
pag->block_count = __xfs_ag_block_count(mp, index, agcount, dblocks);
- pag->min_block = XFS_AGFL_BLOCK(mp);
+ pag->min_block = XFS_AGFL_BLOCK(mp) + 1;
__xfs_agino_range(mp, pag->block_count, &pag->agino_min,
&pag->agino_max);

diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h
index 242346872351c1..1671cd5ce3020a 100644
--- a/fs/xfs/libxfs/xfs_ag.h
+++ b/fs/xfs/libxfs/xfs_ag.h
@@ -216,7 +216,7 @@ xfs_verify_agbno(struct xfs_perag *pag, xfs_agblock_t agbno)
{
if (agbno >= pag->block_count)
return false;
- if (agbno <= pag->min_block)
+ if (agbno < pag->min_block)
return false;
return true;
}