]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
f2fs: avoid casted negative value as shrink count
authorChao Yu <yuchao0@huawei.com>
Tue, 11 Oct 2016 14:31:36 +0000 (22:31 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 23 Nov 2016 20:11:03 +0000 (12:11 -0800)
This patch makes sure it returns a positive value instead of a probable
casted negative value as shrink count.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/shrinker.c

index ec539f407cc49ab7225a748be8e27ea536e3bc43..5c60fc28ec758894a56d7b73e1e830d03fe0f0fb 100644 (file)
@@ -21,14 +21,16 @@ static unsigned int shrinker_run_no;
 
 static unsigned long __count_nat_entries(struct f2fs_sb_info *sbi)
 {
-       return NM_I(sbi)->nat_cnt - NM_I(sbi)->dirty_nat_cnt;
+       long count = NM_I(sbi)->nat_cnt - NM_I(sbi)->dirty_nat_cnt;
+
+       return count > 0 ? count : 0;
 }
 
 static unsigned long __count_free_nids(struct f2fs_sb_info *sbi)
 {
-       if (NM_I(sbi)->nid_cnt[FREE_NID_LIST] > MAX_FREE_NIDS)
-               return NM_I(sbi)->nid_cnt[FREE_NID_LIST] - MAX_FREE_NIDS;
-       return 0;
+       long count = NM_I(sbi)->nid_cnt[FREE_NID_LIST] - MAX_FREE_NIDS;
+
+       return count > 0 ? count : 0;
 }
 
 static unsigned long __count_extent_cache(struct f2fs_sb_info *sbi)