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: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-07-14 23:35:11 -04:00 committed by Kent Overstreet
parent 914f2786b8
commit 71f892a482

View File

@ -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);