Re: [f2fs-dev] [PATCH v2] f2fs: fix livelock in syncing dirty inodes
From: Chao Yu
Date: Wed Sep 09 2026 - 21:47:09 EST
On 9/10/26 03:06, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@xxxxxxxxxx>
>
> During checkpoint, f2fs_sync_dirty_inodes() and f2fs_sync_inode_meta()
> iterate over dirty inodes in their respective lists. If igrab() fails on
> an inode (e.g. because it is in the freeing state), the loop continues
> without moving the current inode to the tail of the list. As a result,
> subsequent iterations pick the same inode repeatedly, preventing other
> ready dirty inodes in the list from making forward progress and leading
> to a livelock.
>
> Fix this by moving the current inode to the tail of the list
> (list_move_tail(&fi->{dirty_list,gdirty_list}, head)) before attempting
> igrab() in both f2fs_sync_dirty_inodes() and f2fs_sync_inode_meta().
>
> Additionally, if igrab() fails, yield the CPU with cond_resched() to
> allow the evicting thread to finish eviction. Remove the redundant
> f2fs_submit_merged_write() call, since .writepages already submits cached
> bios via f2fs_submit_merged_write_cond().
>
> v2:
> - Also apply list_move_tail() to f2fs_sync_dirty_inodes().
> - Remove redundant f2fs_submit_merged_write() calls from both functions,
> keeping only cond_resched().
> - Update commit title and description.
>
> Signed-off-by: Daeho Jeong <daehojeong@xxxxxxxxxx>
Reviewed-by: Chao Yu <chao@xxxxxxxxxx>
Thanks,