This is a note to let you know that I've just added the patch titled xfs: fix soft lockup via spinning in filestream ag selection loop 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-fix-soft-lockup-via-spinning-in-filestream-ag-selection-loop.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:29 -0700 Subject: xfs: fix soft lockup via spinning in filestream ag selection loop To: stable@xxxxxxxxxxxxxxx Cc: linux-xfs@xxxxxxxxxxxxxxx, amir73il@xxxxxxxxx, Brian Foster <bfoster@xxxxxxxxxx>, "Darrick J . Wong" <djwong@xxxxxxxxxx>, Christoph Hellwig <hch@xxxxxx>, Dave Chinner <david@xxxxxxxxxxxxx>, Leah Rumancik <leah.rumancik@xxxxxxxxx> Message-ID: <20220819181431.4113819-8-leah.rumancik@xxxxxxxxx> From: Brian Foster <bfoster@xxxxxxxxxx> [ Upstream commit f650df7171b882dca737ddbbeb414100b31f16af ] The filestream AG selection loop uses pagf data to aid in AG selection, which depends on pagf initialization. If the in-core structure is not initialized, the caller invokes the AGF read path to do so and carries on. If another task enters the loop and finds a pagf init already in progress, the AGF read returns -EAGAIN and the task continues the loop. This does not increment the current ag index, however, which means the task spins on the current AGF buffer until unlocked. If the AGF read I/O submitted by the initial task happens to be delayed for whatever reason, this results in soft lockup warnings via the spinning task. This is reproduced by xfs/170. To avoid this problem, fix the AGF trylock failure path to properly iterate to the next AG. If a task iterates all AGs without making progress, the trylock behavior is dropped in favor of blocking locks and thus a soft lockup is no longer possible. Fixes: f48e2df8a877ca1c ("xfs: make xfs_*read_agf return EAGAIN to ALLOC_FLAG_TRYLOCK callers") Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx> Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> Signed-off-by: Dave Chinner <david@xxxxxxxxxxxxx> 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_filestream.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/fs/xfs/xfs_filestream.c +++ b/fs/xfs/xfs_filestream.c @@ -128,11 +128,12 @@ xfs_filestream_pick_ag( if (!pag->pagf_init) { err = xfs_alloc_pagf_init(mp, NULL, ag, trylock); if (err) { - xfs_perag_put(pag); - if (err != -EAGAIN) + if (err != -EAGAIN) { + xfs_perag_put(pag); return err; + } /* Couldn't lock the AGF, skip this AG. */ - continue; + goto next_ag; } } 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