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.hs...@mediatek.com> > > Signed-off-by: Jaegeuk Kim <jaeg...@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 <yuch...@huawei.com> > > Thanks, > > Thanks, > > > } > >