f2fs: use atomic variable for total_extent_tree
It would be better to use atomic variable for total_extent_tree.
Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index e86e9f1e..0e97d6af 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -70,7 +70,7 @@
rwlock_init(&et->lock);
atomic_set(&et->refcount, 0);
et->count = 0;
- sbi->total_ext_tree++;
+ atomic_inc(&sbi->total_ext_tree);
}
atomic_inc(&et->refcount);
up_write(&sbi->extent_tree_lock);
@@ -570,7 +570,7 @@
radix_tree_delete(root, et->ino);
kmem_cache_free(extent_tree_slab, et);
- sbi->total_ext_tree--;
+ atomic_dec(&sbi->total_ext_tree);
tree_cnt++;
if (node_cnt + tree_cnt >= nr_shrink)
@@ -663,7 +663,7 @@
f2fs_bug_on(sbi, atomic_read(&et->refcount) || et->count);
radix_tree_delete(&sbi->extent_tree_root, inode->i_ino);
kmem_cache_free(extent_tree_slab, et);
- sbi->total_ext_tree--;
+ atomic_dec(&sbi->total_ext_tree);
up_write(&sbi->extent_tree_lock);
F2FS_I(inode)->extent_tree = NULL;
@@ -715,7 +715,7 @@
init_rwsem(&sbi->extent_tree_lock);
INIT_LIST_HEAD(&sbi->extent_list);
spin_lock_init(&sbi->extent_lock);
- sbi->total_ext_tree = 0;
+ atomic_set(&sbi->total_ext_tree, 0);
atomic_set(&sbi->total_ext_node, 0);
}