From patchwork Thu May 29 09:59:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 4263751 X-Patchwork-Delegate: dave@jikos.cz Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E118D9F1E7 for ; Thu, 29 May 2014 10:03:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EED0720320 for ; Thu, 29 May 2014 10:03:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FEC6201FA for ; Thu, 29 May 2014 10:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756586AbaE2KDc (ORCPT ); Thu, 29 May 2014 06:03:32 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:20719 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1756539AbaE2KDb (ORCPT ); Thu, 29 May 2014 06:03:31 -0400 X-IronPort-AV: E=Sophos;i="4.98,933,1392134400"; d="scan'208";a="31187224" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 29 May 2014 18:00:55 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s4TA3Tr0005181 for ; Thu, 29 May 2014 18:03:29 +0800 Received: from wangs.fnst.cn.fujitsu.com (10.167.226.104) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.146.2; Thu, 29 May 2014 18:03:29 +0800 From: Wang Shilong To: Subject: [PATCH v2 1/4] Btrfs-progs: fsck: only allow partial opening under repair mode Date: Thu, 29 May 2014 17:59:56 +0800 Message-ID: <1401357597-9494-1-git-send-email-wangsl.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.0 MIME-Version: 1.0 X-Originating-IP: [10.167.226.104] 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.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 The reason that we allow partial opening is that sometimes, we may have some corrupted trees.(for example extent tree), for fsck repair case, the broken tree may be rebuilt later. So if users only want to do check but not repair anything, this patch will make fsck return failure as soon as possible and tell users that some critial roots have been corrupted. Signed-off-by: Wang Shilong --- v1->v2: add necessary changelog.(Thanks to Eric) --- cmds-check.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index db7df80..0e4e042 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -6810,8 +6810,7 @@ int cmd_check(int argc, char **argv) int option_index = 0; int init_csum_tree = 0; int qgroup_report = 0; - enum btrfs_open_ctree_flags ctree_flags = - OPEN_CTREE_PARTIAL | OPEN_CTREE_EXCLUSIVE; + enum btrfs_open_ctree_flags ctree_flags = OPEN_CTREE_EXCLUSIVE; while(1) { int c; @@ -6877,6 +6876,10 @@ int cmd_check(int argc, char **argv) goto err_out; } + /* only allow partial opening under repair mode */ + if (repair) + ctree_flags |= OPEN_CTREE_PARTIAL; + info = open_ctree_fs_info(argv[optind], bytenr, 0, ctree_flags); if (!info) { fprintf(stderr, "Couldn't open file system\n");