summaryrefslogtreecommitdiffstats
path: root/fs/f2fs/shrinker.c
diff options
context:
space:
mode:
authorChao Yu2016-10-11 16:31:36 +0200
committerJaegeuk Kim2016-11-23 21:11:03 +0100
commit02110a4fd53164db7cce3bb2780dce4d6c4e058f (patch)
treec972ca4ed2811563e314963cde480af791459f32 /fs/f2fs/shrinker.c
parentf2fs: don't interrupt free nids building during nid allocation (diff)
downloadkernel-qcow2-linux-02110a4fd53164db7cce3bb2780dce4d6c4e058f.tar.gz
kernel-qcow2-linux-02110a4fd53164db7cce3bb2780dce4d6c4e058f.tar.xz
kernel-qcow2-linux-02110a4fd53164db7cce3bb2780dce4d6c4e058f.zip
f2fs: avoid casted negative value as shrink count
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>
Diffstat (limited to 'fs/f2fs/shrinker.c')
-rw-r--r--fs/f2fs/shrinker.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
index ec539f407cc4..5c60fc28ec75 100644
--- a/fs/f2fs/shrinker.c
+++ b/fs/f2fs/shrinker.c
@@ -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)