From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: kernel-team@android.com, linux-kernel@vger.kernel.org,
Light Hsieh <Light.Hsieh@mediatek.com>,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v3] f2fs: avoid race condition for shinker count
Date: Tue, 17 Nov 2020 08:40:21 -0800 [thread overview]
Message-ID: <20201117164021.GA1636127@google.com> (raw)
In-Reply-To: <4aae85c2-1829-06c0-8fd1-4148100dc0b9@huawei.com>
On 11/12, Chao Yu wrote:
> On 2020/11/12 13:40, Jaegeuk Kim wrote:
> > Light reported sometimes shinker gets nat_cnt < dirty_nat_cnt resulting in
> > wrong do_shinker work. Let's avoid to get stale data by using nat_tree_lock.
> >
> > Reported-by: Light Hsieh <Light.Hsieh@mediatek.com>
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > v3:
> > - fix to use NM_I(sbi)
> >
> > fs/f2fs/shrinker.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
> > index d66de5999a26..555712ba06d8 100644
> > --- a/fs/f2fs/shrinker.c
> > +++ b/fs/f2fs/shrinker.c
> > @@ -18,7 +18,11 @@ static unsigned int shrinker_run_no;
> > static unsigned long __count_nat_entries(struct f2fs_sb_info *sbi)
> > {
> > - long count = NM_I(sbi)->nat_cnt - NM_I(sbi)->dirty_nat_cnt;
> > + long count;
> > +
> > + down_read(&NM_I(sbi)->nat_tree_lock);
> > + count = NM_I(sbi)->nat_cnt - NM_I(sbi)->dirty_nat_cnt;
> > + up_read(&NM_I(sbi)->nat_tree_lock);
> > return count > 0 ? count : 0;
>
> Minor thing,
>
> Just return count is enough? since count should never be smaller than 0.
Yeah, but let me keep this just in case.
>
> Anyway,
>
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
>
> Thanks,
>
> Thanks,
>
> > }
> >
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com,
Light Hsieh <Light.Hsieh@mediatek.com>
Subject: Re: [f2fs-dev] [PATCH v3] f2fs: avoid race condition for shinker count
Date: Tue, 17 Nov 2020 08:40:21 -0800 [thread overview]
Message-ID: <20201117164021.GA1636127@google.com> (raw)
In-Reply-To: <4aae85c2-1829-06c0-8fd1-4148100dc0b9@huawei.com>
On 11/12, Chao Yu wrote:
> On 2020/11/12 13:40, Jaegeuk Kim wrote:
> > Light reported sometimes shinker gets nat_cnt < dirty_nat_cnt resulting in
> > wrong do_shinker work. Let's avoid to get stale data by using nat_tree_lock.
> >
> > Reported-by: Light Hsieh <Light.Hsieh@mediatek.com>
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > v3:
> > - fix to use NM_I(sbi)
> >
> > fs/f2fs/shrinker.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c
> > index d66de5999a26..555712ba06d8 100644
> > --- a/fs/f2fs/shrinker.c
> > +++ b/fs/f2fs/shrinker.c
> > @@ -18,7 +18,11 @@ static unsigned int shrinker_run_no;
> > static unsigned long __count_nat_entries(struct f2fs_sb_info *sbi)
> > {
> > - long count = NM_I(sbi)->nat_cnt - NM_I(sbi)->dirty_nat_cnt;
> > + long count;
> > +
> > + down_read(&NM_I(sbi)->nat_tree_lock);
> > + count = NM_I(sbi)->nat_cnt - NM_I(sbi)->dirty_nat_cnt;
> > + up_read(&NM_I(sbi)->nat_tree_lock);
> > return count > 0 ? count : 0;
>
> Minor thing,
>
> Just return count is enough? since count should never be smaller than 0.
Yeah, but let me keep this just in case.
>
> Anyway,
>
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
>
> Thanks,
>
> Thanks,
>
> > }
> >
next prev parent reply other threads:[~2020-11-17 16:41 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-09 17:00 [f2fs-dev] [PATCH] f2fs: avoid race condition for shinker count Jaegeuk Kim
2020-11-09 17:00 ` Jaegeuk Kim
2020-11-10 2:15 ` [f2fs-dev] " Chao Yu
2020-11-10 2:15 ` Chao Yu
2020-11-10 4:19 ` Jaegeuk Kim
2020-11-10 4:19 ` Jaegeuk Kim
2020-11-10 6:04 ` Chao Yu
2020-11-10 6:04 ` Chao Yu
2020-11-12 5:31 ` Jaegeuk Kim
2020-11-12 5:31 ` Jaegeuk Kim
2020-11-12 5:34 ` [f2fs-dev] [PATCH v2] " Jaegeuk Kim
2020-11-12 5:34 ` Jaegeuk Kim
2020-11-12 5:40 ` [f2fs-dev] [PATCH v3] " Jaegeuk Kim
2020-11-12 5:40 ` Jaegeuk Kim
2020-11-12 6:57 ` Chao Yu
2020-11-12 6:57 ` Chao Yu
2020-11-17 16:40 ` Jaegeuk Kim [this message]
2020-11-17 16:40 ` Jaegeuk Kim
2020-12-03 6:07 ` Jaegeuk Kim
2020-12-03 6:07 ` Jaegeuk Kim
2020-12-03 6:55 ` Chao Yu
2020-12-03 6:55 ` Chao Yu
2020-12-03 7:55 ` Jaegeuk Kim
2020-12-03 7:55 ` Jaegeuk Kim
2020-12-03 8:16 ` Chao Yu
2020-12-03 8:16 ` 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=20201117164021.GA1636127@google.com \
--to=jaegeuk@kernel.org \
--cc=Light.Hsieh@mediatek.com \
--cc=kernel-team@android.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=yuchao0@huawei.com \
/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.