linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fb.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH 07/12] Btrfs-progs: re-search tree root if it changes
Date: Fri, 10 Oct 2014 16:57:12 -0400	[thread overview]
Message-ID: <1412974637-31334-8-git-send-email-jbacik@fb.com> (raw)
In-Reply-To: <1412974637-31334-1-git-send-email-jbacik@fb.com>

If we change something while scanning fs-roots we need to redo our search so
that we get valid root items and have valid root cache.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 cmds-check.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/cmds-check.c b/cmds-check.c
index e81a26c..9522077 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -2171,7 +2171,7 @@ static int check_fs_roots(struct btrfs_root *root,
 	struct btrfs_path path;
 	struct btrfs_key key;
 	struct walk_control wc;
-	struct extent_buffer *leaf;
+	struct extent_buffer *leaf, *tree_node;
 	struct btrfs_root *tmp_root;
 	struct btrfs_root *tree_root = root->fs_info->tree_root;
 	int ret;
@@ -2186,13 +2186,19 @@ static int check_fs_roots(struct btrfs_root *root,
 	memset(&wc, 0, sizeof(wc));
 	cache_tree_init(&wc.shared);
 	btrfs_init_path(&path);
-
+again:
 	key.offset = 0;
 	key.objectid = 0;
 	key.type = BTRFS_ROOT_ITEM_KEY;
 	ret = btrfs_search_slot(NULL, tree_root, &key, &path, 0, 0);
 	BUG_ON(ret < 0);
+	tree_node = tree_root->node;
 	while (1) {
+		if (tree_node != tree_root->node) {
+			free_root_recs_tree(root_cache);
+			btrfs_release_path(&path);
+			goto again;
+		}
 		leaf = path.nodes[0];
 		if (path.slots[0] >= btrfs_header_nritems(leaf)) {
 			ret = btrfs_next_leaf(tree_root, &path);
-- 
1.8.3.1


  parent reply	other threads:[~2014-10-10 20:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10 20:57 Btrfs-progs: fix horrible things Josef Bacik
2014-10-10 20:57 ` [PATCH 01/12] Btrfs-progs: repair missing dir index Josef Bacik
2014-10-10 20:57 ` [PATCH 02/12] Btrfs-progs: pull back backref.c and fix it up Josef Bacik
2014-10-10 20:57 ` [PATCH 03/12] Btrfs-progs: break out rbtree util functions Josef Bacik
2014-10-10 20:57 ` [PATCH 04/12] Btrfs-progs: update rbtree libs Josef Bacik
2014-10-10 20:57 ` [PATCH 05/12] Btrfs-progs: lookup all roots that point to a corrupt block Josef Bacik
2014-10-10 20:57 ` [PATCH 06/12] Btrfs-progs: reset chunk state if we restart check Josef Bacik
2014-10-10 20:57 ` Josef Bacik [this message]
2014-10-10 20:57 ` [PATCH 08/12] Btrfs-progs: delete bogus dir indexes Josef Bacik
2014-10-10 20:57 ` [PATCH 09/12] Btrfs-progs: add a dummy backref if our location is wrong Josef Bacik
2014-10-10 20:57 ` [PATCH 10/12] Btrfs-progs: deal with mismatch index between dir index and inode ref Josef Bacik
2014-10-10 20:57 ` [PATCH 11/12] Btrfs-progs: add ability to corrupt dir items Josef Bacik

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=1412974637-31334-8-git-send-email-jbacik@fb.com \
    --to=jbacik@fb.com \
    --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).