From patchwork Fri Jan 26 08:35:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 10185289 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 2A19460383 for ; Fri, 26 Jan 2018 08:31:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16980290EB for ; Fri, 26 Jan 2018 08:31:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B758290F6; Fri, 26 Jan 2018 08:31:06 +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 87A6B290EB for ; Fri, 26 Jan 2018 08:31:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752464AbeAZIbB (ORCPT ); Fri, 26 Jan 2018 03:31:01 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:34399 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752436AbeAZIa6 (ORCPT ); Fri, 26 Jan 2018 03:30:58 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="36018070" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Jan 2018 16:30:53 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 9959549F19B1 for ; Fri, 26 Jan 2018 16:30:51 +0800 (CST) Received: from archlinux.g08.fujitsu.local (10.167.226.31) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 26 Jan 2018 16:30:51 +0800 From: Su Yue To: CC: Subject: [PATCH 12/15] btrfs-progs: check: increase counter error in check_inode_recs() Date: Fri, 26 Jan 2018 16:35:16 +0800 Message-ID: <20180126083519.28373-13-suy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180126083519.28373-1-suy.fnst@cn.fujitsu.com> References: <20180126083519.28373-1-suy.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.31] X-yoursite-MailScanner-ID: 9959549F19B1.A9D5B X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: suy.fnst@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 Counter @error decides return values of check_inode_recs(). Previously, @error won't be incremented even repair_inode_recs() failed. It causes 'btrfs check --repair' prints some error information but returns 0. So, if root dir is missing and repair is disabled, @error should be incremented. And after repair_inode_recs(), increase @error if any errors in inodes and backrefs. Signed-off-by: Su Yue Reviewed-by: Qu Wenruo --- cmds-check.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index b23a4493b12b..a83f0a92f48b 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -4137,6 +4137,7 @@ static int check_inode_recs(struct btrfs_root *root, return -EAGAIN; } + error++; fprintf(stderr, "root %llu root dir %llu not found\n", (unsigned long long)root->root_key.objectid, (unsigned long long)root_dirid); @@ -4176,10 +4177,9 @@ static int check_inode_recs(struct btrfs_root *root, free_inode_rec(rec); continue; } - ret = 0; } - if (!(repair && ret == 0)) + if (rec->errors) error++; print_inode_error(root, rec); list_for_each_entry(backref, &rec->backrefs, list) { @@ -4189,6 +4189,8 @@ static int check_inode_recs(struct btrfs_root *root, backref->errors |= REF_ERR_NO_DIR_INDEX; if (!backref->found_inode_ref) backref->errors |= REF_ERR_NO_INODE_REF; + if (backref->errors) + error++; fprintf(stderr, "\tunresolved ref dir %llu index %llu" " namelen %u name %s filetype %d errors %x", (unsigned long long)backref->dir,