Commit 29cea6f4 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix bch2_btree_path_up_until_good_node()

There was a rare bug when path->locks_want was nonzero, but not
BTREE_MAX_DEPTH, where we'd return on a valid node that wasn't locked -
oops.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent e0eaf862
...@@ -1030,7 +1030,7 @@ static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans, ...@@ -1030,7 +1030,7 @@ static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans,
int check_pos) int check_pos)
{ {
unsigned i, l = path->level; unsigned i, l = path->level;
again:
while (btree_path_node(path, l) && while (btree_path_node(path, l) &&
!btree_path_good_node(trans, path, l, check_pos)) !btree_path_good_node(trans, path, l, check_pos))
__btree_path_set_level_up(trans, path, l++); __btree_path_set_level_up(trans, path, l++);
...@@ -1039,9 +1039,11 @@ static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans, ...@@ -1039,9 +1039,11 @@ static inline unsigned btree_path_up_until_good_node(struct btree_trans *trans,
for (i = l + 1; for (i = l + 1;
i < path->locks_want && btree_path_node(path, i); i < path->locks_want && btree_path_node(path, i);
i++) i++)
if (!bch2_btree_node_relock(trans, path, i)) if (!bch2_btree_node_relock(trans, path, i)) {
while (l <= i) while (l <= i)
__btree_path_set_level_up(trans, path, l++); __btree_path_set_level_up(trans, path, l++);
goto again;
}
return l; return l;
} }
......
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