From 12bf93a429c981cf337ce2c27504ec0171157f76 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 20 Feb 2022 05:00:45 -0500 Subject: bcachefs: Add .to_text() methods for all superblock sections This patch improves the superblock .to_text() methods and adds methods for all types that were missing them. It also improves printbufs by allowing them to specfiy what units we want to be printing in, and adds new wrapper methods for unifying our kernel and userspace environments. Signed-off-by: Kent Overstreet --- fs/bcachefs/extents.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'fs/bcachefs/extents.c') diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c index 3ed724e1fc98..c78e10e8ec2c 100644 --- a/fs/bcachefs/extents.c +++ b/fs/bcachefs/extents.c @@ -953,15 +953,19 @@ void bch2_bkey_ptrs_to_text(struct printbuf *out, struct bch_fs *c, switch (__extent_entry_type(entry)) { case BCH_EXTENT_ENTRY_ptr: ptr = entry_to_ptr(entry); - ca = ptr->dev < c->sb.nr_devices && c->devs[ptr->dev] - ? bch_dev_bkey_exists(c, ptr->dev) - : NULL; - pr_buf(out, "ptr: %u:%llu gen %u%s%s", ptr->dev, + pr_buf(out, "ptr: %u:%llu gen %u%s", ptr->dev, (u64) ptr->offset, ptr->gen, - ptr->cached ? " cached" : "", - ca && ptr_stale(ca, ptr) - ? " stale" : ""); + ptr->cached ? " cached" : ""); + + if (c) { + ca = ptr->dev < c->sb.nr_devices && c->devs[ptr->dev] + ? bch_dev_bkey_exists(c, ptr->dev) + : NULL; + + if (ca && ptr_stale(ca, ptr)) + pr_buf(out, " stale"); + } break; case BCH_EXTENT_ENTRY_crc32: case BCH_EXTENT_ENTRY_crc64: -- cgit v1.2.3