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.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-fix-soft-lockup-via-spinning-in-filestream-ag-selection-loop.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:55 +0300 Subject: xfs: fix soft lockup via spinning in filestream ag selection loop 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, Brian Foster <bfoster@xxxxxxxxxx>, Christoph Hellwig <hch@xxxxxx>, Dave Chinner <david@xxxxxxxxxxxxx> Message-ID: <20220901133356.2473299-5-amir73il@xxxxxxxxx> From: Brian Foster <bfoster@xxxxxxxxxx> commit f650df7171b882dca737ddbbeb414100b31f16af upstream. 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: Amir Goldstein <amir73il@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 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