Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f99694b authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim
Browse files

f2fs: avoid casted negative value as shrink count



commit 02110a4fd53164db7cce3bb2780dce4d6c4e058f upstream.

This patch makes sure it returns a positive value instead of a probable
casted negative value as shrink count.

Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent e07f457e
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -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)