path: root/cmds-restore.c
diff options
authorQu Wenruo <>2018-04-11 15:58:01 +0800
committerDavid Sterba <>2018-04-24 13:00:12 +0200
commitf9c56d3489c60f0bedf5b86ead01bf471e9411d6 (patch)
treebd71b0fcab9cd69fad2685e18b49eba846864ee5 /cmds-restore.c
parentc57ed6ca6b1b0655bba4fff97ad10e32dba4a81d (diff)
btrfs-progs: Use more loose open ctree flags for dump-tree and restore
Corrupted extent tree (either the root node or leaf) can normally block us from open the fs. As normally open_ctree() has the following call chain: __open_ctree_fd() |- btrfs_setup_all_roots() |- btrfs_read_block_groups() And we will search block group items in extent tree. And considering how block group items are scattered around the whole extent tree, any error would block the fs from being mounted. Fortunately, we already have OPEN_CTREE_NO_BLOCK_GROUPS flags to disable block group items search, which will not only allow us to open some fs, but also hugely speed up open time. Currently dump-tree and btrfs-restore is ensured that they care nothing about block group items. So specify OPEN_CTREE_NO_BLOCK_GROUPS flag as default. Reported-by: Christoph Anton Mitterer <> Signed-off-by: Qu Wenruo <> Signed-off-by: David Sterba <>
Diffstat (limited to 'cmds-restore.c')
1 files changed, 8 insertions, 1 deletions
diff --git a/cmds-restore.c b/cmds-restore.c
index ade35f0f..f228acab 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -1281,8 +1281,15 @@ static struct btrfs_root *open_fs(const char *dev, u64 root_location,
for (i = super_mirror; i < BTRFS_SUPER_MIRROR_MAX; i++) {
bytenr = btrfs_sb_offset(i);
+ /*
+ * Restore won't allocate extent and doesn't care anything
+ * in extent tree. Skip block group item search will allow
+ * restore to be executed on heavily damaged fs.
+ */
fs_info = open_ctree_fs_info(dev, bytenr, root_location, 0,
if (fs_info)
fprintf(stderr, "Could not open root, trying backup super\n");