[PATCH 19/20] f2fs: count compress cache entries in pages for its memory limit
From: Daeho Jeong
Date: Mon Nov 02 2026 - 14:44:56 EST
From: Daeho Jeong <daehojeong@xxxxxxxxxx>
The compress cache holds one filesystem block per entry, but
f2fs_available_free_memory() compares the number of entries with a
percentage of free memory counted in pages. With subpage blocks, this
limits the compress cache to a fraction (block size / PAGE_SIZE) of
the memory that compress_percent allows. Convert the entry count to
pages before the comparison.
No functional change when the block size equals PAGE_SIZE.
Signed-off-by: Daeho Jeong <daehojeong@xxxxxxxxxx>
---
fs/f2fs/node.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index b95bb5c27b0b..66b28ae91756 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -116,10 +116,12 @@ bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
/*
* free memory is lower than watermark or cached page count
- * exceed threshold, deny caching compress page.
+ * exceed threshold, deny caching compress page. A cache
+ * entry holds one block, so convert the entry count to pages.
*/
res = (free_ram > avail_ram * sbi->compress_watermark / 100) &&
- (COMPRESS_CACHE(sbi)->num_entries <
+ ((COMPRESS_CACHE(sbi)->num_entries >>
+ F2FS_LOG_BLKS_PER_PAGE(sbi)) <
free_ram * sbi->compress_percent / 100);
#else
res = false;
--
2.56.0.317.g454f8302e1-goog