bcachefs: Fix BTREE_ITER_NOT_EXTENTS

bch2_btree_iter_peek() wasn't properly checking for
BTREE_ITER_IS_EXTENTS when updating iter->pos.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2021-04-09 16:52:30 -04:00 committed by Kent Overstreet
parent 0e96452eef
commit d7f35163e6
3 changed files with 8 additions and 2 deletions

View File

@ -1243,7 +1243,7 @@ int bch2_gc_gens(struct bch_fs *c)
}
for (i = 0; i < BTREE_ID_NR; i++)
if (btree_node_type_needs_gc(i)) {
if ((1 << i) & BTREE_ID_HAS_PTRS) {
ret = bch2_gc_btree_gens(c, i);
if (ret) {
bch_err(c, "error recalculating oldest_gen: %i", ret);

View File

@ -1641,7 +1641,9 @@ static inline struct bkey_s_c __btree_iter_peek(struct btree_iter *iter, bool wi
* iter->pos should be mononotically increasing, and always be equal to
* the key we just returned - except extents can straddle iter->pos:
*/
if (bkey_cmp(bkey_start_pos(k.k), iter->pos) > 0)
if (!(iter->flags & BTREE_ITER_IS_EXTENTS))
iter->pos = k.k->p;
else if (bkey_cmp(bkey_start_pos(k.k), iter->pos) > 0)
iter->pos = bkey_start_pos(k.k);
bch2_btree_iter_verify_entry_exit(iter);

View File

@ -616,6 +616,10 @@ static inline bool btree_iter_is_extents(struct btree_iter *iter)
(1U << BTREE_ID_dirents)| \
(1U << BTREE_ID_xattrs))
#define BTREE_ID_HAS_PTRS \
((1U << BTREE_ID_extents)| \
(1U << BTREE_ID_reflink))
static inline bool btree_type_has_snapshots(enum btree_id id)
{
return (1 << id) & BTREE_ID_HAS_SNAPSHOTS;