Skip to content

Commit

Permalink
bcachefs: backpointer_get_key: check for null from peek_slot()
Browse files Browse the repository at this point in the history
peek_slot() doesn't normally return bkey_s_c_null - except when we ask
for a key at a btree level that doesn't exist, which can happen here.

We might want to revisit this, but we'll have to look over all the
places where we use peek_slot() on interior nodes.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
  • Loading branch information
Kent Overstreet committed Apr 3, 2025
1 parent 39ebd74 commit 2581f89
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fs/bcachefs/backpointers.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ struct bkey_s_c bch2_backpointer_get_key(struct btree_trans *trans,
return k;
}

/*
* peek_slot() doesn't normally return NULL - except when we ask for a
* key at a btree level that doesn't exist.
*
* We may want to revisit this and change peek_slot():
*/
if (!k.k) {
bkey_init(&iter->k);
iter->k.p = bp.v->pos;
k.k = &iter->k;
}

if (k.k &&
extent_matches_bp(c, bp.v->btree_id, bp.v->level, k, bp))
return k;
Expand Down

0 comments on commit 2581f89

Please sign in to comment.