diff options
author | Chao Yu <yuchao0@huawei.com> | 2019-05-04 23:40:46 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2019-05-09 00:23:13 -0400 |
commit | c9c8ed50d94c613fc3f4917c51e9c75d493a312e (patch) | |
tree | 161bfa38f995f3fceae4c60d4d9ba1f85384a7f2 /fs/f2fs/segment.c | |
parent | d764834378a9870ca56e9b2977ea46e9911ec358 (diff) |
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) | |||
2169 | * before, we must track that to know how much space we | 2169 | * before, we must track that to know how much space we |
2170 | * really have. | 2170 | * really have. |
2171 | */ | 2171 | */ |
2172 | if (f2fs_test_bit(offset, se->ckpt_valid_map)) | 2172 | if (f2fs_test_bit(offset, se->ckpt_valid_map)) { |
2173 | spin_lock(&sbi->stat_lock); | ||
2173 | sbi->unusable_block_count++; | 2174 | sbi->unusable_block_count++; |
2175 | spin_unlock(&sbi->stat_lock); | ||
2176 | } | ||
2174 | } | 2177 | } |
2175 | 2178 | ||
2176 | if (f2fs_test_and_clear_bit(offset, se->discard_map)) | 2179 | if (f2fs_test_and_clear_bit(offset, se->discard_map)) |