aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-10-25 14:01:40 -0400
committerChris Mason <clm@fb.com>2014-01-31 08:21:58 -0800
commit1f5e3b2825a3a3763334aeffecaf442ad18750c2 (patch)
treee22d93f0619694ab5b6059ac4036b987c6d96b89
parenta156b967ed9bd606afa8dc402451abcf07226c17 (diff)
downloadbtrfs-progs-1f5e3b2825a3a3763334aeffecaf442ad18750c2.tar.gz
btrfs-progs-1f5e3b2825a3a3763334aeffecaf442ad18750c2.tar.xz
btrfs-progs-1f5e3b2825a3a3763334aeffecaf442ad18750c2.zip
Btrfs-progs: allow --init-extent-tree to work when extent tree is borked
Unfortunately you can't run --init-extent-tree if you can't actually read the extent root. Fix this by allowing partial starts with no extent root and then have fsck only check to see if the extent root is uptodate _after_ the check to see if we are init'ing the extent tree. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r--cmds-check.c9
-rw-r--r--disk-io.c12
2 files changed, 17 insertions, 4 deletions
diff --git a/cmds-check.c b/cmds-check.c
index dbf48c8..cdcc4ba 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -6008,7 +6008,7 @@ static int reinit_extent_tree(struct btrfs_fs_info *fs_info)
}
/* Ok we can allocate now, reinit the extent root */
- ret = btrfs_fsck_reinit_root(trans, fs_info->extent_root, 1);
+ ret = btrfs_fsck_reinit_root(trans, fs_info->extent_root, 0);
if (ret) {
fprintf(stderr, "extent root initialization failed\n");
/*
@@ -6194,20 +6194,23 @@ int cmd_check(int argc, char **argv)
if (!extent_buffer_uptodate(info->tree_root->node) ||
!extent_buffer_uptodate(info->dev_root->node) ||
- !extent_buffer_uptodate(info->extent_root->node) ||
!extent_buffer_uptodate(info->chunk_root->node)) {
fprintf(stderr, "Critical roots corrupted, unable to fsck the FS\n");
return -EIO;
}
root = info->fs_root;
-
if (init_extent_tree) {
printf("Creating a new extent tree\n");
ret = reinit_extent_tree(info);
if (ret)
return ret;
}
+ if (!extent_buffer_uptodate(info->extent_root->node)) {
+ fprintf(stderr, "Critical roots corrupted, unable to fsck the FS\n");
+ return -EIO;
+ }
+
fprintf(stderr, "checking extents\n");
if (init_csum_tree) {
struct btrfs_trans_handle *trans;
diff --git a/disk-io.c b/disk-io.c
index 0af3898..7ad2cc2 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -877,7 +877,17 @@ int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info, u64 root_tree_bytenr,
fs_info->extent_root);
if (ret) {
printk("Couldn't setup extent tree\n");
- return -EIO;
+ if (!(flags & OPEN_CTREE_PARTIAL))
+ return -EIO;
+ /* Need a blank node here just so we don't screw up in the
+ * million of places that assume a root has a valid ->node
+ */
+ fs_info->extent_root->node =
+ btrfs_find_create_tree_block(fs_info->extent_root, 0,
+ leafsize);
+ if (!fs_info->extent_root->node)
+ return -ENOMEM;
+ clear_extent_buffer_uptodate(NULL, fs_info->extent_root->node);
}
fs_info->extent_root->track_dirty = 1;