Commit b1cfe5ed authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Improve dev_alloc_debug_to_text()

Now we also print the number of buckets reserved for each watermark.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c85d7796
...@@ -28,6 +28,7 @@ enum alloc_reserve { ...@@ -28,6 +28,7 @@ enum alloc_reserve {
#define x(name) RESERVE_##name, #define x(name) RESERVE_##name,
BCH_ALLOC_RESERVES() BCH_ALLOC_RESERVES()
#undef x #undef x
RESERVE_NR,
}; };
#define OPEN_BUCKETS_COUNT 1024 #define OPEN_BUCKETS_COUNT 1024
......
...@@ -155,6 +155,8 @@ static inline u64 bch2_dev_buckets_reserved(struct bch_dev *ca, enum alloc_reser ...@@ -155,6 +155,8 @@ static inline u64 bch2_dev_buckets_reserved(struct bch_dev *ca, enum alloc_reser
s64 reserved = 0; s64 reserved = 0;
switch (reserve) { switch (reserve) {
case RESERVE_NR:
unreachable();
case RESERVE_none: case RESERVE_none:
reserved += ca->mi.nbuckets >> 6; reserved += ca->mi.nbuckets >> 6;
fallthrough; fallthrough;
......
...@@ -71,7 +71,7 @@ enum printbuf_si { ...@@ -71,7 +71,7 @@ enum printbuf_si {
PRINTBUF_UNITS_10, /* use powers of 10^3 (standard SI) */ PRINTBUF_UNITS_10, /* use powers of 10^3 (standard SI) */
}; };
#define PRINTBUF_INLINE_TABSTOPS 4 #define PRINTBUF_INLINE_TABSTOPS 6
struct printbuf { struct printbuf {
char *buf; char *buf;
......
...@@ -821,38 +821,100 @@ static void dev_alloc_debug_to_text(struct printbuf *out, struct bch_dev *ca) ...@@ -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++) for (i = 0; i < ARRAY_SIZE(c->open_buckets); i++)
nr[c->open_buckets[i].data_type]++; nr[c->open_buckets[i].data_type]++;
prt_printf(out, printbuf_tabstop_push(out, 8);
"\t\t\t buckets\t sectors fragmented\n" printbuf_tabstop_push(out, 16);
"capacity\t%16llu\n", printbuf_tabstop_push(out, 16);
ca->mi.nbuckets - ca->mi.first_bucket); 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", prt_tab(out);
bch2_data_types[i], stats.d[i].buckets, prt_str(out, "buckets");
stats.d[i].sectors, stats.d[i].fragmented); prt_tab_rjust(out);
prt_str(out, "sectors");
prt_printf(out, prt_tab_rjust(out);
"ec\t\t%16llu\n" prt_str(out, "fragmented");
"\n" prt_tab_rjust(out);
"freelist_wait\t\t%s\n" prt_newline(out);
"open buckets allocated\t%u\n"
"open buckets this dev\t%u\n" for (i = 0; i < BCH_DATA_NR; i++) {
"open buckets total\t%u\n" prt_str(out, bch2_data_types[i]);
"open_buckets_wait\t%s\n" prt_tab(out);
"open_buckets_btree\t%u\n" prt_u64(out, stats.d[i].buckets);
"open_buckets_user\t%u\n" prt_tab_rjust(out);
"buckets_to_invalidate\t%llu\n" prt_u64(out, stats.d[i].sectors);
"btree reserve cache\t%u\n", prt_tab_rjust(out);
stats.buckets_ec, prt_u64(out, stats.d[i].fragmented);
c->freelist_wait.list.first ? "waiting" : "empty", prt_tab_rjust(out);
OPEN_BUCKETS_COUNT - c->open_buckets_nr_free, prt_newline(out);
ca->nr_open_buckets, }
OPEN_BUCKETS_COUNT,
c->open_buckets_wait.list.first ? "waiting" : "empty", prt_str(out, "ec");
nr[BCH_DATA_btree], prt_tab(out);
nr[BCH_DATA_user], prt_u64(out, stats.buckets_ec);
should_invalidate_buckets(ca, stats), prt_tab_rjust(out);
c->btree_reserve_cache_nr); 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[] = { static const char * const bch2_rw[] = {
......
...@@ -236,7 +236,7 @@ do { \ ...@@ -236,7 +236,7 @@ do { \
#define prt_tab_rjust(_out) bch2_prt_tab_rjust(_out) #define prt_tab_rjust(_out) bch2_prt_tab_rjust(_out)
#define prt_bytes_indented(...) bch2_prt_bytes_indented(__VA_ARGS__) #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_u64(...) bch2_prt_human_readable_u64(__VA_ARGS__)
#define prt_human_readable_s64(...) bch2_prt_human_readable_s64(__VA_ARGS__) #define prt_human_readable_s64(...) bch2_prt_human_readable_s64(__VA_ARGS__)
#define prt_units_u64(...) bch2_prt_units_u64(__VA_ARGS__) #define prt_units_u64(...) bch2_prt_units_u64(__VA_ARGS__)
......
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