diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-11-06 22:22:05 +0100 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-12-03 09:59:26 +0100 |
commit | a95ba66ac1457b76fe472c8e092ab1006271f16c (patch) | |
tree | 2ec5e949c50264adc344407585fd6cc3ffc7f964 /fs/f2fs/shrinker.c | |
parent | f2fs: add F2FS_IOC_DECOMPRESS_FILE and F2FS_IOC_COMPRESS_FILE (diff) | |
download | linux-a95ba66ac1457b76fe472c8e092ab1006271f16c.tar.xz linux-a95ba66ac1457b76fe472c8e092ab1006271f16c.zip |
f2fs: avoid race condition for shrinker count
Light reported sometimes shinker gets nat_cnt < dirty_nat_cnt resulting in
wrong do_shinker work. Let's avoid to return insane overflowed value by adding
single tracking value.
Reported-by: Light Hsieh <Light.Hsieh@mediatek.com>
Reviewed-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.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/fs/f2fs/shrinker.c b/fs/f2fs/shrinker.c index d66de5999a26..dd3c3c7a90ec 100644 --- a/fs/f2fs/shrinker.c +++ b/fs/f2fs/shrinker.c @@ -18,9 +18,7 @@ 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; - - return count > 0 ? count : 0; + return NM_I(sbi)->nat_cnt[RECLAIMABLE_NAT]; } static unsigned long __count_free_nids(struct f2fs_sb_info *sbi) |