diff options
-rw-r--r-- | fs/bcachefs/bset.c | 7 | ||||
-rw-r--r-- | fs/bcachefs/btree_cache.c | 15 | ||||
-rw-r--r-- | fs/bcachefs/btree_gc.c | 22 | ||||
-rw-r--r-- | fs/bcachefs/btree_io.c | 47 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.c | 45 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_interior.c | 18 | ||||
-rw-r--r-- | fs/bcachefs/rebalance.c | 8 |
7 files changed, 72 insertions, 90 deletions
diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index ac2fd8242ca4..c371f402eaa3 100644 --- a/fs/bcachefs/bset.c +++ b/fs/bcachefs/bset.c @@ -1717,9 +1717,10 @@ void bch2_bfloat_to_text(struct printbuf *out, struct btree *b, uk = bkey_unpack_key(b, k); pr_buf(out, " failed unpacked at depth %u\n" - "\t%llu:%llu\n", - ilog2(j), - uk.p.inode, uk.p.offset); + "\t", + ilog2(j)); + bch2_bpos_to_text(out, uk.p); + pr_buf(out, "\n"); break; } } diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 1a6b4618c2ae..775b3e8468da 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -1064,15 +1064,14 @@ void bch2_btree_node_to_text(struct printbuf *out, struct bch_fs *c, bch2_btree_keys_stats(b, &stats); - pr_buf(out, - "l %u %llu:%llu - %llu:%llu:\n" - " ptrs: ", - b->c.level, - b->data->min_key.inode, - b->data->min_key.offset, - b->data->max_key.inode, - b->data->max_key.offset); + pr_buf(out, "l %u ", b->c.level); + bch2_bpos_to_text(out, b->data->min_key); + pr_buf(out, " - "); + bch2_bpos_to_text(out, b->data->max_key); + pr_buf(out, ":\n" + " ptrs: "); bch2_val_to_text(out, c, bkey_i_to_s_c(&b->key)); + pr_buf(out, "\n" " format: u64s %u fields %u %u %u %u %u\n" " unpack fn len: %u\n" diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 7506a3de58ff..808bb9ca8d50 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -73,12 +73,13 @@ static int bch2_gc_check_topology(struct bch_fs *c, 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); - if (bkey_deleted(&prev->k->k)) - scnprintf(buf1, sizeof(buf1), "start of node: %llu:%llu", - node_start.inode, - node_start.offset); - else + if (bkey_deleted(&prev->k->k)) { + struct printbuf out = PBUF(buf1); + pr_buf(&out, "start of node: "); + bch2_bpos_to_text(&out, node_start); + } else { 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, "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 : 0; u8 max_stale = 0; + char buf[100]; int ret = 0; 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); if (fsck_err_on(bkey_cmp(b->data->min_key, POS_MIN), c, - "btree root with incorrect min_key: %llu:%llu", - b->data->min_key.inode, - b->data->min_key.offset)) { + "btree root with incorrect min_key: %s", + (bch2_bpos_to_text(&PBUF(buf), b->data->min_key), buf))) { BUG(); } if (fsck_err_on(bkey_cmp(b->data->max_key, POS_MAX), c, - "btree root with incorrect min_key: %llu:%llu", - b->data->max_key.inode, - b->data->max_key.offset)) { + "btree root with incorrect max_key: %s", + (bch2_bpos_to_text(&PBUF(buf), b->data->max_key), buf))) { BUG(); } diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index a0df2c67da65..d547bfabf09f 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -488,12 +488,12 @@ enum btree_validate_ret { ({ \ __label__ out; \ char _buf[300]; \ - char *buf2 = _buf; \ + char *_buf2 = _buf; \ struct printbuf out = PBUF(_buf); \ \ - buf2 = kmalloc(4096, GFP_ATOMIC); \ - if (buf2) \ - out = _PBUF(buf2, 4986); \ + _buf2 = kmalloc(4096, GFP_ATOMIC); \ + if (_buf2) \ + out = _PBUF(_buf2, 4986); \ \ btree_err_msg(&out, c, ca, b, i, b->written, write); \ pr_buf(&out, ": " msg, ##__VA_ARGS__); \ @@ -501,13 +501,13 @@ enum btree_validate_ret { if (type == BTREE_ERR_FIXABLE && \ write == READ && \ !test_bit(BCH_FS_INITIAL_GC_DONE, &c->flags)) { \ - mustfix_fsck_err(c, "%s", buf2); \ + mustfix_fsck_err(c, "%s", _buf2); \ goto out; \ } \ \ switch (write) { \ case READ: \ - bch_err(c, "%s", buf2); \ + bch_err(c, "%s", _buf2); \ \ switch (type) { \ case BTREE_ERR_FIXABLE: \ @@ -528,7 +528,7 @@ enum btree_validate_ret { } \ break; \ 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)) { \ ret = BCH_FSCK_ERRORS_NOT_FIXED; \ @@ -537,8 +537,8 @@ enum btree_validate_ret { break; \ } \ out: \ - if (buf2 != _buf) \ - kfree(buf2); \ + if (_buf2 != _buf) \ + kfree(_buf2); \ true; \ }) @@ -550,6 +550,8 @@ static int validate_bset(struct bch_fs *c, struct bch_dev *ca, { unsigned version = le16_to_cpu(i->version); const char *err; + char buf1[100]; + char buf2[100]; int ret = 0; 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_MUST_RETRY, c, ca, b, NULL, - "incorrect min_key: got %llu:%llu should be %llu:%llu", - b->data->min_key.inode, - b->data->min_key.offset, - bp->min_key.inode, - bp->min_key.offset); + "incorrect min_key: got %s should be %s", + (bch2_bpos_to_text(&PBUF(buf1), bn->min_key), buf1), + (bch2_bpos_to_text(&PBUF(buf2), bp->min_key), buf2)); } btree_err_on(bkey_cmp(bn->max_key, b->key.k.p), BTREE_ERR_MUST_RETRY, c, ca, b, i, - "incorrect max key %llu:%llu", - bn->max_key.inode, - bn->max_key.offset); + "incorrect max key %s", + (bch2_bpos_to_text(&PBUF(buf1), bn->max_key), buf1)); if (write) compat_btree_node(b->c.level, b->c.btree_id, version, 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); btree_err_on(err, BTREE_ERR_FATAL, c, ca, b, i, diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index c05bc8ff8b8d..69d15bb20c7c 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -495,7 +495,7 @@ static void bch2_btree_iter_verify_level(struct btree_iter *iter, struct btree_node_iter tmp = l->iter; bool locked = btree_node_locked(iter, level); struct bkey_packed *p, *k; - char buf1[100], buf2[100]; + char buf1[100], buf2[100], buf3[100]; const char *msg; if (!bch2_debug_check_iterators) @@ -552,26 +552,26 @@ unlock: btree_node_unlock(iter, level); return; err: - strcpy(buf1, "(none)"); strcpy(buf2, "(none)"); + strcpy(buf3, "(none)"); + + bch2_bpos_to_text(&PBUF(buf1), iter->real_pos); if (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) { 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" - "iter pos %llu:%llu\n" + "iter pos %s\n" "prev key %s\n" "cur key %s\n", - msg, level, - iter->real_pos.inode, iter->real_pos.offset, - buf1, buf2); + msg, level, buf1, buf2, buf3); } 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 || bkey_deleted(k) || 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); 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" - "iter pos %s %llu:%llu\n" + "iter pos %s %s\n" "iter key %s\n" - "new node %llu:%llu-%llu:%llu\n", - bch2_btree_ids[iter->btree_id], - iter->pos.inode, - iter->pos.offset, - buf, - b->data->min_key.inode, - b->data->min_key.offset, - b->key.k.p.inode, b->key.k.p.offset); + "new node %s-%s\n", + bch2_btree_ids[iter->btree_id], buf1, + buf2, buf3, buf4); } if (!parent_locked) @@ -2011,12 +2012,12 @@ static void btree_trans_iter_alloc_fail(struct btree_trans *trans) struct btree_iter *iter; struct btree_insert_entry *i; + char buf[100]; 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], - iter->pos.inode, - iter->pos.offset, + (bch2_bpos_to_text(&PBUF(buf), iter->pos), buf), btree_iter_live(trans, iter) ? " live" : "", (trans->iters_touched & (1ULL << iter->idx)) ? " touched" : "", iter->flags & BTREE_ITER_KEEP_UNTIL_COMMIT ? " keep" : "", diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index e1dd21320153..4ad8084714f9 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -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_btree_ptr_v2 bp; struct bkey unpacked; + char buf1[100], buf2[100]; 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)) { bch2_dump_btree_node(c, b); - panic("expected next min_key %llu:%llu got %llu:%llu\n", - next_node.inode, - next_node.offset, - bp.v->min_key.inode, - bp.v->min_key.offset); + panic("expected next min_key %s got %s\n", + (bch2_bpos_to_text(&PBUF(buf1), next_node), buf1), + (bch2_bpos_to_text(&PBUF(buf2), bp.v->min_key), buf2)); } bch2_btree_node_iter_advance(&iter, b); if (bch2_btree_node_iter_end(&iter)) { - if (bkey_cmp(k.k->p, b->key.k.p)) { bch2_dump_btree_node(c, b); - panic("expected end %llu:%llu got %llu:%llu\n", - b->key.k.p.inode, - b->key.k.p.offset, - k.k->p.inode, - k.k->p.offset); + panic("expected end %s got %s\n", + (bch2_bpos_to_text(&PBUF(buf1), b->key.k.p), buf1), + (bch2_bpos_to_text(&PBUF(buf2), k.k->p), buf2)); } break; } diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c index 0e1f18d82855..b7e61da0f4d1 100644 --- a/fs/bcachefs/rebalance.c +++ b/fs/bcachefs/rebalance.c @@ -281,10 +281,10 @@ void bch2_rebalance_work_to_text(struct printbuf *out, struct bch_fs *c) h1); break; case REBALANCE_RUNNING: - pr_buf(out, "running\n"); - pr_buf(out, "pos %llu:%llu\n", - r->move_stats.pos.inode, - r->move_stats.pos.offset); + pr_buf(out, "running\n" + "pos "); + bch2_bpos_to_text(out, r->move_stats.pos); + pr_buf(out, "\n"); break; } } |