bcachefs: Improve bch2_stripe_to_text()
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 25 Feb 2023 00:26:03 +0000 (19:26 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:54 +0000 (17:09 -0400)
We now print pointers as bucket:offset, the same as how we print extent
pointers.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/ec.c

index b711f33f0e037a41a08c4c2dd659420b83b0e01d..473f1c09e106a35188212b989dc9f6c0b238d63d 100644 (file)
@@ -138,20 +138,28 @@ void bch2_stripe_to_text(struct printbuf *out, struct bch_fs *c,
                         struct bkey_s_c k)
 {
        const struct bch_stripe *s = bkey_s_c_to_stripe(k).v;
-       unsigned i;
+       unsigned i, nr_data = s->nr_blocks - s->nr_redundant;
 
        prt_printf(out, "algo %u sectors %u blocks %u:%u csum %u gran %u",
               s->algorithm,
               le16_to_cpu(s->sectors),
-              s->nr_blocks - s->nr_redundant,
+              nr_data,
               s->nr_redundant,
               s->csum_type,
               1U << s->csum_granularity_bits);
 
-       for (i = 0; i < s->nr_blocks; i++)
-               prt_printf(out, " %u:%llu:%u", s->ptrs[i].dev,
-                      (u64) s->ptrs[i].offset,
-                      stripe_blockcount_get(s, i));
+       for (i = 0; i < s->nr_blocks; i++) {
+               const struct bch_extent_ptr *ptr = s->ptrs + i;
+               struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev);
+               u32 offset;
+               u64 b = sector_to_bucket_and_offset(ca, ptr->offset, &offset);
+
+               prt_printf(out, " %u:%llu:%u", ptr->dev, b, offset);
+               if (i < nr_data)
+                       prt_printf(out, "#%u", stripe_blockcount_get(s, i));
+               if (ptr_stale(ca, ptr))
+                       prt_printf(out, " stale");
+       }
 }
 
 /* returns blocknr in stripe that we matched: */