[PATCH] f2fs: avoid cache writeback busy loop with zero thresholds

From: Wenjie Qi

Date: Thu Oct 08 2026 - 23:55:04 EST


When both cache writeback thresholds are zero,
f2fs_should_wake_up_cache_wb() returns true even with no dirty caches.
This makes wait_event_freezable_timeout() return immediately and the
writeback thread busy-loop instead of waiting for its periodic timeout.

Return false when both thresholds are disabled so periodic writeback
can proceed without busy-looping.

Fixes: d7f084b1ad93 ("f2fs: cache: wake up f2fs_writeback when exceeding threshold")
Signed-off-by: Wenjie Qi <qiwenjie@xxxxxxxxxx>
---
Based on f2fs/dev-test at ce439a2b0690.

fs/f2fs/cache.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/cache.c b/fs/f2fs/cache.c
index c76c4660606c5..88d4e479c8469 100644
--- a/fs/f2fs/cache.c
+++ b/fs/f2fs/cache.c
@@ -740,7 +740,8 @@ static inline bool f2fs_should_wake_up_cache_wb(struct f2fs_sb_info *sbi)
nr_dirty < cache_thread->cache_wb_dirty_threshold)
return false;

- return true;
+ return cache_thread->cache_wb_total_threshold ||
+ cache_thread->cache_wb_dirty_threshold;
}

static int f2fs_cache_writeback_kthread(void *data)
--
2.43.0