]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs: clear incore AGFL_RESET state if it's not needed libxfs-sync-6.3_2023-04-02
authorDarrick J. Wong <djwong@kernel.org>
Tue, 21 Mar 2023 00:24:59 +0000 (17:24 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Apr 2023 00:13:34 +0000 (17:13 -0700)
commit121a749d4829f42128488eb5a58245f75c0c802f
tree7689ce9c10a1820d12c6fef434569f71902c3326
parent7fb0ebfbcf739ba7699b9686650927693f40d479
xfs: clear incore AGFL_RESET state if it's not needed

Prior to commit 7ac2ff8bb371, when we loaded the incore perag structure
with information from the AGF header, we would set or clear the
pagf_agfl_reset field based on whether or not the AGFL list was
misaligned within the block.  IOWs, it's an incore state bit that's
supposed to cache something in the ondisk metadata.  Therefore, the code
still needs to support clearing the incore bit if (somehow) the AGFL
were to correct itself.

It turns out that xfs_repair does exactly this -- phase 4 loads the AGF
to scan the rmapbt for corrupt records, which can set NEEDS_AGFL_RESET.
The scan unsets AGF_INIT but doesn't unset NEEDS_AGFL_RESET.  Phase 5
totally rewrites the AGFL and fixes the alignment problem, didn't clear
NEEDS_AGFL_RESET historically, and reloads the perag state to fix the
freelist.  This results in the AGFL being reset based on stale data,
which then causes the new AGFL blocks to be leaked.  A subsequent
xfs_repair -n then complains about the leaks.

One could argue that phase 5 ought to clear this bit directly when it
reloads the perag AGF data after rewriting the AGFL, but libxfs used to
handle this for us, so it should go back to doing that.

Found by fuzzing flfirst = ones in xfs/352.

Fixes: 7ac2ff8bb371 ("xfs: perags need atomic operational state")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
libxfs/xfs_alloc.c