/*
* Resolves all the possible roots for the ref at parent.
*/
-static void find_parent_roots(struct ulist *roots, u64 parent)
+static int find_parent_roots(struct ulist *roots, u64 parent)
{
struct ref *ref;
struct rb_node *node;
+ int ret;
/*
* Search the rbtree for the first ref with bytenr == parent.
do {
if (ref->root) {
- if (is_fstree(ref->root))
- ulist_add(roots, ref->root, 0, 0);
+ if (is_fstree(ref->root)) {
+ ret = ulist_add(roots, ref->root, 0, 0);
+ if (ret < 0)
+ goto out;
+ }
} else {
- find_parent_roots(roots, ref->parent);
+ ret = find_parent_roots(roots, ref->parent);
+ if (ret < 0)
+ goto out;
}
node = rb_next(node);
if (node)
ref = rb_entry(node, struct ref, bytenr_node);
} while (node && ref->bytenr == parent);
+
+ ret = 0;
+out:
+ return ret;
}
static int account_one_extent(struct ulist *roots, u64 bytenr, u64 num_bytes)
struct rb_node *node;
u64 bytenr, num_bytes;
struct ulist *roots = ulist_alloc(0);
+ int ret;
node = rb_first(&by_bytenr);
while (node) {
goto enomem;
}
} else {
- find_parent_roots(roots, ref->parent);
+ ret = find_parent_roots(roots, ref->parent);
+ if (ret < 0)
+ goto enomem;
}
/*