From patchwork Fri Oct 4 20:42:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 2990181 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B84B5BF923 for ; Fri, 4 Oct 2013 20:42:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C8D6C20304 for ; Fri, 4 Oct 2013 20:42:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 89E5E202E5 for ; Fri, 4 Oct 2013 20:42:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753697Ab3JDUmn (ORCPT ); Fri, 4 Oct 2013 16:42:43 -0400 Received: from dkim2.fusionio.com ([66.114.96.54]:41607 "EHLO dkim2.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753529Ab3JDUmm (ORCPT ); Fri, 4 Oct 2013 16:42:42 -0400 Received: from mx1.fusionio.com (unknown [10.101.1.160]) by dkim2.fusionio.com (Postfix) with ESMTP id 141899A0364 for ; Fri, 4 Oct 2013 14:42:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fusionio.com; s=default; t=1380919362; bh=x7+8jVVsYlQ8Ia3sRlNVFtjpgMGcnA6O2+DkWXfLRoI=; h=From:To:Subject:Date; b=hCoomuj01HqdIdc1gWurjTZMv0Bk2NJIc6dsbdIiZWHBJzDDm5nwrbv3CdltqZqKx +RF/Wqgi7HuLQt04aPkuU9X3TO38yNL8pb2ay52H7yF5wVSCCupeEjbi3GseITP0Et QVHHvKGoMSEpJt4VLlT9ZzYti+GAKNbxUN1MM11k= X-ASG-Debug-ID: 1380919361-03d6a50f601622d0001-6jHSXT Received: from CAS1.int.fusionio.com ([10.101.1.40]) by mx1.fusionio.com with ESMTP id WJS9HW0tZnvAD8Xs (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO) for ; Fri, 04 Oct 2013 14:42:41 -0600 (MDT) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (10.101.1.160) by mail.fusionio.com (10.101.1.40) with Microsoft SMTP Server (TLS) id 14.3.158.1; Fri, 4 Oct 2013 14:42:40 -0600 From: Josef Bacik To: Subject: [PATCH] Btrfs-progs: print out human readable errors for inodes and backrefs Date: Fri, 4 Oct 2013 16:42:39 -0400 X-ASG-Orig-Subj: [PATCH] Btrfs-progs: print out human readable errors for inodes and backrefs Message-ID: <1380919359-2310-1-git-send-email-jbacik@fusionio.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.101.1.160] X-Barracuda-Connect: UNKNOWN[10.101.1.40] X-Barracuda-Start-Time: 1380919361 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.180:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.0000 1.0000 -2.0210 X-Barracuda-Spam-Score: -2.02 X-Barracuda-Spam-Status: No, SCORE=-2.02 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.141175 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- cmds-check.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index ec6669c..d8fcf97 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); }