summaryrefslogtreecommitdiff
path: root/cmds-check.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2014-10-10 16:57:12 -0400
committerDavid Sterba <dsterba@suse.cz>2014-10-14 10:41:51 +0200
commit994ce2672dbf89fe5a7a18557b15449f0f83af65 (patch)
tree08ca609ec263a85c65f077e26c5101ffee098feb /cmds-check.c
parenta8e9c9a65b337117e87d2a040697edf6816369c3 (diff)
Btrfs-progs: re-search tree root if it changes
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> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-check.c')
-rw-r--r--cmds-check.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 131eba95..4f400032 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -2237,7 +2237,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;
@@ -2253,6 +2253,7 @@ static int check_fs_roots(struct btrfs_root *root,
cache_tree_init(&wc.shared);
btrfs_init_path(&path);
+again:
key.offset = 0;
key.objectid = 0;
key.type = BTRFS_ROOT_ITEM_KEY;
@@ -2261,7 +2262,13 @@ static int check_fs_roots(struct btrfs_root *root,
err = 1;
goto out;
}
+ 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);