Commit 23dfb3a2 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix bch2_btree_iter_peek_slot() error path

iter->k needs to be consistent with iter->pos - required for
bch2_btree_iter_(rewind|advance) to work correctly.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 8192f8a5
...@@ -2844,8 +2844,10 @@ struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *iter) ...@@ -2844,8 +2844,10 @@ struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *iter)
iter->flags & BTREE_ITER_INTENT); iter->flags & BTREE_ITER_INTENT);
ret = bch2_btree_path_traverse(trans, iter->path, iter->flags); ret = bch2_btree_path_traverse(trans, iter->path, iter->flags);
if (unlikely(ret)) if (unlikely(ret)) {
return bkey_s_c_err(ret); k = bkey_s_c_err(ret);
goto out_no_locked;
}
if ((iter->flags & BTREE_ITER_CACHED) || if ((iter->flags & BTREE_ITER_CACHED) ||
!(iter->flags & (BTREE_ITER_IS_EXTENTS|BTREE_ITER_FILTER_SNAPSHOTS))) { !(iter->flags & (BTREE_ITER_IS_EXTENTS|BTREE_ITER_FILTER_SNAPSHOTS))) {
...@@ -2895,6 +2897,9 @@ struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *iter) ...@@ -2895,6 +2897,9 @@ struct bkey_s_c bch2_btree_iter_peek_slot(struct btree_iter *iter)
struct bpos pos = iter->pos; struct bpos pos = iter->pos;
k = bch2_btree_iter_peek(iter); k = bch2_btree_iter_peek(iter);
if (unlikely(bkey_err(k)))
bch2_btree_iter_set_pos(iter, pos);
else
iter->pos = pos; iter->pos = pos;
} }
......
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