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

bcachefs: Improve btree_bad_header() error message

We should always print out the full btree node ptr.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent eb7f44db
......@@ -719,26 +719,25 @@ static int lock_node_check_fn(struct six_lock *lock, void *p)
static noinline void btree_bad_header(struct bch_fs *c, struct btree *b)
{
char buf1[100], buf2[100], buf3[100], buf4[100];
char buf1[200], buf2[100], buf3[100];
if (!test_bit(BCH_FS_INITIAL_GC_DONE, &c->flags))
return;
bch2_bpos_to_text(&PBUF(buf1), b->key.k.type == KEY_TYPE_btree_ptr_v2
? bkey_i_to_btree_ptr_v2(&b->key)->v.min_key
: POS_MIN);
bch2_bkey_val_to_text(&PBUF(buf1), c, bkey_i_to_s_c(&b->key));
bch2_bpos_to_text(&PBUF(buf2), b->data->min_key);
bch2_bpos_to_text(&PBUF(buf3), b->data->max_key);
bch2_bpos_to_text(&PBUF(buf3), b->key.k.p);
bch2_bpos_to_text(&PBUF(buf4), b->data->max_key);
bch2_fs_inconsistent(c, "btree node header doesn't match ptr\n"
"btree: ptr %u header %llu\n"
"level: ptr %u header %llu\n"
"min ptr %s node header %s\n"
"max ptr %s node header %s",
b->c.btree_id, BTREE_NODE_ID(b->data),
b->c.level, BTREE_NODE_LEVEL(b->data),
buf1, buf2, buf3, buf4);
"btree %s level %u\n"
"ptr: %s\n"
"header: btree %s level %llu\n"
"min %s max %s\n",
bch2_btree_ids[b->c.btree_id], b->c.level,
buf1,
bch2_btree_ids[BTREE_NODE_ID(b->data)],
BTREE_NODE_LEVEL(b->data),
buf2, buf3);
}
static inline void btree_check_header(struct bch_fs *c, struct btree *b)
......
......@@ -191,9 +191,10 @@ void bch2_btree_ptr_v2_to_text(struct printbuf *out, struct bch_fs *c,
{
struct bkey_s_c_btree_ptr_v2 bp = bkey_s_c_to_btree_ptr_v2(k);
pr_buf(out, "seq %llx written %u min_key ",
pr_buf(out, "seq %llx written %u min_key %s",
le64_to_cpu(bp.v->seq),
le16_to_cpu(bp.v->sectors_written));
le16_to_cpu(bp.v->sectors_written),
BTREE_PTR_RANGE_UPDATED(bp.v) ? "R " : "");
bch2_bpos_to_text(out, bp.v->min_key);
pr_buf(out, " ");
......
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