summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu <chao2.yu@samsung.com>2016-01-08 13:24:00 +0100
committerJaegeuk Kim <jaegeuk@kernel.org>2016-01-08 20:57:18 +0100
commit9b72a388f5867f4a31113a41d24bbf1026611d7b (patch)
tree86e9e666dfc73e6a4571189d1779c4323ff00a87
parentf2fs: use atomic type for node count in extent tree (diff)
downloadlinux-9b72a388f5867f4a31113a41d24bbf1026611d7b.tar.xz
linux-9b72a388f5867f4a31113a41d24bbf1026611d7b.zip
f2fs: skip releasing nodes in chindless extent tree
If there are no nodes in extent tree, let's skip releasing step to avoid any overhead of grabbing/releasing extent tree lock. Signed-off-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/extent_cache.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 9febbc622bf5..ccd5c636d3fe 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -570,9 +570,11 @@ unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink)
/* 1. remove unreferenced extent tree */
list_for_each_entry_safe(et, next, &sbi->zombie_list, list) {
- write_lock(&et->lock);
- node_cnt += __free_extent_tree(sbi, et, true);
- write_unlock(&et->lock);
+ if (atomic_read(&et->node_cnt)) {
+ write_lock(&et->lock);
+ node_cnt += __free_extent_tree(sbi, et, true);
+ write_unlock(&et->lock);
+ }
list_del_init(&et->list);
radix_tree_delete(&sbi->extent_tree_root, et->ino);
@@ -618,6 +620,9 @@ free_node:
for (i = 0; i < found; i++) {
struct extent_tree *et = treevec[i];
+ if (!atomic_read(&et->node_cnt))
+ continue;
+
if (write_trylock(&et->lock)) {
node_cnt += __free_extent_tree(sbi, et, false);
write_unlock(&et->lock);
@@ -641,7 +646,7 @@ unsigned int f2fs_destroy_extent_node(struct inode *inode)
struct extent_tree *et = F2FS_I(inode)->extent_tree;
unsigned int node_cnt = 0;
- if (!et)
+ if (!et || !atomic_read(&et->node_cnt))
return 0;
write_lock(&et->lock);