From patchwork Wed Nov 26 02:58: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: 5383821 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 37E1B9F39B for ; Wed, 26 Nov 2014 03:00:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C949201F4 for ; Wed, 26 Nov 2014 03:00:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86DCC201C7 for ; Wed, 26 Nov 2014 03:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751936AbaKZDAr (ORCPT ); Tue, 25 Nov 2014 22:00:47 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:37202 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751142AbaKZDAp (ORCPT ); Tue, 25 Nov 2014 22:00:45 -0500 Received: by mail-pa0-f51.google.com with SMTP id ey11so1876000pad.24 for ; Tue, 25 Nov 2014 19:00:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HHIIC74HOHE+iAFhZCTYd1dYeifyaFi9BMflrNaC1A0=; b=LULEFO6+HYAS543CtHMIHDp5cegOKmi7nNV/rZmUtsCO97g+DF9CPh+JnFz+1putXd /LN1cyH7sh7V0fyCqK508CkZTztqx+b7oY3u1h4bQNgcv+jl4/t1SHsKgiwTIUN4kZfw JeIMmQzrrNWuZ0Mu63XV/cXYRmR8bcDsgwC3ZhBHBwNLQLgkftGz8CWi4qbAu+Y10uST Yd2AShCXATmXsGpGSihb+lnaV3GB9iR9mfKVGkn/1LrxCi7wDDBMAsxnkcTkWsiUZzSN q8akq71P6ZO/uJy6qedDiS/2xcerLOOJZ/Di6AIPFr8igvlg5qU7Dz2WDqlShFoiDdRv atGQ== X-Received: by 10.70.31.2 with SMTP id w2mr48403585pdh.128.1416970845368; Tue, 25 Nov 2014 19:00:45 -0800 (PST) Received: from localhost.localdomain.localdomain ([112.23.171.71]) by mx.google.com with ESMTPSA id kb16sm2749429pbb.34.2014.11.25.19.00.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Nov 2014 19:00:44 -0800 (PST) From: Wang Shilong To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH 3/3] Btrfs-progs, fsck: move root items repair after root rebuilding Date: Wed, 26 Nov 2014 10:58:56 +0800 Message-Id: <1416970736-26623-8-git-send-email-wangshilong1991@gmail.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1416970736-26623-1-git-send-email-wangshilong1991@gmail.com> References: <1416970736-26623-1-git-send-email-wangshilong1991@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_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 If some critical roots are corrupt, reapr_root_items() will fail, this is detected by fsck_tests.sh's extent rebuilding tests. Signed-off-by: Wang Shilong --- cmds-check.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index a102752..ae9005e 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -7987,22 +7987,6 @@ int cmd_check(int argc, char **argv) root = info->fs_root; - ret = repair_root_items(info); - if (ret < 0) - goto close_out; - if (repair) { - fprintf(stderr, "Fixed %d roots.\n", ret); - ret = 0; - } else if (ret > 0) { - fprintf(stderr, - "Found %d roots with an outdated root item.\n", - ret); - fprintf(stderr, - "Please run a filesystem check with the option --repair to fix them.\n"); - ret = 1; - goto close_out; - } - /* * repair mode will force us to commit transaction which * will make us fail to load log tree when mounting. @@ -8101,6 +8085,22 @@ int cmd_check(int argc, char **argv) if (ret) fprintf(stderr, "Errors found in extent allocation tree or chunk allocation\n"); + ret = repair_root_items(info); + if (ret < 0) + goto close_out; + if (repair) { + fprintf(stderr, "Fixed %d roots.\n", ret); + ret = 0; + } else if (ret > 0) { + fprintf(stderr, + "Found %d roots with an outdated root item.\n", + ret); + fprintf(stderr, + "Please run a filesystem check with the option --repair to fix them.\n"); + ret = 1; + goto close_out; + } + fprintf(stderr, "checking free space cache\n"); ret = check_space_cache(root); if (ret)