]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: adjust min_block usage in xfs_verify_agbno
authorDarrick J. Wong <djwong@kernel.org>
Mon, 4 Nov 2024 04:19:34 +0000 (20:19 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 5 Nov 2024 21:38:44 +0000 (13:38 -0800)
There's some weird logic in xfs_verify_agbno -- min_block ought to be
the first agblock number in the AG that can be used by non-static
metadata.  However, we initialize it to the last agblock of the static
metadata, which works due to the <= check, even though this isn't
technically correct.

Change the check to < and set min_block 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 that
doesn't have a rt superblock.

Note that there's no user-visible impact with the old logic, so this
isn't a bug fix.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_ag.c
fs/xfs/libxfs/xfs_ag.h

index 47e90dbb852bba76ff456aa022785fda6ef8de1a..8fe96a9e047205264b0fdaee16d715182ac41f08 100644 (file)
@@ -242,7 +242,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);
 
index 7290148fa6e6aaeefe01d344b6950f841b4d8505..9c22a76d58cfc2f730340734facf045cce0e85ed 100644 (file)
@@ -222,7 +222,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;
 }