For tree reloc tree whose level is >= 2, the root node's parent will
point to itself.
In this case it will make btrfsck overflow its stack and cause segfault.
While for tree reloc tree, it doesn't affect qgroup and kernel can
handle it well.
So add tree reloc tree check for qgroup-verify.c and fix the bug.
Test case will follow soon after I make a minimal image for it.
Current xz ziped image is still over 10M for a 512M fs.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
if (ret < 0)
goto out;
}
+ } else if (ref->parent == ref->bytenr) {
+ /*
+ * Special loop case for tree reloc tree
+ */
+ ref->root = BTRFS_TREE_RELOC_OBJECTID;
} else {
ret = find_parent_roots(roots, ref->parent);
if (ret < 0)
if (ref->root)
return ref->root;
+ if (ref->parent == bytenr)
+ return BTRFS_TREE_RELOC_OBJECTID;
return resolve_one_root(ref->parent);
}
struct btrfs_root *root;
struct btrfs_key key;
+ /* Tree reloc tree doesn't contribute qgroup, skip it */
+ if (root_id == BTRFS_TREE_RELOC_OBJECTID)
+ return 0;
key.objectid = root_id;
key.type = BTRFS_ROOT_ITEM_KEY;
key.offset = (u64)-1;