From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH 7/7] f2fs: avoid casted negative value as shrink count
Date: Tue, 11 Oct 2016 22:31:36 +0800 [thread overview]
Message-ID: <20161011143136.2107-7-chao@kernel.org> (raw)
In-Reply-To: <20161011143136.2107-1-chao@kernel.org>
From: Chao Yu <yuchao0@huawei.com>
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>
---
fs/f2fs/shrinker.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
index 8b0a112..e1220f2 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)->free_nid_cnt > MAX_FREE_NIDS)
- return NM_I(sbi)->free_nid_cnt - MAX_FREE_NIDS;
- return 0;
+ long count = NM_I(sbi)->free_nid_cnt - MAX_FREE_NIDS;
+
+ return count > 0 ? count : 0;
}
static unsigned long __count_extent_cache(struct f2fs_sb_info *sbi)
--
2.10.1
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
WARNING: multiple messages have this Message-ID (diff)
From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Chao Yu <yuchao0@huawei.com>
Subject: [PATCH 7/7] f2fs: avoid casted negative value as shrink count
Date: Tue, 11 Oct 2016 22:31:36 +0800 [thread overview]
Message-ID: <20161011143136.2107-7-chao@kernel.org> (raw)
In-Reply-To: <20161011143136.2107-1-chao@kernel.org>
From: Chao Yu <yuchao0@huawei.com>
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>
---
fs/f2fs/shrinker.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
index 8b0a112..e1220f2 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)->free_nid_cnt > MAX_FREE_NIDS)
- return NM_I(sbi)->free_nid_cnt - MAX_FREE_NIDS;
- return 0;
+ long count = NM_I(sbi)->free_nid_cnt - MAX_FREE_NIDS;
+
+ return count > 0 ? count : 0;
}
static unsigned long __count_extent_cache(struct f2fs_sb_info *sbi)
--
2.10.1
next prev parent reply other threads:[~2016-10-11 14:36 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-11 14:31 [PATCH 1/7] f2fs: split free nid list Chao Yu
2016-10-11 14:31 ` [PATCH 2/7] f2fs: clean up nid list operation Chao Yu
2016-10-11 14:31 ` Chao Yu
2016-10-11 14:31 ` [PATCH 3/7] f2fs: rename free nid cache operation Chao Yu
2016-10-11 14:31 ` Chao Yu
2016-10-11 17:19 ` Jaegeuk Kim
2016-10-11 17:19 ` Jaegeuk Kim
2016-10-12 15:14 ` Chao Yu
2016-10-12 15:14 ` Chao Yu
2016-10-12 17:15 ` Jaegeuk Kim
2016-10-12 17:15 ` Jaegeuk Kim
2016-10-13 10:26 ` Chao Yu
2016-10-13 10:26 ` Chao Yu
2016-10-11 14:31 ` [PATCH 4/7] f2fs: show pending allocated nids count in debugfs Chao Yu
2016-10-11 17:20 ` Jaegeuk Kim
2016-10-11 17:20 ` Jaegeuk Kim
2016-10-11 14:31 ` [PATCH 5/7] f2fs: exclude free nids building and allocation Chao Yu
2016-10-11 14:31 ` Chao Yu
2016-10-11 17:25 ` Jaegeuk Kim
2016-10-11 17:25 ` Jaegeuk Kim
2016-10-11 14:31 ` [PATCH 6/7] f2fs: don't interrupt free nids building during nid allocation Chao Yu
2016-10-11 14:31 ` Chao Yu [this message]
2016-10-11 14:31 ` [PATCH 7/7] f2fs: avoid casted negative value as shrink count Chao Yu
2016-10-11 17:09 ` [PATCH 1/7] f2fs: split free nid list Jaegeuk Kim
2016-10-11 17:09 ` Jaegeuk Kim
2016-10-12 1:14 ` Chao Yu
2016-10-12 1:14 ` Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161011143136.2107-7-chao@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.