Btrfs-progs: reset balance before reiniting extent root
authorJosef Bacik <jbacik@fb.com>
Wed, 11 Dec 2013 16:17:52 +0000 (11:17 -0500)
committerChris Mason <clm@fb.com>
Fri, 31 Jan 2014 16:22:14 +0000 (08:22 -0800)
When we re-init the extent root we make it completely empty, so when we reset a
pending balance we will fail to find refs for any blocks we may cow, which will
result in errors and we will exit out.  We need to reset the balance first so
the normal cow stuff doesn't freak out and then we can re-init the extent tree.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
cmds-check.c

index e7d4edf..cb5ed3e 100644 (file)
@@ -6008,6 +6008,12 @@ static int reinit_extent_tree(struct btrfs_fs_info *fs_info)
                return ret;
        }
 
+       ret = reset_balance(trans, fs_info);
+       if (ret) {
+               fprintf(stderr, "error reseting the pending balance\n");
+               return ret;
+       }
+
        /* Ok we can allocate now, reinit the extent root */
        ret = btrfs_fsck_reinit_root(trans, fs_info->extent_root, 0);
        if (ret) {
@@ -6020,12 +6026,6 @@ static int reinit_extent_tree(struct btrfs_fs_info *fs_info)
                return ret;
        }
 
-       ret = reset_balance(trans, fs_info);
-       if (ret) {
-               fprintf(stderr, "error reseting the pending balance\n");
-               return ret;
-       }
-
        /*
         * Now we have all the in-memory block groups setup so we can make
         * allocations properly, and the metadata we care about is safe since we