From: Li Chen <me@linux.beauty>
To: "Jan Kara" <jack@suse.cz>
Cc: "Theodore Ts'o" <tytso@mit.edu>,
"Andreas Dilger" <adilger.kernel@dilger.ca>,
"Harshad Shirwadkar" <harshadshirwadkar@gmail.com>,
"linux-ext4" <linux-ext4@vger.kernel.org>,
"linux-kernel" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ext4: fast commit: avoid fs_reclaim inversion in perform_commit
Date: Tue, 06 Jan 2026 20:14:37 +0800 [thread overview]
Message-ID: <19b933b0448.619d63104490112.7140925865813405260@linux.beauty> (raw)
In-Reply-To: <jdssgnr44c6scnzhpbl7gwgcpo2f25n3cxaaw6fo2uzh3bdwda@ograleyyoyot>
Hi Jan,
---- On Tue, 06 Jan 2026 00:17:31 +0800 Jan Kara <jack@suse.cz> wrote ---
> On Tue 23-12-25 21:13:42, Li Chen wrote:
> > lockdep reports a possible deadlock due to lock order inversion:
> >
> > CPU0 CPU1
> > ---- ----
> > lock(fs_reclaim);
> > lock(&sbi->s_fc_lock);
> > lock(fs_reclaim);
> > lock(&sbi->s_fc_lock);
> >
> > ext4_fc_perform_commit() holds s_fc_lock while writing the fast commit
> > log. Allocations here can enter reclaim and take fs_reclaim, inverting
> > with ext4_fc_del() which runs under fs_reclaim during inode eviction.
> > Wrap Step 6 in memalloc_nofs_save()/restore() so reclaim is skipped
> > while s_fc_lock is held.
> >
> > Fixes: 6593714d67ba ("ext4: hold s_fc_lock while during fast commit")
> > Signed-off-by: Li Chen <me@linux.beauty>
>
> Thanks for the analysis and the patch! Your solution is in principle
> correct but it's a bit fragile because there can be other instances (or we
> can grow them in the future) where sbi->s_fc_lock is held when doing
> allocation. The situation is that sbi->s_fc_lock can be acquired from inode
> eviction path (ext4_clear_inode()) and thus this lock is inherently reclaim
> unsafe. What we do in such cases is that we create helper functions for
> acquiring / releasing the lock while also setting proper context and using
> these helpers - like in commit 00d873c17e29 ("ext4: avoid deadlock in fs
> reclaim with page writeback"). Can you perhaps modify your patch to follow
> that behavior as well?
Thanks a lot for your suggestion, I have added helpers here: https://lore.kernel.org/linux-ext4/20260106120621.440126-1-me@linux.beauty/T/#u
Please take a look, thanks.
(But I didn't add v2 reroll count there, because I mistakenly remembered that this was an RFC, sorry for this)
Regards,
Li
prev parent reply other threads:[~2026-01-06 12:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-23 13:13 [PATCH] ext4: fast commit: avoid fs_reclaim inversion in perform_commit Li Chen
2026-01-05 16:17 ` Jan Kara
2026-01-06 12:14 ` Li Chen [this message]
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=19b933b0448.619d63104490112.7140925865813405260@linux.beauty \
--to=me@linux.beauty \
--cc=adilger.kernel@dilger.ca \
--cc=harshadshirwadkar@gmail.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox