linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Shilong <wangshilong1991@gmail.com>
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	[thread overview]
Message-ID: <1416970736-26623-8-git-send-email-wangshilong1991@gmail.com> (raw)
In-Reply-To: <1416970736-26623-1-git-send-email-wangshilong1991@gmail.com>

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 <wangshilong1991@gmail.com>
---
 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)
-- 
2.1.0


  parent reply	other threads:[~2014-11-26  3:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-26  2:58 [PATCH 0/3] Extent tree rebuilding with snapshots patches Wang Shilong
2014-11-26  2:58 ` [PATCH resend 1/3] Btrfs-progs: fsck: deal with snapshot one by one when rebuilding extent tree Wang Shilong
2014-11-26  2:58 ` [PATCH resend 2/3] Btrfs-progs: fsck: add ability to rebuild extent tree with snapshots Wang Shilong
2014-11-26  2:58 ` [PATCH 3/3] Btrfs-progs, fsck: move root items repair after root rebuilding Wang Shilong
2014-11-26  2:58 ` [PATCH 0/3] Extent tree rebuilding with snapshots patches Wang Shilong
2014-11-26  2:58 ` [PATCH resend 1/3] Btrfs-progs: fsck: deal with snapshot one by one when rebuilding extent tree Wang Shilong
2014-11-26  2:58 ` [PATCH resend 2/3] Btrfs-progs: fsck: add ability to rebuild extent tree with snapshots Wang Shilong
2014-11-26  2:58 ` Wang Shilong [this message]
2014-11-26  3:06   ` [PATCH 3/3] Btrfs-progs, fsck: move root items repair after root rebuilding Wang Shilong
2014-12-04 15:55 ` [PATCH 0/3] Extent tree rebuilding with snapshots patches David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1416970736-26623-8-git-send-email-wangshilong1991@gmail.com \
    --to=wangshilong1991@gmail.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).