]> git.hungrycats.org Git - linux/commitdiff
xfs: reduce new btree slack factor if free space is negative
authorDarrick J. Wong <djwong@kernel.org>
Tue, 13 Oct 2026 06:06:14 +0000 (23:06 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:06:01 +0000 (12:06 -0500)
commit 80f13dc7225eec318da7499c7a562d7a34d25e6a upstream.

LOLLM points out that if the incore fdblocks counter is negative, the
assignment to uint64_t will mask this possibly low space situation and
we don't pack the btree blocks as tightly as we probably ought to.  If
it's the case that there's some free space and fdblocks is too low due
to an error in the superblock field, then we can end up failing btree
rebuilds due to ENOSPC unnecessarily.  This is a corner case, but let's
fix it anyway.

Cc: stable@vger.kernel.org # v6.8
Fixes: be408417630427 ("xfs: implement block reservation accounting for btrees we're staging")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Assisted-by: LOLLM # finding obvious bugs
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/scrub/newbt.c

index 2a9547789c5c1ab5ef9f49a0ee676ecdf2679592..bdcdc87fb227a74d7aca29d9c6e4eae933803341 100644 (file)
@@ -71,7 +71,7 @@ xrep_newbt_estimate_slack(
                free = sc->sa.pag->pagf_freeblks;
                sz = xfs_ag_block_count(sc->mp, pag_agno(sc->sa.pag));
        } else {
-               free = xfs_sum_freecounter_raw(sc->mp, XC_FREE_BLOCKS);
+               free = xfs_sum_freecounter(sc->mp, XC_FREE_BLOCKS);
                sz = sc->mp->m_sb.sb_dblocks;
        }