Commit 71f892a4 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix bch2_btree_iter_rewind()

We'd hit a BUG() when rewinding at the start of the btree on btrees with
snapshots.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 914f2786
......@@ -1622,7 +1622,9 @@ inline bool bch2_btree_iter_advance(struct btree_iter *iter)
inline bool bch2_btree_iter_rewind(struct btree_iter *iter)
{
struct bpos pos = bkey_start_pos(&iter->k);
bool ret = bpos_cmp(pos, POS_MIN) != 0;
bool ret = (iter->flags & BTREE_ITER_ALL_SNAPSHOTS
? bpos_cmp(pos, POS_MIN)
: bkey_cmp(pos, POS_MIN)) != 0;
if (ret && !(iter->flags & BTREE_ITER_IS_EXTENTS))
pos = bkey_predecessor(iter, 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