diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-11-13 14:41:06 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2020-11-16 18:23:54 -0500 |
commit | 13f53aa228c83731226f4a359983215f1f7c2a47 (patch) | |
tree | f13df1911f064fe507afbd2420d49be797904e63 /libbcachefs/bkey_methods.c | |
parent | 3420d86959401e5884627efdf3c2361e50b05eaa (diff) |
Update bcachefs sources to d1fd471830 bcachefs: Add more debug checks
Diffstat (limited to 'libbcachefs/bkey_methods.c')
-rw-r--r-- | libbcachefs/bkey_methods.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/libbcachefs/bkey_methods.c b/libbcachefs/bkey_methods.c index 99b7fce2..f5779795 100644 --- a/libbcachefs/bkey_methods.c +++ b/libbcachefs/bkey_methods.c @@ -181,8 +181,12 @@ void bch2_bpos_to_text(struct printbuf *out, struct bpos pos) void bch2_bkey_to_text(struct printbuf *out, const struct bkey *k) { if (k) { - pr_buf(out, "u64s %u type %s ", k->u64s, - bch2_bkey_types[k->type]); + pr_buf(out, "u64s %u type ", k->u64s); + + if (k->type < KEY_TYPE_MAX) + pr_buf(out, "%s ", bch2_bkey_types[k->type]); + else + pr_buf(out, "%u ", k->type); bch2_bpos_to_text(out, k->p); @@ -196,10 +200,14 @@ void bch2_bkey_to_text(struct printbuf *out, const struct bkey *k) void bch2_val_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c k) { - const struct bkey_ops *ops = &bch2_bkey_ops[k.k->type]; + if (k.k->type < KEY_TYPE_MAX) { + const struct bkey_ops *ops = &bch2_bkey_ops[k.k->type]; - if (likely(ops->val_to_text)) - ops->val_to_text(out, c, k); + if (likely(ops->val_to_text)) + ops->val_to_text(out, c, k); + } else { + pr_buf(out, "(invalid type %u)", k.k->type); + } } void bch2_bkey_val_to_text(struct printbuf *out, struct bch_fs *c, |