Skip to content

Commit

Permalink
bcachefs: Improve btree_bad_header() error message
Browse files Browse the repository at this point in the history
We should always print out the full btree node ptr.

Signed-off-by: Kent Overstreet <[email protected]>
  • Loading branch information
koverstreet committed Jul 15, 2021
1 parent 86d8202 commit 2f3f216
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
26 changes: 12 additions & 14 deletions fs/bcachefs/btree_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,26 +712,24 @@ 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_bpos_to_text(&PBUF(buf2), b->data->min_key);
bch2_bkey_val_to_text(&PBUF(buf1), c, bkey_i_to_s_c(&b->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)
Expand Down
5 changes: 3 additions & 2 deletions fs/bcachefs/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,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, " ");
Expand Down

0 comments on commit 2f3f216

Please sign in to comment.