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.15-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.15 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 Tue Aug 23 09:20:27 AM CEST 2022 From: Leah Rumancik <leah.rumancik@xxxxxxxxx> Date: Fri, 19 Aug 2022 11:14:27 -0700 Subject: xfs: always succeed at setting the reserve pool size To: stable@xxxxxxxxxxxxxxx Cc: linux-xfs@xxxxxxxxxxxxxxx, amir73il@xxxxxxxxx, "Darrick J. Wong" <djwong@xxxxxxxxxx>, Dave Chinner <dchinner@xxxxxxxxxx>, Leah Rumancik <leah.rumancik@xxxxxxxxx> Message-ID: <20220819181431.4113819-6-leah.rumancik@xxxxxxxxx> From: "Darrick J. Wong" <djwong@xxxxxxxxxx> [ Upstream commit 0baa2657dc4d79202148be79a3dc36c35f425060 ] 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: Leah Rumancik <leah.rumancik@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 @@ -434,11 +434,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 @@ -455,10 +458,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 leah.rumancik@xxxxxxxxx are queue-5.15/xfs-remove-infinite-loop-when-reserving-free-block-pool.patch queue-5.15/xfs-reserve-quota-for-target-dir-expansion-when-renaming-files.patch queue-5.15/xfs-fix-soft-lockup-via-spinning-in-filestream-ag-selection-loop.patch queue-5.15/xfs-flush-inodegc-workqueue-tasks-before-cancel.patch queue-5.15/xfs-revert-xfs-actually-bump-warning-counts-when-we-send-warnings.patch queue-5.15/xfs-reserve-quota-for-dir-expansion-when-linking-unlinking-files.patch queue-5.15/xfs-fix-overfilling-of-reserve-pool.patch queue-5.15/xfs-reject-crazy-array-sizes-being-fed-to-xfs_ioc_getbmap.patch queue-5.15/xfs-always-succeed-at-setting-the-reserve-pool-size.patch