From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 2/4] xfs: don't stall background reclaim on inactvation
Date: Mon, 19 Dec 2022 16:05:08 -0800 [thread overview]
Message-ID: <167149470870.336919.10695086693636688760.stgit@magnolia> (raw)
In-Reply-To: <167149469744.336919.13748690081866673267.stgit@magnolia>
From: Darrick J. Wong <djwong@kernel.org>
The online fsck stress tests deadlocked a test VM the other night. The
deadlock happened because:
1. kswapd tried to prune the sb inode list, xfs found that it needed to
inactivate an inode and that the queue was long enough that it should
wait for the worker. It was holding shrinker_rwsem.
2. The inactivation worker allocated a transaction and then stalled
trying to obtain the AGI buffer lock.
3. An online repair function called unregister_shrinker while in
transaction context and holding the AGI lock. It also tried to grab
shrinker_rwsem.
#3 shouldn't happen and was easily fixed, but seeing as we designed
background inodegc to avoid stalling reclaim, I feel that #1 shouldn't
be happening either. Fix xfs_inodegc_want_flush_work to avoid stalling
background reclaim on inode inactivation.
Fixes: ab23a7768739 ("xfs: per-cpu deferred inode inactivation queues")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/xfs_icache.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index f35e2cee5265..24eff2bd4062 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -2000,6 +2000,8 @@ xfs_inodegc_want_queue_work(
*
* Note: If the current thread is running a transaction, we don't ever want to
* wait for other transactions because that could introduce a deadlock.
+ *
+ * Don't let kswapd background reclamation stall on inactivations.
*/
static inline bool
xfs_inodegc_want_flush_work(
@@ -2010,6 +2012,9 @@ xfs_inodegc_want_flush_work(
if (current->journal_info)
return false;
+ if (current_is_kswapd())
+ return false;
+
if (shrinker_hits > 0)
return true;
next prev parent reply other threads:[~2022-12-20 0:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-20 0:04 [PATCHSET 0/4] xfs: random fixes for 6.2, part 3 Darrick J. Wong
2022-12-20 0:05 ` [PATCH 1/4] xfs: don't assert if cmap covers imap after cycling lock Darrick J. Wong
2022-12-20 4:49 ` Dave Chinner
2022-12-20 0:05 ` Darrick J. Wong [this message]
2022-12-20 4:49 ` [PATCH 2/4] xfs: don't stall background reclaim on inactvation Dave Chinner
2022-12-20 16:28 ` Darrick J. Wong
2022-12-20 0:05 ` [PATCH 3/4] xfs: make xfs_iomap_page_ops static Darrick J. Wong
2022-12-20 4:49 ` Dave Chinner
2022-12-20 0:05 ` [PATCH 4/4] xfs: fix off-by-one error in xfs_btree_space_to_height Darrick J. Wong
2022-12-20 5:00 ` Dave Chinner
2022-12-20 16:10 ` Darrick J. Wong
2022-12-20 16:20 ` Darrick J. Wong
2022-12-20 20:39 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=167149470870.336919.10695086693636688760.stgit@magnolia \
--to=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.