mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 14:44:10 +08:00
bcachefs: Improve dev_alloc_debug_to_text()
Now we also print the number of buckets reserved for each watermark. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
c85d779609
commit
b1cfe5ed2b
@ -28,6 +28,7 @@ enum alloc_reserve {
|
||||
#define x(name) RESERVE_##name,
|
||||
BCH_ALLOC_RESERVES()
|
||||
#undef x
|
||||
RESERVE_NR,
|
||||
};
|
||||
|
||||
#define OPEN_BUCKETS_COUNT 1024
|
||||
|
@ -155,6 +155,8 @@ static inline u64 bch2_dev_buckets_reserved(struct bch_dev *ca, enum alloc_reser
|
||||
s64 reserved = 0;
|
||||
|
||||
switch (reserve) {
|
||||
case RESERVE_NR:
|
||||
unreachable();
|
||||
case RESERVE_none:
|
||||
reserved += ca->mi.nbuckets >> 6;
|
||||
fallthrough;
|
||||
|
@ -71,7 +71,7 @@ enum printbuf_si {
|
||||
PRINTBUF_UNITS_10, /* use powers of 10^3 (standard SI) */
|
||||
};
|
||||
|
||||
#define PRINTBUF_INLINE_TABSTOPS 4
|
||||
#define PRINTBUF_INLINE_TABSTOPS 6
|
||||
|
||||
struct printbuf {
|
||||
char *buf;
|
||||
|
@ -821,38 +821,100 @@ static void dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca)
|
||||
for (i = 0; i < ARRAY_SIZE(c->open_buckets); i++)
|
||||
nr[c->open_buckets[i].data_type]++;
|
||||
|
||||
prt_printf(out,
|
||||
"\t\t\t buckets\t sectors fragmented\n"
|
||||
"capacity\t%16llu\n",
|
||||
ca->mi.nbuckets - ca->mi.first_bucket);
|
||||
printbuf_tabstop_push(out, 8);
|
||||
printbuf_tabstop_push(out, 16);
|
||||
printbuf_tabstop_push(out, 16);
|
||||
printbuf_tabstop_push(out, 16);
|
||||
printbuf_tabstop_push(out, 16);
|
||||
|
||||
for (i = 0; i < BCH_DATA_NR; i++)
|
||||
prt_printf(out, "%-16s%16llu%16llu%16llu\n",
|
||||
bch2_data_types[i], stats.d[i].buckets,
|
||||
stats.d[i].sectors, stats.d[i].fragmented);
|
||||
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);
|
||||
|
||||
prt_printf(out,
|
||||
"ec\t\t%16llu\n"
|
||||
"\n"
|
||||
"freelist_wait\t\t%s\n"
|
||||
"open buckets allocated\t%u\n"
|
||||
"open buckets this dev\t%u\n"
|
||||
"open buckets total\t%u\n"
|
||||
"open_buckets_wait\t%s\n"
|
||||
"open_buckets_btree\t%u\n"
|
||||
"open_buckets_user\t%u\n"
|
||||
"buckets_to_invalidate\t%llu\n"
|
||||
"btree reserve cache\t%u\n",
|
||||
stats.buckets_ec,
|
||||
c->freelist_wait.list.first ? "waiting" : "empty",
|
||||
OPEN_BUCKETS_COUNT - c->open_buckets_nr_free,
|
||||
ca->nr_open_buckets,
|
||||
OPEN_BUCKETS_COUNT,
|
||||
c->open_buckets_wait.list.first ? "waiting" : "empty",
|
||||
nr[BCH_DATA_btree],
|
||||
nr[BCH_DATA_user],
|
||||
should_invalidate_buckets(ca, stats),
|
||||
c->btree_reserve_cache_nr);
|
||||
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);
|
||||
|
||||
prt_newline(out);
|
||||
|
||||
prt_printf(out, "reserves:");
|
||||
prt_newline(out);
|
||||
for (i = 0; i < RESERVE_NR; i++) {
|
||||
prt_str(out, bch2_alloc_reserves[i]);
|
||||
prt_tab(out);
|
||||
prt_u64(out, bch2_dev_buckets_reserved(ca, i));
|
||||
prt_tab_rjust(out);
|
||||
prt_newline(out);
|
||||
}
|
||||
|
||||
prt_newline(out);
|
||||
|
||||
printbuf_tabstops_reset(out);
|
||||
printbuf_tabstop_push(out, 24);
|
||||
|
||||
prt_str(out, "freelist_wait");
|
||||
prt_tab(out);
|
||||
prt_str(out, c->freelist_wait.list.first ? "waiting" : "empty");
|
||||
prt_newline(out);
|
||||
|
||||
prt_str(out, "open buckets allocated");
|
||||
prt_tab(out);
|
||||
prt_u64(out, OPEN_BUCKETS_COUNT - c->open_buckets_nr_free);
|
||||
prt_newline(out);
|
||||
|
||||
prt_str(out, "open buckets this dev");
|
||||
prt_tab(out);
|
||||
prt_u64(out, ca->nr_open_buckets);
|
||||
prt_newline(out);
|
||||
|
||||
prt_str(out, "open buckets total");
|
||||
prt_tab(out);
|
||||
prt_u64(out, OPEN_BUCKETS_COUNT);
|
||||
prt_newline(out);
|
||||
|
||||
prt_str(out, "open_buckets_wait");
|
||||
prt_tab(out);
|
||||
prt_str(out, c->open_buckets_wait.list.first ? "waiting" : "empty");
|
||||
prt_newline(out);
|
||||
|
||||
prt_str(out, "open_buckets_btree");
|
||||
prt_tab(out);
|
||||
prt_u64(out, nr[BCH_DATA_btree]);
|
||||
prt_newline(out);
|
||||
|
||||
prt_str(out, "open_buckets_user");
|
||||
prt_tab(out);
|
||||
prt_u64(out, nr[BCH_DATA_user]);
|
||||
prt_newline(out);
|
||||
|
||||
prt_str(out, "buckets_to_invalidate");
|
||||
prt_tab(out);
|
||||
prt_u64(out, should_invalidate_buckets(ca, stats));
|
||||
prt_newline(out);
|
||||
|
||||
prt_str(out, "btree reserve cache");
|
||||
prt_tab(out);
|
||||
prt_u64(out, c->btree_reserve_cache_nr);
|
||||
prt_newline(out);
|
||||
}
|
||||
|
||||
static const char * const bch2_rw[] = {
|
||||
|
@ -236,7 +236,7 @@ do { \
|
||||
#define prt_tab_rjust(_out) bch2_prt_tab_rjust(_out)
|
||||
|
||||
#define prt_bytes_indented(...) bch2_prt_bytes_indented(__VA_ARGS__)
|
||||
#define prt_u64(_out, _v) prt_printf(_out, "%llu", _v)
|
||||
#define prt_u64(_out, _v) prt_printf(_out, "%llu", (u64) (_v))
|
||||
#define prt_human_readable_u64(...) bch2_prt_human_readable_u64(__VA_ARGS__)
|
||||
#define prt_human_readable_s64(...) bch2_prt_human_readable_s64(__VA_ARGS__)
|
||||
#define prt_units_u64(...) bch2_prt_units_u64(__VA_ARGS__)
|
||||
|
Loading…
Reference in New Issue
Block a user