summaryrefslogtreecommitdiff
path: root/cmds-check.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-10-04 16:42:39 -0400
committerChris Mason <chris.mason@fusionio.com>2013-10-16 08:23:12 -0400
commit8fa3f2085c8637657fb486879054c1777b55b404 (patch)
tree35e2757c55e15e00a4cbf4590bf650c2372fecb6 /cmds-check.c
parent67e8b6748e2d73f4deef420b81225faff67020a5 (diff)
Btrfs-progs: print out human readable errors for inodes and backrefs
We usually print out a hex value of any errors on inodes or their backrefs, which is a huge pain for me because I have to put it into a calculator and count the bits to figure out which errors these map to, and usually I get it wrong the first time. To fix this lets just print out a human readable string for each error that way it will be easier to spot the "OH GOD THAT'S AWFUL" errors from "oh yeah thats no big deal, repair will fix that." Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'cmds-check.c')
-rw-r--r--cmds-check.c70
1 files changed, 68 insertions, 2 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 59ae4ecc..ee0abfd7 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -278,6 +278,70 @@ static struct inode_record *clone_inode_rec(struct inode_record *orig_rec)
return rec;
}
+static void print_inode_error(int errors)
+{
+ if (errors & I_ERR_NO_INODE_ITEM)
+ fprintf(stderr, ", no inode item");
+ if (errors & I_ERR_NO_ORPHAN_ITEM)
+ fprintf(stderr, ", no orphan item");
+ if (errors & I_ERR_DUP_INODE_ITEM)
+ fprintf(stderr, ", dup inode item");
+ if (errors & I_ERR_DUP_DIR_INDEX)
+ fprintf(stderr, ", dup dir index");
+ if (errors & I_ERR_ODD_DIR_ITEM)
+ fprintf(stderr, ", odd dir item");
+ if (errors & I_ERR_ODD_FILE_EXTENT)
+ fprintf(stderr, ", odd file extent");
+ if (errors & I_ERR_BAD_FILE_EXTENT)
+ fprintf(stderr, ", bad file extent");
+ if (errors & I_ERR_FILE_EXTENT_OVERLAP)
+ fprintf(stderr, ", file extent overlap");
+ if (errors & I_ERR_FILE_EXTENT_DISCOUNT)
+ fprintf(stderr, ", file extent discount");
+ if (errors & I_ERR_DIR_ISIZE_WRONG)
+ fprintf(stderr, ", dir isize wrong");
+ if (errors & I_ERR_FILE_NBYTES_WRONG)
+ fprintf(stderr, ", nbytes wrong");
+ if (errors & I_ERR_ODD_CSUM_ITEM)
+ fprintf(stderr, ", odd csum item");
+ if (errors & I_ERR_SOME_CSUM_MISSING)
+ fprintf(stderr, ", some csum missing");
+ if (errors & I_ERR_LINK_COUNT_WRONG)
+ fprintf(stderr, ", link count wrong");
+ fprintf(stderr, "\n");
+}
+
+static void print_ref_error(int errors)
+{
+ if (errors & REF_ERR_NO_DIR_ITEM)
+ fprintf(stderr, ", no dir item");
+ if (errors & REF_ERR_NO_DIR_INDEX)
+ fprintf(stderr, ", no dir index");
+ if (errors & REF_ERR_NO_INODE_REF)
+ fprintf(stderr, ", no inode ref");
+ if (errors & REF_ERR_DUP_DIR_ITEM)
+ fprintf(stderr, ", dup dir item");
+ if (errors & REF_ERR_DUP_DIR_INDEX)
+ fprintf(stderr, ", dup dir index");
+ if (errors & REF_ERR_DUP_INODE_REF)
+ fprintf(stderr, ", dup inode ref");
+ if (errors & REF_ERR_INDEX_UNMATCH)
+ fprintf(stderr, ", index unmatch");
+ if (errors & REF_ERR_FILETYPE_UNMATCH)
+ fprintf(stderr, ", filetype unmatch");
+ if (errors & REF_ERR_NAME_TOO_LONG)
+ fprintf(stderr, ", name too long");
+ if (errors & REF_ERR_NO_ROOT_REF)
+ fprintf(stderr, ", no root ref");
+ if (errors & REF_ERR_NO_ROOT_BACKREF)
+ fprintf(stderr, ", no root backref");
+ if (errors & REF_ERR_DUP_ROOT_REF)
+ fprintf(stderr, ", dup root ref");
+ if (errors & REF_ERR_DUP_ROOT_BACKREF)
+ fprintf(stderr, ", dup root backref");
+ fprintf(stderr, "\n");
+}
+
static struct inode_record *get_inode_rec(struct cache_tree *inode_cache,
u64 ino, int mod)
{
@@ -1474,9 +1538,10 @@ static int check_inode_recs(struct btrfs_root *root,
rec->errors |= I_ERR_NO_INODE_ITEM;
if (rec->found_link != rec->nlink)
rec->errors |= I_ERR_LINK_COUNT_WRONG;
- fprintf(stderr, "root %llu inode %llu errors %x\n",
+ fprintf(stderr, "root %llu inode %llu errors %x",
(unsigned long long) root->root_key.objectid,
(unsigned long long) rec->ino, rec->errors);
+ print_inode_error(rec->errors);
list_for_each_entry(backref, &rec->backrefs, list) {
if (!backref->found_dir_item)
backref->errors |= REF_ERR_NO_DIR_ITEM;
@@ -1485,11 +1550,12 @@ static int check_inode_recs(struct btrfs_root *root,
if (!backref->found_inode_ref)
backref->errors |= REF_ERR_NO_INODE_REF;
fprintf(stderr, "\tunresolved ref dir %llu index %llu"
- " namelen %u name %s filetype %d error %x\n",
+ " namelen %u name %s filetype %d error %x",
(unsigned long long)backref->dir,
(unsigned long long)backref->index,
backref->namelen, backref->name,
backref->filetype, backref->errors);
+ print_ref_error(backref->errors);
}
free_inode_rec(rec);
}