aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/backref.c
diff options
context:
space:
mode:
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>2014-01-31 11:42:05 -0500
committerJosef Bacik <jbacik@fb.com>2014-03-10 15:15:41 -0400
commit98cfee214394a3560bd4ce3209b55a71c4267783 (patch)
tree504a904635516ddeaf0582489e420b67b2d622fa /fs/btrfs/backref.c
parentabccd00f8af27c585be48904515bad5658130e48 (diff)
Btrfs: only add roots if necessary in find_parent_nodes()
find_all_leafs() dosen't need add all roots actually, add roots only if we need, this can avoid unnecessary ulist dance. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fb.com>
Diffstat (limited to 'fs/btrfs/backref.c')
-rw-r--r--fs/btrfs/backref.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index aded3ef3d3d4..903fe68e017b 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -965,7 +965,7 @@ again:
965 while (!list_empty(&prefs)) { 965 while (!list_empty(&prefs)) {
966 ref = list_first_entry(&prefs, struct __prelim_ref, list); 966 ref = list_first_entry(&prefs, struct __prelim_ref, list);
967 WARN_ON(ref->count < 0); 967 WARN_ON(ref->count < 0);
968 if (ref->count && ref->root_id && ref->parent == 0) { 968 if (roots && ref->count && ref->root_id && ref->parent == 0) {
969 /* no parent == root of tree */ 969 /* no parent == root of tree */
970 ret = ulist_add(roots, ref->root_id, 0, GFP_NOFS); 970 ret = ulist_add(roots, ref->root_id, 0, GFP_NOFS);
971 if (ret < 0) 971 if (ret < 0)
@@ -1061,22 +1061,14 @@ static int btrfs_find_all_leafs(struct btrfs_trans_handle *trans,
1061 u64 time_seq, struct ulist **leafs, 1061 u64 time_seq, struct ulist **leafs,
1062 const u64 *extent_item_pos) 1062 const u64 *extent_item_pos)
1063{ 1063{
1064 struct ulist *tmp;
1065 int ret; 1064 int ret;
1066 1065
1067 tmp = ulist_alloc(GFP_NOFS);
1068 if (!tmp)
1069 return -ENOMEM;
1070 *leafs = ulist_alloc(GFP_NOFS); 1066 *leafs = ulist_alloc(GFP_NOFS);
1071 if (!*leafs) { 1067 if (!*leafs)
1072 ulist_free(tmp);
1073 return -ENOMEM; 1068 return -ENOMEM;
1074 }
1075 1069
1076 ret = find_parent_nodes(trans, fs_info, bytenr, 1070 ret = find_parent_nodes(trans, fs_info, bytenr,
1077 time_seq, *leafs, tmp, extent_item_pos); 1071 time_seq, *leafs, NULL, extent_item_pos);
1078 ulist_free(tmp);
1079
1080 if (ret < 0 && ret != -ENOENT) { 1072 if (ret < 0 && ret != -ENOENT) {
1081 free_leaf_list(*leafs); 1073 free_leaf_list(*leafs);
1082 return ret; 1074 return ret;