diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-31 06:40:19 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:28 +0300 |
commit | 1296ab552040e09b35f37b8c523d4f1711ac8435 (patch) | |
tree | 018def7f7b72e2449937f9720d7b779008e91056 | |
parent | 5aabb32442c44c9cfc41a2c29638aebeb3e9cb26 (diff) | |
download | linux-1296ab552040e09b35f37b8c523d4f1711ac8435.tar.xz |
bcachefs: Improve bch2_bkey_ptrs_to_text()
Print bucket:offset when the filesystem is online; this makes debugging
easier when correlating with alloc updates.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | fs/bcachefs/extents.c | 22 | ||||
-rw-r--r-- | fs/bcachefs/super.h | 6 |
2 files changed, 20 insertions, 8 deletions
diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c index c78e10e8ec2c..01d14645579b 100644 --- a/fs/bcachefs/extents.c +++ b/fs/bcachefs/extents.c @@ -953,15 +953,21 @@ 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 = c && ptr->dev < c->sb.nr_devices && c->devs[ptr->dev] + ? bch_dev_bkey_exists(c, ptr->dev) + : NULL; + + if (!ca) { + pr_buf(out, "ptr: %u:%llu gen %u%s", ptr->dev, + (u64) ptr->offset, ptr->gen, + ptr->cached ? " cached" : ""); + } else { + u32 offset; + u64 b = sector_to_bucket_and_offset(ca, ptr->offset, &offset); - pr_buf(out, "ptr: %u:%llu gen %u%s", ptr->dev, - (u64) ptr->offset, ptr->gen, - ptr->cached ? " cached" : ""); - - if (c) { - 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:%u gen %u%s", ptr->dev, + b, offset, ptr->gen, + ptr->cached ? " cached" : ""); if (ca && ptr_stale(ca, ptr)) pr_buf(out, " stale"); diff --git a/fs/bcachefs/super.h b/fs/bcachefs/super.h index 6414f6a6bb91..359fa1e7fc18 100644 --- a/fs/bcachefs/super.h +++ b/fs/bcachefs/super.h @@ -26,6 +26,12 @@ static inline sector_t bucket_remainder(const struct bch_dev *ca, sector_t s) return remainder; } +static inline size_t sector_to_bucket_and_offset(const struct bch_dev *ca, sector_t s, + u32 *offset) +{ + return div_u64_rem(s, ca->mi.bucket_size, offset); +} + static inline bool bch2_dev_is_online(struct bch_dev *ca) { return !percpu_ref_is_zero(&ca->io_ref); |