summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-02-23 17:23:41 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-04-05 23:43:22 -0400
commita20c22c5410ad3cb67c3b6084278f15ff1428b69 (patch)
treefcf3638e314346586f47c0fa5253f9ea0d3e65de
parent41d323f3038e237a2e0b1130f706005f05850074 (diff)
bcachefs: bch2_fs_usage_base_to_text()
Helper to show raw accounting in sysfs, mainly for debugging. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/sysfs.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c
index cb761b29d1cb..05ec89a8afaf 100644
--- a/fs/bcachefs/sysfs.c
+++ b/fs/bcachefs/sysfs.c
@@ -203,6 +203,7 @@ read_attribute(disk_groups);
read_attribute(has_data);
read_attribute(alloc_debug);
read_attribute(accounting);
+read_attribute(usage_base);
#define x(t, n, ...) read_attribute(t);
BCH_PERSISTENT_COUNTERS()
@@ -327,6 +328,20 @@ static void bch2_btree_wakeup_all(struct bch_fs *c)
seqmutex_unlock(&c->btree_trans_lock);
}
+static void bch2_fs_usage_base_to_text(struct printbuf *out, struct bch_fs *c)
+{
+ struct bch_fs_usage_base b = {};
+
+ acc_u64s_percpu(&b.hidden, &c->usage->hidden, sizeof(b) / sizeof(u64));
+
+ prt_printf(out, "hidden:\t\t%llu\n", b.hidden);
+ prt_printf(out, "btree:\t\t%llu\n", b.btree);
+ prt_printf(out, "data:\t\t%llu\n", b.data);
+ prt_printf(out, "cached:\t%llu\n", b.cached);
+ prt_printf(out, "reserved:\t\t%llu\n", b.reserved);
+ prt_printf(out, "nr_inodes:\t%llu\n", b.nr_inodes);
+}
+
SHOW(bch2_fs)
{
struct bch_fs *c = container_of(kobj, struct bch_fs, kobj);
@@ -412,6 +427,9 @@ SHOW(bch2_fs)
if (attr == &sysfs_accounting)
bch2_fs_accounting_to_text(out, c);
+ if (attr == &sysfs_usage_base)
+ bch2_fs_usage_base_to_text(out, c);
+
return 0;
}
@@ -624,6 +642,7 @@ struct attribute *bch2_fs_internal_files[] = {
&sysfs_disk_groups,
&sysfs_accounting,
+ &sysfs_usage_base,
NULL
};