Btrfs-progs: fix reference check for roots in btrfsck
authorJosef Bacik <jbacik@fusionio.com>
Wed, 5 Jun 2013 14:02:59 +0000 (10:02 -0400)
committerChris Mason <chris.mason@fusionio.com>
Wed, 19 Jun 2013 17:52:56 +0000 (13:52 -0400)
I noticed that I was getting these errors on a bigger file system with more
snapshots that had been removed.  This check is bogus since we won't inc
rec->found_ref if we don't find a REF_KEY _and_ a DIR_ITEM, so we only have to
worry about there being no references to a root if it actually has a root item.
If it doesn't then it's just referenced by things that will go no where anyway.
With this patch fsck no longer incorrectly complains about this file system
image I have.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
cmds-check.c

index 4083298..68cdd52 100644 (file)
@@ -1637,6 +1637,14 @@ static int check_root_refs(struct btrfs_root *root,
                                                rec->objectid);
                        if (ret == 0)
                                continue;
+
+                       /*
+                        * If we don't have a root item then we likely just have
+                        * a dir item in a snapshot for this root but no actual
+                        * ref key or anything so it's meaningless.
+                        */
+                       if (!rec->found_root_item)
+                               continue;
                        errors++;
                        fprintf(stderr, "fs tree %llu not referenced\n",
                                (unsigned long long)rec->objectid);