mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-04 15:09:50 -04:00
bcachefs: fs_alloc_debug_to_text()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@@ -362,6 +362,37 @@ static void bch2_btree_wakeup_all(struct bch_fs *c)
|
||||
seqmutex_unlock(&c->btree_trans_lock);
|
||||
}
|
||||
|
||||
static void fs_alloc_debug_to_text(struct printbuf *out, struct bch_fs *c)
|
||||
{
|
||||
unsigned nr[BCH_DATA_NR];
|
||||
|
||||
memset(nr, 0, sizeof(nr));
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(c->open_buckets); i++)
|
||||
nr[c->open_buckets[i].data_type]++;
|
||||
|
||||
printbuf_tabstop_push(out, 24);
|
||||
|
||||
percpu_down_read(&c->mark_lock);
|
||||
prt_printf(out, "hidden\t%llu\n", bch2_fs_usage_read_one(c, &c->usage_base->b.hidden));
|
||||
prt_printf(out, "btree\t%llu\n", bch2_fs_usage_read_one(c, &c->usage_base->b.btree));
|
||||
prt_printf(out, "data\t%llu\n", bch2_fs_usage_read_one(c, &c->usage_base->b.data));
|
||||
prt_printf(out, "cached\t%llu\n", bch2_fs_usage_read_one(c, &c->usage_base->b.cached));
|
||||
prt_printf(out, "reserved\t%llu\n", bch2_fs_usage_read_one(c, &c->usage_base->b.reserved));
|
||||
prt_printf(out, "online_reserved\t%llu\n", percpu_u64_get(c->online_reserved));
|
||||
prt_printf(out, "nr_inodes\t%llu\n", bch2_fs_usage_read_one(c, &c->usage_base->b.nr_inodes));
|
||||
percpu_up_read(&c->mark_lock);
|
||||
|
||||
prt_newline(out);
|
||||
prt_printf(out, "freelist_wait\t%s\n", c->freelist_wait.list.first ? "waiting" : "empty");
|
||||
prt_printf(out, "open buckets allocated\t%i\n", OPEN_BUCKETS_COUNT - c->open_buckets_nr_free);
|
||||
prt_printf(out, "open buckets total\t%u\n", OPEN_BUCKETS_COUNT);
|
||||
prt_printf(out, "open_buckets_wait\t%s\n", c->open_buckets_wait.list.first ? "waiting" : "empty");
|
||||
prt_printf(out, "open_buckets_btree\t%u\n", nr[BCH_DATA_btree]);
|
||||
prt_printf(out, "open_buckets_user\t%u\n", nr[BCH_DATA_user]);
|
||||
prt_printf(out, "btree reserve cache\t%u\n", c->btree_reserve_cache_nr);
|
||||
}
|
||||
|
||||
SHOW(bch2_fs)
|
||||
{
|
||||
struct bch_fs *c = container_of(kobj, struct bch_fs, kobj);
|
||||
@@ -444,6 +475,9 @@ SHOW(bch2_fs)
|
||||
if (attr == &sysfs_disk_groups)
|
||||
bch2_disk_groups_to_text(out, c);
|
||||
|
||||
if (attr == &sysfs_alloc_debug)
|
||||
fs_alloc_debug_to_text(out, c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -650,6 +684,7 @@ struct attribute *bch2_fs_internal_files[] = {
|
||||
&sysfs_internal_uuid,
|
||||
|
||||
&sysfs_disk_groups,
|
||||
&sysfs_alloc_debug,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user