]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
erofs: return SHRINK_EMPTY if no objects to free
authorChen Linxuan <chenlinxuan@uniontech.com>
Thu, 16 Jan 2025 08:33:02 +0000 (16:33 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 16 Jan 2025 19:24:30 +0000 (03:24 +0800)
Comments in file include/linux/shrinker.h says that
`count_objects` of `struct shrinker` should return SHRINK_EMPTY
when there are no objects to free.

> If there are no objects to free, it should return SHRINK_EMPTY,
> while 0 is returned in cases of the number of freeable items cannot
> be determined or shrinker should skip this cache for this time
> (e.g., their number is below shrinkable limit).

Signed-off-by: Chen Linxuan <chenlinxuan@uniontech.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/149E6E64B5B6B5E8+20250116083303.199817-1-chenlinxuan@uniontech.com
[ Gao Xiang: should have no impact since it's not memcg-aware. ]
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/zutil.c

index 0dd65cefce33e22acb7a23e6bc91413fceeb0c7b..83fbcab70a920f9337f4c0c168b8baa0caabb723 100644 (file)
@@ -243,7 +243,7 @@ void erofs_shrinker_unregister(struct super_block *sb)
 static unsigned long erofs_shrink_count(struct shrinker *shrink,
                                        struct shrink_control *sc)
 {
-       return atomic_long_read(&erofs_global_shrink_cnt);
+       return atomic_long_read(&erofs_global_shrink_cnt) ?: SHRINK_EMPTY;
 }
 
 static unsigned long erofs_shrink_scan(struct shrinker *shrink,