Commit b564513c authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: fix bch2_bkey_print_bfloat

was popping an assertion in the eytzinger code
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 5bd95a37
...@@ -1774,7 +1774,7 @@ int bch2_bkey_print_bfloat(struct btree *b, struct bkey_packed *k, ...@@ -1774,7 +1774,7 @@ int bch2_bkey_print_bfloat(struct btree *b, struct bkey_packed *k,
struct bkey_packed *l, *r, *p; struct bkey_packed *l, *r, *p;
struct bkey uk, up; struct bkey uk, up;
char buf1[200], buf2[200]; char buf1[200], buf2[200];
unsigned j; unsigned j, inorder;
if (!size) if (!size)
return 0; return 0;
...@@ -1782,53 +1782,57 @@ int bch2_bkey_print_bfloat(struct btree *b, struct bkey_packed *k, ...@@ -1782,53 +1782,57 @@ int bch2_bkey_print_bfloat(struct btree *b, struct bkey_packed *k,
if (!bset_has_ro_aux_tree(t)) if (!bset_has_ro_aux_tree(t))
goto out; goto out;
j = __inorder_to_eytzinger1(bkey_to_cacheline(b, t, k), t->size, t->extra); inorder = bkey_to_cacheline(b, t, k);
if (j && if (!inorder || inorder >= t->size)
j < t->size && goto out;
k == tree_to_bkey(b, t, j))
switch (bkey_float(b, t, j)->exponent) { j = __inorder_to_eytzinger1(inorder, t->size, t->extra);
case BFLOAT_FAILED_UNPACKED: if (k != tree_to_bkey(b, t, j))
uk = bkey_unpack_key(b, k); goto out;
return scnprintf(buf, size,
" failed unpacked at depth %u\n" switch (bkey_float(b, t, j)->exponent) {
"\t%llu:%llu\n", case BFLOAT_FAILED_UNPACKED:
ilog2(j), uk = bkey_unpack_key(b, k);
uk.p.inode, uk.p.offset); return scnprintf(buf, size,
case BFLOAT_FAILED_PREV: " failed unpacked at depth %u\n"
p = tree_to_prev_bkey(b, t, j); "\t%llu:%llu\n",
l = is_power_of_2(j) ilog2(j),
? btree_bkey_first(b, t) uk.p.inode, uk.p.offset);
: tree_to_prev_bkey(b, t, j >> ffs(j)); case BFLOAT_FAILED_PREV:
r = is_power_of_2(j + 1) p = tree_to_prev_bkey(b, t, j);
? bch2_bkey_prev_all(b, t, btree_bkey_last(b, t)) l = is_power_of_2(j)
: tree_to_bkey(b, t, j >> (ffz(j) + 1)); ? btree_bkey_first(b, t)
: tree_to_prev_bkey(b, t, j >> ffs(j));
up = bkey_unpack_key(b, p); r = is_power_of_2(j + 1)
uk = bkey_unpack_key(b, k); ? bch2_bkey_prev_all(b, t, btree_bkey_last(b, t))
bch2_to_binary(buf1, high_word(&b->format, p), b->nr_key_bits); : tree_to_bkey(b, t, j >> (ffz(j) + 1));
bch2_to_binary(buf2, high_word(&b->format, k), b->nr_key_bits);
up = bkey_unpack_key(b, p);
return scnprintf(buf, size, uk = bkey_unpack_key(b, k);
" failed prev at depth %u\n" bch2_to_binary(buf1, high_word(&b->format, p), b->nr_key_bits);
"\tkey starts at bit %u but first differing bit at %u\n" bch2_to_binary(buf2, high_word(&b->format, k), b->nr_key_bits);
"\t%llu:%llu\n"
"\t%llu:%llu\n" return scnprintf(buf, size,
"\t%s\n" " failed prev at depth %u\n"
"\t%s\n", "\tkey starts at bit %u but first differing bit at %u\n"
ilog2(j), "\t%llu:%llu\n"
bch2_bkey_greatest_differing_bit(b, l, r), "\t%llu:%llu\n"
bch2_bkey_greatest_differing_bit(b, p, k), "\t%s\n"
uk.p.inode, uk.p.offset, "\t%s\n",
up.p.inode, up.p.offset, ilog2(j),
buf1, buf2); bch2_bkey_greatest_differing_bit(b, l, r),
case BFLOAT_FAILED_OVERFLOW: bch2_bkey_greatest_differing_bit(b, p, k),
uk = bkey_unpack_key(b, k); uk.p.inode, uk.p.offset,
return scnprintf(buf, size, up.p.inode, up.p.offset,
" failed overflow at depth %u\n" buf1, buf2);
"\t%llu:%llu\n", case BFLOAT_FAILED_OVERFLOW:
ilog2(j), uk = bkey_unpack_key(b, k);
uk.p.inode, uk.p.offset); return scnprintf(buf, size,
} " failed overflow at depth %u\n"
"\t%llu:%llu\n",
ilog2(j),
uk.p.inode, uk.p.offset);
}
out: out:
*buf = '\0'; *buf = '\0';
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment