diff options
author | Chao Yu <yuchao0@huawei.com> | 2019-05-05 05:40:46 +0200 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2019-05-09 06:23:13 +0200 |
commit | c9c8ed50d94c613fc3f4917c51e9c75d493a312e (patch) | |
tree | 161bfa38f995f3fceae4c60d4d9ba1f85384a7f2 /fs/f2fs/segment.c | |
parent | f2fs: add tracepoint for f2fs_filemap_fault() (diff) | |
download | linux-c9c8ed50d94c613fc3f4917c51e9c75d493a312e.tar.xz linux-c9c8ed50d94c613fc3f4917c51e9c75d493a312e.zip |
f2fs: fix to avoid potential race on sbi->unusable_block_count access/update
Use sbi.stat_lock to protect sbi->unusable_block_count accesss/udpate, in
order to avoid potential race on it.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r-- | fs/f2fs/segment.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 8388d2abacb5..8dee063c833f 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2169,8 +2169,11 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) * before, we must track that to know how much space we * really have. */ - if (f2fs_test_bit(offset, se->ckpt_valid_map)) + if (f2fs_test_bit(offset, se->ckpt_valid_map)) { + spin_lock(&sbi->stat_lock); sbi->unusable_block_count++; + spin_unlock(&sbi->stat_lock); + } } if (f2fs_test_and_clear_bit(offset, se->discard_map)) |