From: Chao Yu <chao@kernel.org>
To: Wenjie Qi <qwjhust@gmail.com>, jaegeuk@kernel.org
Cc: chao@kernel.org, ruipengqi3@gmail.com,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, qiwenjie@xiaomi.com
Subject: Re: [PATCH] f2fs: submit cached data bios before gc_merge GC
Date: Thu, 21 May 2026 16:39:42 +0800 [thread overview]
Message-ID: <353a532f-6e22-4aed-8cf8-680c67685754@kernel.org> (raw)
In-Reply-To: <20260521053050.1785858-1-qiwenjie@xiaomi.com>
I've submitted the same fix previously as below:
https://lore.kernel.org/linux-f2fs-devel/20260519011438.1168155-1-chao@kernel.org
On 5/21/26 13:30, Wenjie Qi wrote:
> Commit fefdf0723650 ("f2fs: fix potential deadlock in f2fs_balance_fs()")
> added cached DATA bio submission before direct foreground GC in
> f2fs_balance_fs().
>
> This avoids a deadlock between writeback and GC on cached data folios.
> However, when gc_merge is enabled, f2fs_balance_fs() does not execute
> foreground GC in the caller. It wakes the background GC thread and waits
> for that foreground request to finish.
>
> That branch currently skips the cached DATA bio submission, so the same
> foreground GC request can still start with cached DATA bios pending.
>
> Move the cached DATA bio submission before the gc_merge branch so both
> direct and merged foreground GC paths satisfy the same precondition.
>
> Fixes: fefdf0723650 ("f2fs: fix potential deadlock in f2fs_balance_fs()")
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
> ---
> fs/f2fs/segment.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 7c8ac62b1b0..1ef4edb7707 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -445,6 +445,13 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
> if (has_enough_free_secs(sbi, 0, 0))
> return;
>
> + /*
> + * Submit all cached OPU/IPU DATA bios before triggering
> + * foreground GC to avoid potential deadlocks.
> + */
> + f2fs_submit_merged_write(sbi, DATA);
> + f2fs_submit_all_merged_ipu_writes(sbi);
> +
> if (test_opt(sbi, GC_MERGE) && sbi->gc_thread &&
> sbi->gc_thread->f2fs_gc_task) {
> DEFINE_WAIT(wait);
> @@ -464,13 +471,6 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
> .err_gc_skipped = false,
> .nr_free_secs = 1 };
>
> - /*
> - * Submit all cached OPU/IPU DATA bios before triggering
> - * foreground GC to avoid potential deadlocks.
> - */
> - f2fs_submit_merged_write(sbi, DATA);
> - f2fs_submit_all_merged_ipu_writes(sbi);
> -
> f2fs_down_write_trace(&sbi->gc_lock, &gc_control.lc);
> stat_inc_gc_call_count(sbi, FOREGROUND);
> f2fs_gc(sbi, &gc_control);
next prev parent reply other threads:[~2026-05-21 8:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 5:30 Wenjie Qi
2026-05-21 8:39 ` Chao Yu [this message]
2026-05-22 4:30 ` [f2fs-dev] " patchwork-bot+f2fs
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=353a532f-6e22-4aed-8cf8-680c67685754@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=qiwenjie@xiaomi.com \
--cc=qwjhust@gmail.com \
--cc=ruipengqi3@gmail.com \
/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
Powered by JetHome