diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-06-17 23:33:53 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:08:41 +0200 |
commit | a34782a0663cc3a5d8c4e4657480fa0e6ddc8a16 (patch) | |
tree | 32cd31b2c0996a779730688a5749f6b93f0bfab4 /fs | |
parent | bcachefs: Fix a deadlock in the RO path (diff) | |
download | linux-a34782a0663cc3a5d8c4e4657480fa0e6ddc8a16.tar.xz linux-a34782a0663cc3a5d8c4e4657480fa0e6ddc8a16.zip |
bcachefs: Change bch2_dump_bset() to also print key values
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/bset.c | 41 | ||||
-rw-r--r-- | fs/bcachefs/bset.h | 4 | ||||
-rw-r--r-- | fs/bcachefs/btree_io.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/debug.c | 6 |
4 files changed, 26 insertions, 27 deletions
diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index 09711352094c..797deaf0ad2e 100644 --- a/fs/bcachefs/bset.c +++ b/fs/bcachefs/bset.c @@ -52,21 +52,27 @@ struct bset_tree *bch2_bkey_to_bset(struct btree *b, struct bkey_packed *k) * by the time we actually do the insert will all be deleted. */ -void bch2_dump_bset(struct btree *b, struct bset *i, unsigned set) +void bch2_dump_bset(struct bch_fs *c, struct btree *b, + struct bset *i, unsigned set) { struct bkey_packed *_k, *_n; - struct bkey k, n; - char buf[120]; + struct bkey uk, n; + struct bkey_s_c k; + char buf[200]; if (!i->u64s) return; - for (_k = i->start, k = bkey_unpack_key(b, _k); + for (_k = i->start; _k < vstruct_last(i); - _k = _n, k = n) { + _k = _n) { _n = bkey_next_skip_noops(_k, vstruct_last(i)); - bch2_bkey_to_text(&PBUF(buf), &k); + k = bkey_disassemble(b, _k, &uk); + if (c) + bch2_bkey_val_to_text(&PBUF(buf), c, k); + else + bch2_bkey_to_text(&PBUF(buf), k.k); printk(KERN_ERR "block %u key %5zu: %s\n", set, _k->_data - i->_data, buf); @@ -75,31 +81,24 @@ void bch2_dump_bset(struct btree *b, struct bset *i, unsigned set) n = bkey_unpack_key(b, _n); - if (bkey_cmp(bkey_start_pos(&n), k.p) < 0) { + if (bkey_cmp(bkey_start_pos(&n), k.k->p) < 0) { printk(KERN_ERR "Key skipped backwards\n"); continue; } - /* - * Weird check for duplicate non extent keys: extents are - * deleted iff they have 0 size, so if it has zero size and it's - * not deleted these aren't extents: - */ - if (((!k.size && !bkey_deleted(&k)) || - (!n.size && !bkey_deleted(&n))) && - !bkey_deleted(&k) && - !bkey_cmp(n.p, k.p)) + if (!bkey_deleted(k.k) && + !bkey_cmp(n.p, k.k->p)) printk(KERN_ERR "Duplicate keys\n"); } } -void bch2_dump_btree_node(struct btree *b) +void bch2_dump_btree_node(struct bch_fs *c, struct btree *b) { struct bset_tree *t; console_lock(); for_each_bset(b, t) - bch2_dump_bset(b, bset(b, t), t - b->set); + bch2_dump_bset(c, b, bset(b, t), t - b->set); console_unlock(); } @@ -158,7 +157,7 @@ static void bch2_btree_node_iter_next_check(struct btree_node_iter *_iter, struct bkey nu = bkey_unpack_key(b, n); char buf1[80], buf2[80]; - bch2_dump_btree_node(b); + bch2_dump_btree_node(NULL, b); bch2_bkey_to_text(&PBUF(buf1), &ku); bch2_bkey_to_text(&PBUF(buf2), &nu); printk(KERN_ERR "out of order/overlapping:\n%s\n%s\n", @@ -236,7 +235,7 @@ void bch2_verify_insert_pos(struct btree *b, struct bkey_packed *where, char buf1[100]; char buf2[100]; - bch2_dump_btree_node(b); + bch2_dump_btree_node(NULL, b); bch2_bkey_to_text(&PBUF(buf1), &k1); bch2_bkey_to_text(&PBUF(buf2), &k2); @@ -257,7 +256,7 @@ void bch2_verify_insert_pos(struct btree *b, struct bkey_packed *where, char buf1[100]; char buf2[100]; - bch2_dump_btree_node(b); + bch2_dump_btree_node(NULL, b); bch2_bkey_to_text(&PBUF(buf1), &k1); bch2_bkey_to_text(&PBUF(buf2), &k2); diff --git a/fs/bcachefs/bset.h b/fs/bcachefs/bset.h index 50d0ce7d1afa..a2e5e3ee68db 100644 --- a/fs/bcachefs/bset.h +++ b/fs/bcachefs/bset.h @@ -615,8 +615,8 @@ void bch2_bfloat_to_text(struct printbuf *, struct btree *, /* Debug stuff */ -void bch2_dump_bset(struct btree *, struct bset *, unsigned); -void bch2_dump_btree_node(struct btree *); +void bch2_dump_bset(struct bch_fs *, struct btree *, struct bset *, unsigned); +void bch2_dump_btree_node(struct bch_fs *, struct btree *); void bch2_dump_btree_node_iter(struct btree *, struct btree_node_iter *); #ifdef CONFIG_BCACHEFS_DEBUG diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 5325c24548f9..2a253380fef9 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -897,7 +897,7 @@ static int validate_bset_keys(struct bch_fs *c, struct btree *b, bch2_bkey_to_text(&PBUF(buf1), &up); bch2_bkey_to_text(&PBUF(buf2), u.k); - bch2_dump_bset(b, i, 0); + bch2_dump_bset(c, b, i, 0); btree_err(BTREE_ERR_FATAL, c, b, i, "keys out of order: %s > %s", buf1, buf2); diff --git a/fs/bcachefs/debug.c b/fs/bcachefs/debug.c index 7adc5ae20b9f..be97cbba12e7 100644 --- a/fs/bcachefs/debug.c +++ b/fs/bcachefs/debug.c @@ -97,10 +97,10 @@ void __bch2_btree_verify(struct bch_fs *c, struct btree *b) console_lock(); printk(KERN_ERR "*** in memory:\n"); - bch2_dump_bset(b, inmemory, 0); + bch2_dump_bset(c, b, inmemory, 0); printk(KERN_ERR "*** read back in:\n"); - bch2_dump_bset(v, sorted, 0); + bch2_dump_bset(c, v, sorted, 0); while (offset < b->written) { if (!offset ) { @@ -117,7 +117,7 @@ void __bch2_btree_verify(struct bch_fs *c, struct btree *b) } printk(KERN_ERR "*** on disk block %u:\n", offset); - bch2_dump_bset(b, i, offset); + bch2_dump_bset(c, b, i, offset); offset += sectors; } |