btrfs-progs: fix backref after init-csum-tree
authorAnand Jain <anand.jain@oracle.com>
Mon, 2 Dec 2013 06:11:54 +0000 (14:11 +0800)
committerChris Mason <clm@fb.com>
Fri, 31 Jan 2014 16:22:10 +0000 (08:22 -0800)
btrfsck reports backref error after running init-csum-tree

btrfsck --init-csum-tree /dev/sdc
btrfsck /dev/sdc
::
ref mismatch on [29474816 16384] extent item 1, found 0
Backref 29474816 root 7 not referenced back 0x1101d30
Incorrect global backref count on 29474816 found 1 wanted 0
backpointer mismatch on [29474816 16384]
owner ref check failed [29474816 16384]
Errors found in extent allocation tree or chunk allocation
::

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
cmds-check.c

index c15d8d0..e7d4edf 100644 (file)
@@ -6159,6 +6159,7 @@ int cmd_check(int argc, char **argv)
                } else if (option_index == 2) {
                        printf("Creating a new CRC tree\n");
                        init_csum_tree = 1;
+                       repair = 1;
                        ctree_flags |= OPEN_CTREE_WRITES;
                } else if (option_index == 3) {
                        init_extent_tree = 1;
@@ -6232,6 +6233,11 @@ int cmd_check(int argc, char **argv)
                ret = btrfs_commit_transaction(trans, info->csum_root);
                if (ret)
                        exit(1);
+
+               ret = check_chunks_and_extents(root);
+               if (ret)
+                       fprintf(stderr,
+                               "Errors found in extent allocation tree or chunk allocation\n");
                goto out;
        }
        ret = check_chunks_and_extents(root);