From patchwork Tue Feb 21 08:34:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9584043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8EE38600CA for ; Tue, 21 Feb 2017 08:35:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79C8E288E0 for ; Tue, 21 Feb 2017 08:35:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E9AE288E4; Tue, 21 Feb 2017 08:35:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1089F288E0 for ; Tue, 21 Feb 2017 08:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751547AbdBUIfU (ORCPT ); Tue, 21 Feb 2017 03:35:20 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:12298 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751466AbdBUIe7 (ORCPT ); Tue, 21 Feb 2017 03:34:59 -0500 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="15798784" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 21 Feb 2017 16:34:43 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 683A147C4E90; Tue, 21 Feb 2017 16:34:42 +0800 (CST) Received: from localhost.localdomain (10.167.226.34) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 21 Feb 2017 16:34:40 +0800 From: Qu Wenruo To: CC: Christoph Anton Mitterer Subject: [PATCH v3 02/12] btrfs-progs: check: Output verbose error when fsck found a bug in any tree Date: Tue, 21 Feb 2017 16:34:28 +0800 Message-ID: <20170221083438.25719-3-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170221083438.25719-1-quwenruo@cn.fujitsu.com> References: <20170221083438.25719-1-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.34] X-yoursite-MailScanner-ID: 683A147C4E90.AE7B9 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Although we output error like "errors found in extent allocation tree or chunk allocation", but we lacks such output for other trees, but leaving the final "found error is %d" to catch the last return value(and sometime it's cleared) This patch adds extra error message for top level error path, and modify the last "found error is %d" to "error(s) found" or "no error found". Cc: Christoph Anton Mitterer Signed-off-by: Qu Wenruo --- cmds-check.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index 699753fb..107359f8 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -12933,8 +12933,10 @@ int cmd_check(int argc, char **argv) ret = repair_root_items(info); err |= !!ret; - if (ret < 0) + if (ret < 0) { + error("failed to repair root items: %s", strerror(-ret)); goto close_out; + } if (repair) { fprintf(stderr, "Fixed %d roots.\n", ret); ret = 0; @@ -12957,8 +12959,13 @@ int cmd_check(int argc, char **argv) } ret = check_space_cache(root); err |= !!ret; - if (ret) + if (ret) { + if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE)) + error("errors found in free space tree"); + else + error("errors found in free space cache"); goto out; + } /* * We used to have to have these hole extents in between our real @@ -12974,22 +12981,28 @@ int cmd_check(int argc, char **argv) else ret = check_fs_roots(root, &root_cache); err |= !!ret; - if (ret) + if (ret) { + error("errors found in fs roots"); goto out; + } fprintf(stderr, "checking csums\n"); ret = check_csums(root); err |= !!ret; - if (ret) + if (ret) { + error("errors found in csum tree"); goto out; + } fprintf(stderr, "checking root refs\n"); /* For low memory mode, check_fs_roots_v2 handles root refs */ if (check_mode != CHECK_MODE_LOWMEM) { ret = check_root_refs(root, &root_cache); err |= !!ret; - if (ret) + if (ret) { + error("errors found in root refs"); goto out; + } } while (repair && !list_empty(&root->fs_info->recow_ebs)) { @@ -13000,8 +13013,10 @@ int cmd_check(int argc, char **argv) list_del_init(&eb->recow); ret = recow_extent_buffer(root, eb); err |= !!ret; - if (ret) + if (ret) { + error("fails to fix transid errors"); break; + } } while (!list_empty(&delete_items)) { @@ -13020,13 +13035,17 @@ int cmd_check(int argc, char **argv) fprintf(stderr, "checking quota groups\n"); ret = qgroup_verify_all(info); err |= !!ret; - if (ret) + if (ret) { + error("failed to check quota groups"); goto out; + } report_qgroups(0); ret = repair_qgroups(info, &qgroups_repaired); err |= !!ret; - if (err) + if (err) { + error("failed to repair quota groups"); goto out; + } ret = 0; } @@ -13047,8 +13066,12 @@ out: "backup data and re-format the FS. *\n\n"); err |= 1; } - printf("found %llu bytes used err is %d\n", - (unsigned long long)bytes_used, ret); + printf("found %llu bytes used, ", + (unsigned long long)bytes_used); + if (err) + printf("error(s) found\n"); + else + printf("no error found\n"); printf("total csum bytes: %llu\n",(unsigned long long)total_csum_bytes); printf("total tree bytes: %llu\n", (unsigned long long)total_btree_bytes);