From a45c9a0055f5ccff0c5c546e0478604b990f23ab Mon Sep 17 00:00:00 2001 From: Seongjae Jeong Date: Sat, 10 Oct 2026 07:49:12 +0000 Subject: [PATCH] f2fs: fix termination of f2fs_sync_meta_caches() When __f2fs_write_meta_cache() returns false in f2fs_sync_meta_caches(), the function only exits the inner loop instead of the entire while loop. This leads to an unnecessary lookup of the next batch. Also, when nwritten >= nr_to_write, only the inner loop terminates. This allows the function to continue processing subsequent batches after the writeback budget has been reached. Terminate the entire while loop in both cases to avoid unnecessary batch lookups and respect the writeback budget. Signed-off-by: Seongjae Jeong Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim --- fs/f2fs/checkpoint.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index fd0a6c03987e..5c5b45d3c67b 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -658,7 +658,8 @@ long f2fs_sync_meta_caches(struct f2fs_sb_info *sbi, long nr_to_write, if (!__f2fs_write_meta_cache(entry, io_type)) { f2fs_unlock_cache(entry); - break; + f2fs_cache_gang_release(entries, nr); + goto stop; } nwritten++; next = entry->index + 1; @@ -667,6 +668,9 @@ long f2fs_sync_meta_caches(struct f2fs_sb_info *sbi, long nr_to_write, } f2fs_cache_gang_release(entries, nr); cond_resched(); + + if (unlikely(nwritten >= nr_to_write)) + break; } stop: if (nwritten)