summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/rebalance.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-11-09 01:24:07 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:11 -0400
commit319f9ac38eaba628d69b6ddbf402b35487315fc1 (patch)
tree01daddd4881b1f09bb4d50087e8b8803e59fea35 /fs/bcachefs/rebalance.c
parent75369d4ec3d2dfc52af18a2d20cd0af14c935ac9 (diff)
downloadlinux-319f9ac38eaba628d69b6ddbf402b35487315fc1.tar.gz
linux-319f9ac38eaba628d69b6ddbf402b35487315fc1.tar.bz2
linux-319f9ac38eaba628d69b6ddbf402b35487315fc1.zip
bcachefs: revamp to_text methods
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/rebalance.c')
-rw-r--r--fs/bcachefs/rebalance.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c
index 570dbae5a240..5d246c5b8186 100644
--- a/fs/bcachefs/rebalance.c
+++ b/fs/bcachefs/rebalance.c
@@ -252,49 +252,43 @@ static int bch2_rebalance_thread(void *arg)
ssize_t bch2_rebalance_work_show(struct bch_fs *c, char *buf)
{
- char *out = buf, *end = out + PAGE_SIZE;
+ struct printbuf out = _PBUF(buf, PAGE_SIZE);
struct bch_fs_rebalance *r = &c->rebalance;
struct rebalance_work w = rebalance_work(c);
char h1[21], h2[21];
bch2_hprint(h1, w.dev_most_full_work << 9);
bch2_hprint(h2, w.dev_most_full_capacity << 9);
- out += scnprintf(out, end - out,
- "fullest_dev (%i):\t%s/%s\n",
- w.dev_most_full_idx, h1, h2);
+ pr_buf(&out, "fullest_dev (%i):\t%s/%s\n",
+ w.dev_most_full_idx, h1, h2);
bch2_hprint(h1, w.total_work << 9);
bch2_hprint(h2, c->capacity << 9);
- out += scnprintf(out, end - out,
- "total work:\t\t%s/%s\n",
- h1, h2);
+ pr_buf(&out, "total work:\t\t%s/%s\n", h1, h2);
- out += scnprintf(out, end - out,
- "rate:\t\t\t%u\n",
- r->pd.rate.rate);
+ pr_buf(&out, "rate:\t\t\t%u\n", r->pd.rate.rate);
switch (r->state) {
case REBALANCE_WAITING:
- out += scnprintf(out, end - out, "waiting\n");
+ pr_buf(&out, "waiting\n");
break;
case REBALANCE_THROTTLED:
bch2_hprint(h1,
(r->throttled_until_iotime -
atomic_long_read(&c->io_clock[WRITE].now)) << 9);
- out += scnprintf(out, end - out,
- "throttled for %lu sec or %s io\n",
- (r->throttled_until_cputime - jiffies) / HZ,
- h1);
+ pr_buf(&out, "throttled for %lu sec or %s io\n",
+ (r->throttled_until_cputime - jiffies) / HZ,
+ h1);
break;
case REBALANCE_RUNNING:
- out += scnprintf(out, end - out, "running\n");
- out += scnprintf(out, end - out, "pos %llu:%llu\n",
- r->move_stats.iter.pos.inode,
- r->move_stats.iter.pos.offset);
+ pr_buf(&out, "running\n");
+ pr_buf(&out, "pos %llu:%llu\n",
+ r->move_stats.iter.pos.inode,
+ r->move_stats.iter.pos.offset);
break;
}
- return out - buf;
+ return out.pos - buf;
}
void bch2_rebalance_stop(struct bch_fs *c)