bcachefs: Move tabstop setup to bch2_dev_usage_to_text()
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 4 Sep 2024 21:51:16 +0000 (17:51 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Sep 2024 15:39:48 +0000 (11:39 -0400)
No reason for it not to be where it's needed.

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

index bf8fb9c..d0e0b56 100644 (file)
@@ -1729,13 +1729,6 @@ void bch2_dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca)
        for (unsigned i = 0; i < ARRAY_SIZE(c->open_buckets); i++)
                nr[c->open_buckets[i].data_type]++;
 
-       printbuf_tabstops_reset(out);
-       printbuf_tabstop_push(out, 12);
-       printbuf_tabstop_push(out, 16);
-       printbuf_tabstop_push(out, 16);
-       printbuf_tabstop_push(out, 16);
-       printbuf_tabstop_push(out, 16);
-
        bch2_dev_usage_to_text(out, ca, &stats);
 
        prt_newline(out);
index 4a0f55d..4abd22d 100644 (file)
@@ -75,6 +75,15 @@ void bch2_dev_usage_to_text(struct printbuf *out,
                            struct bch_dev *ca,
                            struct bch_dev_usage *usage)
 {
+       if (out->nr_tabstops < 5) {
+               printbuf_tabstops_reset(out);
+               printbuf_tabstop_push(out, 12);
+               printbuf_tabstop_push(out, 16);
+               printbuf_tabstop_push(out, 16);
+               printbuf_tabstop_push(out, 16);
+               printbuf_tabstop_push(out, 16);
+       }
+
        prt_printf(out, "\tbuckets\rsectors\rfragmented\r\n");
 
        for (unsigned i = 0; i < BCH_DATA_NR; i++) {