This is a note to let you know that I've just added the patch titled xfs: always succeed at setting the reserve pool size to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-always-succeed-at-setting-the-reserve-pool-size.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Fri Sep 2 08:15:14 AM CEST 2022 From: Amir Goldstein <amir73il@xxxxxxxxx> Date: Thu, 1 Sep 2022 16:33:53 +0300 Subject: xfs: always succeed at setting the reserve pool size To: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Sasha Levin <sashal@xxxxxxxxxx>, "Darrick J . Wong" <djwong@xxxxxxxxxx>, Leah Rumancik <leah.rumancik@xxxxxxxxx>, Chandan Babu R <chandan.babu@xxxxxxxxxx>, Luis Chamberlain <mcgrof@xxxxxxxxxx>, Adam Manzanares <a.manzanares@xxxxxxxxxxx>, linux-xfs@xxxxxxxxxxxxxxx, stable@xxxxxxxxxxxxxxx, Dave Chinner <dchinner@xxxxxxxxxx> Message-ID: <20220901133356.2473299-3-amir73il@xxxxxxxxx> From: "Darrick J. Wong" <djwong@xxxxxxxxxx> commit 0baa2657dc4d79202148be79a3dc36c35f425060 upstream. Nowadays, xfs_mod_fdblocks will always choose to fill the reserve pool with freed blocks before adding to fdblocks. Therefore, we can change the behavior of xfs_reserve_blocks slightly -- setting the target size of the pool should always succeed, since a deficiency will eventually be made up as blocks get freed. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx> Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> Acked-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/xfs/xfs_fsops.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -380,11 +380,14 @@ xfs_reserve_blocks( * The code below estimates how many blocks it can request from * fdblocks to stash in the reserve pool. This is a classic TOCTOU * race since fdblocks updates are not always coordinated via - * m_sb_lock. + * m_sb_lock. Set the reserve size even if there's not enough free + * space to fill it because mod_fdblocks will refill an undersized + * reserve when it can. */ free = percpu_counter_sum(&mp->m_fdblocks) - xfs_fdblocks_unavailable(mp); delta = request - mp->m_resblks; + mp->m_resblks = request; if (delta > 0 && free > 0) { /* * We'll either succeed in getting space from the free block @@ -401,10 +404,8 @@ xfs_reserve_blocks( * Update the reserve counters if blocks have been successfully * allocated. */ - if (!error) { - mp->m_resblks += fdblks_delta; + if (!error) mp->m_resblks_avail += fdblks_delta; - } } out: if (outval) { Patches currently in stable-queue which might be from amir73il@xxxxxxxxx are queue-5.10/xfs-remove-infinite-loop-when-reserving-free-block-pool.patch queue-5.10/xfs-fix-soft-lockup-via-spinning-in-filestream-ag-selection-loop.patch queue-5.10/xfs-revert-xfs-actually-bump-warning-counts-when-we-send-warnings.patch queue-5.10/xfs-fix-overfilling-of-reserve-pool.patch queue-5.10/xfs-always-succeed-at-setting-the-reserve-pool-size.patch