Skip to content

Commit 2581f89

Browse files
author
Kent Overstreet
committed
bcachefs: backpointer_get_key: check for null from peek_slot()
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>
1 parent 39ebd74 commit 2581f89

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

fs/bcachefs/backpointers.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,18 @@ struct bkey_s_c bch2_backpointer_get_key(struct btree_trans *trans,
258258
return k;
259259
}
260260

261+
/*
262+
* peek_slot() doesn't normally return NULL - except when we ask for a
263+
* key at a btree level that doesn't exist.
264+
*
265+
* We may want to revisit this and change peek_slot():
266+
*/
267+
if (!k.k) {
268+
bkey_init(&iter->k);
269+
iter->k.p = bp.v->pos;
270+
k.k = &iter->k;
271+
}
272+
261273
if (k.k &&
262274
extent_matches_bp(c, bp.v->btree_id, bp.v->level, k, bp))
263275
return k;

0 commit comments

Comments
 (0)