On Sun, Mar 20, 2022 at 09:43:43AM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > xfs_reserve_blocks controls the size of the user-visible free space > reserve pool. Given the difference between the current and requested > pool sizes, it will try to reserve free space from fdblocks. However, > the amount requested from fdblocks is also constrained by the amount of > space that we think xfs_mod_fdblocks will give us. We'll keep trying to > reserve space so long as xfs_mod_fdblocks returns ENOSPC. > > In commit fd43cf600cf6, we decided that xfs_mod_fdblocks should not hand > out the "free space" used by the free space btrees, because some portion > of the free space btrees hold in reserve space for future btree > expansion. Unfortunately, xfs_reserve_blocks' estimation of the number > of blocks that it could request from xfs_mod_fdblocks was not updated to > include m_allocbt_blks, so if space is extremely low, the caller hangs. > > Fix this by creating a function to estimate the number of blocks that > can be reserved from fdblocks, which needs to exclude the set-aside and > m_allocbt_blks. > > Found by running xfs/306 (which formats a single-AG 20MB filesystem) > with an fstests configuration that specifies a 1k blocksize and a > specially crafted log size that will consume 7/8 of the space (17920 > blocks, specifically) in that AG. > > Cc: Brian Foster <bfoster@xxxxxxxxxx> > Fixes: fd43cf600cf6 ("xfs: set aside allocation btree blocks from block reservation") > Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> Looks fine. Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx> -- Dave Chinner david@xxxxxxxxxxxxx