* [PATCH] f2fs: fix to avoid potential deadloop in f2fs_fsync_node_pages()
@ 2026-08-24 13:17 Chao Yu
2026-08-25 15:40 ` [f2fs-dev] " patchwork-bot+f2fs
0 siblings, 1 reply; 2+ messages in thread
From: Chao Yu @ 2026-08-24 13:17 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Chao Yu, stable
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))) {
+ 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: fix to avoid potential deadloop in f2fs_fsync_node_pages()
2026-08-24 13:17 [PATCH] f2fs: fix to avoid potential deadloop in f2fs_fsync_node_pages() Chao Yu
@ 2026-08-25 15:40 ` patchwork-bot+f2fs
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+f2fs @ 2026-08-25 15:40 UTC (permalink / raw)
To: Chao Yu; +Cc: jaegeuk, stable, linux-kernel, linux-f2fs-devel
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Mon, 24 Aug 2026 21:17:29 +0800 you wrote:
> 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
>
> [...]
Here is the summary with links:
- [f2fs-dev] f2fs: fix to avoid potential deadloop in f2fs_fsync_node_pages()
https://git.kernel.org/jaegeuk/f2fs/c/ce366bfa821e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-25 15:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24 13:17 [PATCH] f2fs: fix to avoid potential deadloop in f2fs_fsync_node_pages() Chao Yu
2026-08-25 15:40 ` [f2fs-dev] " patchwork-bot+f2fs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox