Commit 2581f89a authored by Kent Overstreet's avatar Kent Overstreet
Browse files

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 39ebd748
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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;