From: Chao Yu <chao@kernel.org>
To: Zhiguo Niu <niuzhiguo84@gmail.com>
Cc: chao@kernel.org, jaegeuk@kernel.org, stable@kernel.org,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: fix to avoid potential deadloop in f2fs_fsync_node_pages()
Date: Wed, 9 Sep 2026 10:03:50 +0800 [thread overview]
Message-ID: <c5d29b31-e764-4782-9639-be84b1b2bfc2@kernel.org> (raw)
In-Reply-To: <CAHJ8P3+KBs1cQnDPsfpHOyjxNA+JNQ5DPCbrF_JqTLcmoyzB1w@mail.gmail.com>
On 9/9/26 09:12, Zhiguo Niu wrote:
> Chao Yu via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
> 于2026年8月24日周一 21:19写道:
>>
>> There is potential deadloop in race condition:
>>
>> Thread A Thread B
>> - fsync
>> - f2fs_do_sync_file
>> - f2fs_fsync_node_pages
>> - last_fsync_dnode
>> - folio_get(last_folio)
>> - f2fs_setattr
>> - f2fs_truncate
>> - f2fs_truncate_blocks
>> - f2fs_do_truncate_blocks
>> - f2fs_truncate_inode_blocks
>> - truncate_dnode
>> - truncate_node
>> - invalidate_mapping_pages
>> - folio->mapping = NULL
>> - is_node_folio alwasy return false
>> - atomic && !marked is always true,
>> then goto retry
>>
>> Cc: stable@kernel.org
>> Fixes: 608514deba38 ("f2fs: set fsync mark only for the last dnode")
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>> fs/f2fs/node.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
>> index 968e5ed38816..86c2e67e43b6 100644
>> --- a/fs/f2fs/node.c
>> +++ b/fs/f2fs/node.c
>> @@ -2016,6 +2016,11 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
>> f2fs_debug(sbi, "Retry to write fsync mark: ino=%u, idx=%lx",
>> ino, last_folio->index);
>> folio_lock(last_folio);
>> + if (unlikely(!is_node_folio(last_folio))) {
> Hi Chao,
> is_node_folio->NODE_MAPPING(F2FS_F_SB(folio))->F2FS_M_SB(folio->mappping)->F2FS_I_SB(mapping->host)
> if mapping==NULL, panic will occur here?
> just like commit msg in mai: "f2fs: parameterize node helpers and macros"
Hi Zhiguo,
Ah, seems we need to revert ("f2fs: introduce is_{meta,node}_folio") which
introduce this bug? IIUC.
Thanks,
> thanks!
>
>> + f2fs_folio_put(last_folio, true);
>> + ret = -EAGAIN;
>> + goto out;
>> + }
>> f2fs_folio_wait_writeback(last_folio, NODE, true, true);
>> folio_mark_dirty(last_folio);
>> folio_unlock(last_folio);
>> --
>> 2.49.0
>>
>>
>>
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2026-09-09 2:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 13:17 Chao Yu
2026-08-25 15:40 ` [f2fs-dev] " patchwork-bot+f2fs
2026-09-09 1:12 ` Zhiguo Niu
2026-09-09 2:03 ` Chao Yu [this message]
2026-09-09 2:12 ` Zhiguo Niu
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=c5d29b31-e764-4782-9639-be84b1b2bfc2@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=niuzhiguo84@gmail.com \
--cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®