f2fs: fix to return SHRINK_EMPTY if no objects to free
authorZhiguo Niu <zhiguo.niu@unisoc.com>
Mon, 10 Feb 2025 01:24:09 +0000 (09:24 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 10 Feb 2025 17:03:19 +0000 (17:03 +0000)
Quoted from include/linux/shrinker.h
"count_objects should return the number of freeable items in the cache. 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: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/shrinker.c

index 83d6fb97dcae0f84ff6bd76ad389198a5660a5c7..fc1bbef418ce930cedf0e823d29caed1f168768e 100644 (file)
@@ -73,7 +73,7 @@ unsigned long f2fs_shrink_count(struct shrinker *shrink,
                mutex_unlock(&sbi->umount_mutex);
        }
        spin_unlock(&f2fs_list_lock);
-       return count;
+       return count ?: SHRINK_EMPTY;
 }
 
 unsigned long f2fs_shrink_scan(struct shrinker *shrink,