Commit b6c60c80 authored by Josef Bacik's avatar Josef Bacik Committed by Chris Mason

Btrfs: change how we queue blocks for backref checking

Previously we only added blocks to the list to have their backrefs checked if
the level of the block is right above the one we are searching for.  This is
because we want to make sure we don't add the entire path up to the root to the
lists to make sure we process things one at a time.  This assumes that if any
blocks in the path to the root are going to be not checked (shared in other
words) then they will be in the level right above the current block on up.  This
isn't quite right though since we can have blocks higher up the list that are
shared because they are attached to a reloc root.  But we won't add this block
to be checked and then later on we will BUG_ON(!upper->checked).  So instead
keep track of wether or not we've queued a block to be checked in this current
search, and if we haven't go ahead and queue it to be checked.  This patch fixed
the panic I was seeing where we BUG_ON(!upper->checked).  Thanks,
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent d062d13c
...@@ -696,6 +696,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc, ...@@ -696,6 +696,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
int cowonly; int cowonly;
int ret; int ret;
int err = 0; int err = 0;
bool need_check = true;
path1 = btrfs_alloc_path(); path1 = btrfs_alloc_path();
path2 = btrfs_alloc_path(); path2 = btrfs_alloc_path();
...@@ -919,6 +920,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc, ...@@ -919,6 +920,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
cur->bytenr); cur->bytenr);
lower = cur; lower = cur;
need_check = true;
for (; level < BTRFS_MAX_LEVEL; level++) { for (; level < BTRFS_MAX_LEVEL; level++) {
if (!path2->nodes[level]) { if (!path2->nodes[level]) {
BUG_ON(btrfs_root_bytenr(&root->root_item) != BUG_ON(btrfs_root_bytenr(&root->root_item) !=
...@@ -962,14 +964,12 @@ struct backref_node *build_backref_tree(struct reloc_control *rc, ...@@ -962,14 +964,12 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
/* /*
* add the block to pending list if we * add the block to pending list if we
* need check its backrefs. only block * need check its backrefs, we only do this once
* at 'cur->level + 1' is added to the * while walking up a tree as we will catch
* tail of pending list. this guarantees * anything else later on.
* we check backrefs from lower level
* blocks to upper level blocks.
*/ */
if (!upper->checked && if (!upper->checked && need_check) {
level == cur->level + 1) { need_check = false;
list_add_tail(&edge->list[UPPER], list_add_tail(&edge->list[UPPER],
&list); &list);
} else } else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment