summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/rebalance.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-02-25 13:18:19 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:25 -0400
commitfa8e94faeece12c20b541f647059f29867e98bc0 (patch)
tree43c5542168a6324d69c8671724e62c46e6265b8c /fs/bcachefs/rebalance.c
parent2be7b16eee9442f2c45ebde19bd3b50fcd030515 (diff)
downloadlinux-fa8e94faeece12c20b541f647059f29867e98bc0.tar.gz
linux-fa8e94faeece12c20b541f647059f29867e98bc0.tar.bz2
linux-fa8e94faeece12c20b541f647059f29867e98bc0.zip
bcachefs: Heap allocate printbufs
This patch changes printbufs dynamically allocate and reallocate a buffer as needed. Stack usage has become a bit of a problem, and a major cause of that has been static size string buffers on the stack. The most involved part of this refactoring is that printbufs must now be exited with printbuf_exit(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/rebalance.c')
-rw-r--r--fs/bcachefs/rebalance.c42
1 files changed, 27 insertions, 15 deletions
diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c
index fe0a1dbac199..babf98894e87 100644
--- a/fs/bcachefs/rebalance.c
+++ b/fs/bcachefs/rebalance.c
@@ -257,35 +257,47 @@ void bch2_rebalance_work_to_text(struct printbuf *out, struct bch_fs *c)
{
struct bch_fs_rebalance *r = &c->rebalance;
struct rebalance_work w = rebalance_work(c);
- char h1[21], h2[21];
- bch2_hprint(&PBUF(h1), w.dev_most_full_work << 9);
- bch2_hprint(&PBUF(h2), w.dev_most_full_capacity << 9);
- pr_buf(out, "fullest_dev (%i):\t%s/%s\n",
- w.dev_most_full_idx, h1, h2);
+ out->tabstops[0] = 20;
- bch2_hprint(&PBUF(h1), w.total_work << 9);
- bch2_hprint(&PBUF(h2), c->capacity << 9);
- pr_buf(out, "total work:\t\t%s/%s\n", h1, h2);
+ pr_buf(out, "fullest_dev (%i):", w.dev_most_full_idx);
+ pr_tab(out);
- pr_buf(out, "rate:\t\t\t%u\n", r->pd.rate.rate);
+ bch2_hprint(out, w.dev_most_full_work << 9);
+ pr_buf(out, "/");
+ bch2_hprint(out, w.dev_most_full_capacity << 9);
+ pr_newline(out);
+
+ pr_buf(out, "total work:");
+ pr_tab(out);
+
+ bch2_hprint(out, w.total_work << 9);
+ pr_buf(out, "/");
+ bch2_hprint(out, c->capacity << 9);
+ pr_newline(out);
+
+ pr_buf(out, "rate:");
+ pr_tab(out);
+ pr_buf(out, "%u", r->pd.rate.rate);
+ pr_newline(out);
switch (r->state) {
case REBALANCE_WAITING:
- pr_buf(out, "waiting\n");
+ pr_buf(out, "waiting");
break;
case REBALANCE_THROTTLED:
- bch2_hprint(&PBUF(h1),
+ pr_buf(out, "throttled for %lu sec or ",
+ (r->throttled_until_cputime - jiffies) / HZ);
+ bch2_hprint(out,
(r->throttled_until_iotime -
atomic64_read(&c->io_clock[WRITE].now)) << 9);
- pr_buf(out, "throttled for %lu sec or %s io\n",
- (r->throttled_until_cputime - jiffies) / HZ,
- h1);
+ pr_buf(out, " io");
break;
case REBALANCE_RUNNING:
- pr_buf(out, "running\n");
+ pr_buf(out, "running");
break;
}
+ pr_newline(out);
}
void bch2_rebalance_stop(struct bch_fs *c)