From a6ede405455106bf42164ec96fd84008c5aabdd9 Mon Sep 17 00:00:00 2001 From: Wenjie Qi Date: Fri, 16 Oct 2026 13:44:05 +0800 Subject: [PATCH] f2fs: flush SIT journal during filesystem resize During a filesystem resize, SBI_IS_RESIZEFS prevents new SIT entries from being added to the journal and forces existing entries to the SIT area. However, f2fs_flush_sit_entries() returns early when there are no new dirty sentries, leaving existing journal entries behind. After the main area shrinks, a later checkpoint can access a journal entry whose segment number is outside the new geometry and trigger f2fs_bug_on(). Only take the zero-dirty fast path when entries may be written back to the journal. This lets resize drain existing entries through remove_sits_in_journal() even when there are no new dirty sentries. Cc: stable@kernel.org Fixes: 04f0b2eaa3b3 ("f2fs: ioctl for removing a range from F2FS") Signed-off-by: Wenjie Qi Reviewed-by: Daeho Jeong Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim --- fs/f2fs/segment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 25785b7626bb..bf8d07fcce33 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -4893,7 +4893,7 @@ void f2fs_flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) down_write(&sit_i->sentry_lock); - if (!sit_i->dirty_sentries) + if (!sit_i->dirty_sentries && to_journal) goto out; /*