- 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 if (ref->parent == ref->bytenr) {
+ /*
+ * Special loop case for tree reloc tree
+ */
+ ref->root = BTRFS_TREE_RELOC_OBJECTID;