Commit ed0cd515 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: bch2_dev_usage_to_text()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent dafff7e5
......@@ -277,6 +277,36 @@ void bch2_dev_usage_init(struct bch_dev *ca)
ca->usage_base->d[BCH_DATA_free].buckets = ca->mi.nbuckets - ca->mi.first_bucket;
}
void bch2_dev_usage_to_text(struct printbuf *out, struct bch_dev_usage *usage)
{
prt_tab(out);
prt_str(out, "buckets");
prt_tab_rjust(out);
prt_str(out, "sectors");
prt_tab_rjust(out);
prt_str(out, "fragmented");
prt_tab_rjust(out);
prt_newline(out);
for (unsigned i = 0; i < BCH_DATA_NR; i++) {
prt_str(out, bch2_data_types[i]);
prt_tab(out);
prt_u64(out, usage->d[i].buckets);
prt_tab_rjust(out);
prt_u64(out, usage->d[i].sectors);
prt_tab_rjust(out);
prt_u64(out, usage->d[i].fragmented);
prt_tab_rjust(out);
prt_newline(out);
}
prt_str(out, "ec");
prt_tab(out);
prt_u64(out, usage->buckets_ec);
prt_tab_rjust(out);
prt_newline(out);
}
static void bch2_dev_usage_update(struct bch_fs *c, struct bch_dev *ca,
struct bch_alloc_v4 old,
struct bch_alloc_v4 new,
......
......@@ -203,6 +203,7 @@ static inline struct bch_dev_usage bch2_dev_usage_read(struct bch_dev *ca)
}
void bch2_dev_usage_init(struct bch_dev *);
void bch2_dev_usage_to_text(struct printbuf *, struct bch_dev_usage *);
static inline u64 bch2_dev_buckets_reserved(struct bch_dev *ca, enum bch_watermark watermark)
{
......
......@@ -786,32 +786,7 @@ static void dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca)
printbuf_tabstop_push(out, 16);
printbuf_tabstop_push(out, 16);
prt_tab(out);
prt_str(out, "buckets");
prt_tab_rjust(out);
prt_str(out, "sectors");
prt_tab_rjust(out);
prt_str(out, "fragmented");
prt_tab_rjust(out);
prt_newline(out);
for (i = 0; i < BCH_DATA_NR; i++) {
prt_str(out, bch2_data_types[i]);
prt_tab(out);
prt_u64(out, stats.d[i].buckets);
prt_tab_rjust(out);
prt_u64(out, stats.d[i].sectors);
prt_tab_rjust(out);
prt_u64(out, stats.d[i].fragmented);
prt_tab_rjust(out);
prt_newline(out);
}
prt_str(out, "ec");
prt_tab(out);
prt_u64(out, stats.buckets_ec);
prt_tab_rjust(out);
prt_newline(out);
bch2_dev_usage_to_text(out, &stats);
prt_newline(out);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment