bcachefs: Use bch2_bpos_to_text() more consistently
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
18fc6ae503
commit
f020bfcdb0
@ -1717,9 +1717,10 @@ void bch2_bfloat_to_text(struct printbuf *out, struct btree *b,
|
|||||||
uk = bkey_unpack_key(b, k);
|
uk = bkey_unpack_key(b, k);
|
||||||
pr_buf(out,
|
pr_buf(out,
|
||||||
" failed unpacked at depth %u\n"
|
" failed unpacked at depth %u\n"
|
||||||
"\t%llu:%llu\n",
|
"\t",
|
||||||
ilog2(j),
|
ilog2(j));
|
||||||
uk.p.inode, uk.p.offset);
|
bch2_bpos_to_text(out, uk.p);
|
||||||
|
pr_buf(out, "\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1064,15 +1064,14 @@ void bch2_btree_node_to_text(struct printbuf *out, struct bch_fs *c,
|
|||||||
|
|
||||||
bch2_btree_keys_stats(b, &stats);
|
bch2_btree_keys_stats(b, &stats);
|
||||||
|
|
||||||
pr_buf(out,
|
pr_buf(out, "l %u ", b->c.level);
|
||||||
"l %u %llu:%llu - %llu:%llu:\n"
|
bch2_bpos_to_text(out, b->data->min_key);
|
||||||
" ptrs: ",
|
pr_buf(out, " - ");
|
||||||
b->c.level,
|
bch2_bpos_to_text(out, b->data->max_key);
|
||||||
b->data->min_key.inode,
|
pr_buf(out, ":\n"
|
||||||
b->data->min_key.offset,
|
" ptrs: ");
|
||||||
b->data->max_key.inode,
|
|
||||||
b->data->max_key.offset);
|
|
||||||
bch2_val_to_text(out, c, bkey_i_to_s_c(&b->key));
|
bch2_val_to_text(out, c, bkey_i_to_s_c(&b->key));
|
||||||
|
|
||||||
pr_buf(out, "\n"
|
pr_buf(out, "\n"
|
||||||
" format: u64s %u fields %u %u %u %u %u\n"
|
" format: u64s %u fields %u %u %u %u %u\n"
|
||||||
" unpack fn len: %u\n"
|
" unpack fn len: %u\n"
|
||||||
|
@ -73,12 +73,13 @@ static int bch2_gc_check_topology(struct bch_fs *c,
|
|||||||
if (cur.k->k.type == KEY_TYPE_btree_ptr_v2) {
|
if (cur.k->k.type == KEY_TYPE_btree_ptr_v2) {
|
||||||
struct bkey_i_btree_ptr_v2 *bp = bkey_i_to_btree_ptr_v2(cur.k);
|
struct bkey_i_btree_ptr_v2 *bp = bkey_i_to_btree_ptr_v2(cur.k);
|
||||||
|
|
||||||
if (bkey_deleted(&prev->k->k))
|
if (bkey_deleted(&prev->k->k)) {
|
||||||
scnprintf(buf1, sizeof(buf1), "start of node: %llu:%llu",
|
struct printbuf out = PBUF(buf1);
|
||||||
node_start.inode,
|
pr_buf(&out, "start of node: ");
|
||||||
node_start.offset);
|
bch2_bpos_to_text(&out, node_start);
|
||||||
else
|
} else {
|
||||||
bch2_bkey_val_to_text(&PBUF(buf1), c, bkey_i_to_s_c(prev->k));
|
bch2_bkey_val_to_text(&PBUF(buf1), c, bkey_i_to_s_c(prev->k));
|
||||||
|
}
|
||||||
|
|
||||||
if (fsck_err_on(bkey_cmp(expected_start, bp->v.min_key), c,
|
if (fsck_err_on(bkey_cmp(expected_start, bp->v.min_key), c,
|
||||||
"btree node with incorrect min_key at btree %s level %u:\n"
|
"btree node with incorrect min_key at btree %s level %u:\n"
|
||||||
@ -554,6 +555,7 @@ static int bch2_gc_btree_init(struct bch_fs *c,
|
|||||||
: !btree_node_type_needs_gc(btree_id) ? 1
|
: !btree_node_type_needs_gc(btree_id) ? 1
|
||||||
: 0;
|
: 0;
|
||||||
u8 max_stale = 0;
|
u8 max_stale = 0;
|
||||||
|
char buf[100];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
b = c->btree_roots[btree_id].b;
|
b = c->btree_roots[btree_id].b;
|
||||||
@ -563,16 +565,14 @@ static int bch2_gc_btree_init(struct bch_fs *c,
|
|||||||
|
|
||||||
six_lock_read(&b->c.lock, NULL, NULL);
|
six_lock_read(&b->c.lock, NULL, NULL);
|
||||||
if (fsck_err_on(bkey_cmp(b->data->min_key, POS_MIN), c,
|
if (fsck_err_on(bkey_cmp(b->data->min_key, POS_MIN), c,
|
||||||
"btree root with incorrect min_key: %llu:%llu",
|
"btree root with incorrect min_key: %s",
|
||||||
b->data->min_key.inode,
|
(bch2_bpos_to_text(&PBUF(buf), b->data->min_key), buf))) {
|
||||||
b->data->min_key.offset)) {
|
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsck_err_on(bkey_cmp(b->data->max_key, POS_MAX), c,
|
if (fsck_err_on(bkey_cmp(b->data->max_key, POS_MAX), c,
|
||||||
"btree root with incorrect min_key: %llu:%llu",
|
"btree root with incorrect max_key: %s",
|
||||||
b->data->max_key.inode,
|
(bch2_bpos_to_text(&PBUF(buf), b->data->max_key), buf))) {
|
||||||
b->data->max_key.offset)) {
|
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,12 +488,12 @@ enum btree_validate_ret {
|
|||||||
({ \
|
({ \
|
||||||
__label__ out; \
|
__label__ out; \
|
||||||
char _buf[300]; \
|
char _buf[300]; \
|
||||||
char *buf2 = _buf; \
|
char *_buf2 = _buf; \
|
||||||
struct printbuf out = PBUF(_buf); \
|
struct printbuf out = PBUF(_buf); \
|
||||||
\
|
\
|
||||||
buf2 = kmalloc(4096, GFP_ATOMIC); \
|
_buf2 = kmalloc(4096, GFP_ATOMIC); \
|
||||||
if (buf2) \
|
if (_buf2) \
|
||||||
out = _PBUF(buf2, 4986); \
|
out = _PBUF(_buf2, 4986); \
|
||||||
\
|
\
|
||||||
btree_err_msg(&out, c, ca, b, i, b->written, write); \
|
btree_err_msg(&out, c, ca, b, i, b->written, write); \
|
||||||
pr_buf(&out, ": " msg, ##__VA_ARGS__); \
|
pr_buf(&out, ": " msg, ##__VA_ARGS__); \
|
||||||
@ -501,13 +501,13 @@ enum btree_validate_ret {
|
|||||||
if (type == BTREE_ERR_FIXABLE && \
|
if (type == BTREE_ERR_FIXABLE && \
|
||||||
write == READ && \
|
write == READ && \
|
||||||
!test_bit(BCH_FS_INITIAL_GC_DONE, &c->flags)) { \
|
!test_bit(BCH_FS_INITIAL_GC_DONE, &c->flags)) { \
|
||||||
mustfix_fsck_err(c, "%s", buf2); \
|
mustfix_fsck_err(c, "%s", _buf2); \
|
||||||
goto out; \
|
goto out; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
switch (write) { \
|
switch (write) { \
|
||||||
case READ: \
|
case READ: \
|
||||||
bch_err(c, "%s", buf2); \
|
bch_err(c, "%s", _buf2); \
|
||||||
\
|
\
|
||||||
switch (type) { \
|
switch (type) { \
|
||||||
case BTREE_ERR_FIXABLE: \
|
case BTREE_ERR_FIXABLE: \
|
||||||
@ -528,7 +528,7 @@ enum btree_validate_ret {
|
|||||||
} \
|
} \
|
||||||
break; \
|
break; \
|
||||||
case WRITE: \
|
case WRITE: \
|
||||||
bch_err(c, "corrupt metadata before write: %s", buf2); \
|
bch_err(c, "corrupt metadata before write: %s", _buf2); \
|
||||||
\
|
\
|
||||||
if (bch2_fs_inconsistent(c)) { \
|
if (bch2_fs_inconsistent(c)) { \
|
||||||
ret = BCH_FSCK_ERRORS_NOT_FIXED; \
|
ret = BCH_FSCK_ERRORS_NOT_FIXED; \
|
||||||
@ -537,8 +537,8 @@ enum btree_validate_ret {
|
|||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
out: \
|
out: \
|
||||||
if (buf2 != _buf) \
|
if (_buf2 != _buf) \
|
||||||
kfree(buf2); \
|
kfree(_buf2); \
|
||||||
true; \
|
true; \
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -550,6 +550,8 @@ static int validate_bset(struct bch_fs *c, struct bch_dev *ca,
|
|||||||
{
|
{
|
||||||
unsigned version = le16_to_cpu(i->version);
|
unsigned version = le16_to_cpu(i->version);
|
||||||
const char *err;
|
const char *err;
|
||||||
|
char buf1[100];
|
||||||
|
char buf2[100];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
btree_err_on((version != BCH_BSET_VERSION_OLD &&
|
btree_err_on((version != BCH_BSET_VERSION_OLD &&
|
||||||
@ -613,37 +615,20 @@ static int validate_bset(struct bch_fs *c, struct bch_dev *ca,
|
|||||||
|
|
||||||
btree_err_on(bkey_cmp(b->data->min_key, bp->min_key),
|
btree_err_on(bkey_cmp(b->data->min_key, bp->min_key),
|
||||||
BTREE_ERR_MUST_RETRY, c, ca, b, NULL,
|
BTREE_ERR_MUST_RETRY, c, ca, b, NULL,
|
||||||
"incorrect min_key: got %llu:%llu should be %llu:%llu",
|
"incorrect min_key: got %s should be %s",
|
||||||
b->data->min_key.inode,
|
(bch2_bpos_to_text(&PBUF(buf1), bn->min_key), buf1),
|
||||||
b->data->min_key.offset,
|
(bch2_bpos_to_text(&PBUF(buf2), bp->min_key), buf2));
|
||||||
bp->min_key.inode,
|
|
||||||
bp->min_key.offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btree_err_on(bkey_cmp(bn->max_key, b->key.k.p),
|
btree_err_on(bkey_cmp(bn->max_key, b->key.k.p),
|
||||||
BTREE_ERR_MUST_RETRY, c, ca, b, i,
|
BTREE_ERR_MUST_RETRY, c, ca, b, i,
|
||||||
"incorrect max key %llu:%llu",
|
"incorrect max key %s",
|
||||||
bn->max_key.inode,
|
(bch2_bpos_to_text(&PBUF(buf1), bn->max_key), buf1));
|
||||||
bn->max_key.offset);
|
|
||||||
|
|
||||||
if (write)
|
if (write)
|
||||||
compat_btree_node(b->c.level, b->c.btree_id, version,
|
compat_btree_node(b->c.level, b->c.btree_id, version,
|
||||||
BSET_BIG_ENDIAN(i), write, bn);
|
BSET_BIG_ENDIAN(i), write, bn);
|
||||||
|
|
||||||
/* XXX: ideally we would be validating min_key too */
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* not correct anymore, due to btree node write error
|
|
||||||
* handling
|
|
||||||
*
|
|
||||||
* need to add bn->seq to btree keys and verify
|
|
||||||
* against that
|
|
||||||
*/
|
|
||||||
btree_err_on(!extent_contains_ptr(bkey_i_to_s_c_extent(&b->key),
|
|
||||||
bn->ptr),
|
|
||||||
BTREE_ERR_FATAL, c, b, i,
|
|
||||||
"incorrect backpointer");
|
|
||||||
#endif
|
|
||||||
err = bch2_bkey_format_validate(&bn->format);
|
err = bch2_bkey_format_validate(&bn->format);
|
||||||
btree_err_on(err,
|
btree_err_on(err,
|
||||||
BTREE_ERR_FATAL, c, ca, b, i,
|
BTREE_ERR_FATAL, c, ca, b, i,
|
||||||
|
@ -495,7 +495,7 @@ static void bch2_btree_iter_verify_level(struct btree_iter *iter,
|
|||||||
struct btree_node_iter tmp = l->iter;
|
struct btree_node_iter tmp = l->iter;
|
||||||
bool locked = btree_node_locked(iter, level);
|
bool locked = btree_node_locked(iter, level);
|
||||||
struct bkey_packed *p, *k;
|
struct bkey_packed *p, *k;
|
||||||
char buf1[100], buf2[100];
|
char buf1[100], buf2[100], buf3[100];
|
||||||
const char *msg;
|
const char *msg;
|
||||||
|
|
||||||
if (!bch2_debug_check_iterators)
|
if (!bch2_debug_check_iterators)
|
||||||
@ -552,26 +552,26 @@ unlock:
|
|||||||
btree_node_unlock(iter, level);
|
btree_node_unlock(iter, level);
|
||||||
return;
|
return;
|
||||||
err:
|
err:
|
||||||
strcpy(buf1, "(none)");
|
|
||||||
strcpy(buf2, "(none)");
|
strcpy(buf2, "(none)");
|
||||||
|
strcpy(buf3, "(none)");
|
||||||
|
|
||||||
|
bch2_bpos_to_text(&PBUF(buf1), iter->real_pos);
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
struct bkey uk = bkey_unpack_key(l->b, p);
|
struct bkey uk = bkey_unpack_key(l->b, p);
|
||||||
bch2_bkey_to_text(&PBUF(buf1), &uk);
|
bch2_bkey_to_text(&PBUF(buf2), &uk);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k) {
|
if (k) {
|
||||||
struct bkey uk = bkey_unpack_key(l->b, k);
|
struct bkey uk = bkey_unpack_key(l->b, k);
|
||||||
bch2_bkey_to_text(&PBUF(buf2), &uk);
|
bch2_bkey_to_text(&PBUF(buf3), &uk);
|
||||||
}
|
}
|
||||||
|
|
||||||
panic("iterator should be %s key at level %u:\n"
|
panic("iterator should be %s key at level %u:\n"
|
||||||
"iter pos %llu:%llu\n"
|
"iter pos %s\n"
|
||||||
"prev key %s\n"
|
"prev key %s\n"
|
||||||
"cur key %s\n",
|
"cur key %s\n",
|
||||||
msg, level,
|
msg, level, buf1, buf2, buf3);
|
||||||
iter->real_pos.inode, iter->real_pos.offset,
|
|
||||||
buf1, buf2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bch2_btree_iter_verify(struct btree_iter *iter)
|
static void bch2_btree_iter_verify(struct btree_iter *iter)
|
||||||
@ -876,22 +876,23 @@ static void btree_iter_verify_new_node(struct btree_iter *iter, struct btree *b)
|
|||||||
if (!k ||
|
if (!k ||
|
||||||
bkey_deleted(k) ||
|
bkey_deleted(k) ||
|
||||||
bkey_cmp_left_packed(l->b, k, &b->key.k.p)) {
|
bkey_cmp_left_packed(l->b, k, &b->key.k.p)) {
|
||||||
char buf[100];
|
char buf1[100];
|
||||||
|
char buf2[100];
|
||||||
|
char buf3[100];
|
||||||
|
char buf4[100];
|
||||||
struct bkey uk = bkey_unpack_key(b, k);
|
struct bkey uk = bkey_unpack_key(b, k);
|
||||||
|
|
||||||
bch2_dump_btree_node(iter->trans->c, l->b);
|
bch2_dump_btree_node(iter->trans->c, l->b);
|
||||||
bch2_bkey_to_text(&PBUF(buf), &uk);
|
bch2_bpos_to_text(&PBUF(buf1), iter->real_pos);
|
||||||
|
bch2_bkey_to_text(&PBUF(buf2), &uk);
|
||||||
|
bch2_bpos_to_text(&PBUF(buf3), b->data->min_key);
|
||||||
|
bch2_bpos_to_text(&PBUF(buf3), b->data->max_key);
|
||||||
panic("parent iter doesn't point to new node:\n"
|
panic("parent iter doesn't point to new node:\n"
|
||||||
"iter pos %s %llu:%llu\n"
|
"iter pos %s %s\n"
|
||||||
"iter key %s\n"
|
"iter key %s\n"
|
||||||
"new node %llu:%llu-%llu:%llu\n",
|
"new node %s-%s\n",
|
||||||
bch2_btree_ids[iter->btree_id],
|
bch2_btree_ids[iter->btree_id], buf1,
|
||||||
iter->pos.inode,
|
buf2, buf3, buf4);
|
||||||
iter->pos.offset,
|
|
||||||
buf,
|
|
||||||
b->data->min_key.inode,
|
|
||||||
b->data->min_key.offset,
|
|
||||||
b->key.k.p.inode, b->key.k.p.offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parent_locked)
|
if (!parent_locked)
|
||||||
@ -2011,12 +2012,12 @@ static void btree_trans_iter_alloc_fail(struct btree_trans *trans)
|
|||||||
|
|
||||||
struct btree_iter *iter;
|
struct btree_iter *iter;
|
||||||
struct btree_insert_entry *i;
|
struct btree_insert_entry *i;
|
||||||
|
char buf[100];
|
||||||
|
|
||||||
trans_for_each_iter(trans, iter)
|
trans_for_each_iter(trans, iter)
|
||||||
printk(KERN_ERR "iter: btree %s pos %llu:%llu%s%s%s %ps\n",
|
printk(KERN_ERR "iter: btree %s pos %s%s%s%s %ps\n",
|
||||||
bch2_btree_ids[iter->btree_id],
|
bch2_btree_ids[iter->btree_id],
|
||||||
iter->pos.inode,
|
(bch2_bpos_to_text(&PBUF(buf), iter->pos), buf),
|
||||||
iter->pos.offset,
|
|
||||||
btree_iter_live(trans, iter) ? " live" : "",
|
btree_iter_live(trans, iter) ? " live" : "",
|
||||||
(trans->iters_touched & (1ULL << iter->idx)) ? " touched" : "",
|
(trans->iters_touched & (1ULL << iter->idx)) ? " touched" : "",
|
||||||
iter->flags & BTREE_ITER_KEEP_UNTIL_COMMIT ? " keep" : "",
|
iter->flags & BTREE_ITER_KEEP_UNTIL_COMMIT ? " keep" : "",
|
||||||
|
@ -35,6 +35,7 @@ static void btree_node_interior_verify(struct bch_fs *c, struct btree *b)
|
|||||||
struct bkey_s_c k;
|
struct bkey_s_c k;
|
||||||
struct bkey_s_c_btree_ptr_v2 bp;
|
struct bkey_s_c_btree_ptr_v2 bp;
|
||||||
struct bkey unpacked;
|
struct bkey unpacked;
|
||||||
|
char buf1[100], buf2[100];
|
||||||
|
|
||||||
BUG_ON(!b->c.level);
|
BUG_ON(!b->c.level);
|
||||||
|
|
||||||
@ -51,24 +52,19 @@ static void btree_node_interior_verify(struct bch_fs *c, struct btree *b)
|
|||||||
|
|
||||||
if (bkey_cmp(next_node, bp.v->min_key)) {
|
if (bkey_cmp(next_node, bp.v->min_key)) {
|
||||||
bch2_dump_btree_node(c, b);
|
bch2_dump_btree_node(c, b);
|
||||||
panic("expected next min_key %llu:%llu got %llu:%llu\n",
|
panic("expected next min_key %s got %s\n",
|
||||||
next_node.inode,
|
(bch2_bpos_to_text(&PBUF(buf1), next_node), buf1),
|
||||||
next_node.offset,
|
(bch2_bpos_to_text(&PBUF(buf2), bp.v->min_key), buf2));
|
||||||
bp.v->min_key.inode,
|
|
||||||
bp.v->min_key.offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bch2_btree_node_iter_advance(&iter, b);
|
bch2_btree_node_iter_advance(&iter, b);
|
||||||
|
|
||||||
if (bch2_btree_node_iter_end(&iter)) {
|
if (bch2_btree_node_iter_end(&iter)) {
|
||||||
|
|
||||||
if (bkey_cmp(k.k->p, b->key.k.p)) {
|
if (bkey_cmp(k.k->p, b->key.k.p)) {
|
||||||
bch2_dump_btree_node(c, b);
|
bch2_dump_btree_node(c, b);
|
||||||
panic("expected end %llu:%llu got %llu:%llu\n",
|
panic("expected end %s got %s\n",
|
||||||
b->key.k.p.inode,
|
(bch2_bpos_to_text(&PBUF(buf1), b->key.k.p), buf1),
|
||||||
b->key.k.p.offset,
|
(bch2_bpos_to_text(&PBUF(buf2), k.k->p), buf2));
|
||||||
k.k->p.inode,
|
|
||||||
k.k->p.offset);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -281,10 +281,10 @@ void bch2_rebalance_work_to_text(struct printbuf *out, struct bch_fs *c)
|
|||||||
h1);
|
h1);
|
||||||
break;
|
break;
|
||||||
case REBALANCE_RUNNING:
|
case REBALANCE_RUNNING:
|
||||||
pr_buf(out, "running\n");
|
pr_buf(out, "running\n"
|
||||||
pr_buf(out, "pos %llu:%llu\n",
|
"pos ");
|
||||||
r->move_stats.pos.inode,
|
bch2_bpos_to_text(out, r->move_stats.pos);
|
||||||
r->move_stats.pos.offset);
|
pr_buf(out, "\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user