mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-28 23:24:50 +00:00
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>
This commit is contained in:
parent
abccd00f8a
commit
98cfee2143
1 changed files with 3 additions and 11 deletions
|
@ -965,7 +965,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
|
||||||
while (!list_empty(&prefs)) {
|
while (!list_empty(&prefs)) {
|
||||||
ref = list_first_entry(&prefs, struct __prelim_ref, list);
|
ref = list_first_entry(&prefs, struct __prelim_ref, list);
|
||||||
WARN_ON(ref->count < 0);
|
WARN_ON(ref->count < 0);
|
||||||
if (ref->count && ref->root_id && ref->parent == 0) {
|
if (roots && ref->count && ref->root_id && ref->parent == 0) {
|
||||||
/* no parent == root of tree */
|
/* no parent == root of tree */
|
||||||
ret = ulist_add(roots, ref->root_id, 0, GFP_NOFS);
|
ret = ulist_add(roots, ref->root_id, 0, GFP_NOFS);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -1061,22 +1061,14 @@ static int btrfs_find_all_leafs(struct btrfs_trans_handle *trans,
|
||||||
u64 time_seq, struct ulist **leafs,
|
u64 time_seq, struct ulist **leafs,
|
||||||
const u64 *extent_item_pos)
|
const u64 *extent_item_pos)
|
||||||
{
|
{
|
||||||
struct ulist *tmp;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
tmp = ulist_alloc(GFP_NOFS);
|
|
||||||
if (!tmp)
|
|
||||||
return -ENOMEM;
|
|
||||||
*leafs = ulist_alloc(GFP_NOFS);
|
*leafs = ulist_alloc(GFP_NOFS);
|
||||||
if (!*leafs) {
|
if (!*leafs)
|
||||||
ulist_free(tmp);
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
|
||||||
|
|
||||||
ret = find_parent_nodes(trans, fs_info, bytenr,
|
ret = find_parent_nodes(trans, fs_info, bytenr,
|
||||||
time_seq, *leafs, tmp, extent_item_pos);
|
time_seq, *leafs, NULL, extent_item_pos);
|
||||||
ulist_free(tmp);
|
|
||||||
|
|
||||||
if (ret < 0 && ret != -ENOENT) {
|
if (ret < 0 && ret != -ENOENT) {
|
||||||
free_leaf_list(*leafs);
|
free_leaf_list(*leafs);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue