Skip to content

Commit 72c2778

Browse files
author
Kent Overstreet
committed
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>
1 parent f93bb76 commit 72c2778

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

fs/bcachefs/sysfs.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ read_attribute(disk_groups);
204204
read_attribute(has_data);
205205
read_attribute(alloc_debug);
206206
read_attribute(accounting);
207+
read_attribute(usage_base);
207208

208209
#define x(t, n, ...) read_attribute(t);
209210
BCH_PERSISTENT_COUNTERS()
@@ -303,6 +304,20 @@ static void bch2_gc_gens_pos_to_text(struct printbuf *out, struct bch_fs *c)
303304
prt_printf(out, "\n");
304305
}
305306

307+
static void bch2_fs_usage_base_to_text(struct printbuf *out, struct bch_fs *c)
308+
{
309+
struct bch_fs_usage_base b = {};
310+
311+
acc_u64s_percpu(&b.hidden, &c->usage->hidden, sizeof(b) / sizeof(u64));
312+
313+
prt_printf(out, "hidden:\t\t%llu\n", b.hidden);
314+
prt_printf(out, "btree:\t\t%llu\n", b.btree);
315+
prt_printf(out, "data:\t\t%llu\n", b.data);
316+
prt_printf(out, "cached:\t%llu\n", b.cached);
317+
prt_printf(out, "reserved:\t\t%llu\n", b.reserved);
318+
prt_printf(out, "nr_inodes:\t%llu\n", b.nr_inodes);
319+
}
320+
306321
SHOW(bch2_fs)
307322
{
308323
struct bch_fs *c = container_of(kobj, struct bch_fs, kobj);
@@ -392,6 +407,9 @@ SHOW(bch2_fs)
392407
if (attr == &sysfs_accounting)
393408
bch2_fs_accounting_to_text(out, c);
394409

410+
if (attr == &sysfs_usage_base)
411+
bch2_fs_usage_base_to_text(out, c);
412+
395413
return 0;
396414
}
397415

@@ -606,6 +624,7 @@ struct attribute *bch2_fs_internal_files[] = {
606624
&sysfs_disk_groups,
607625
&sysfs_alloc_debug,
608626
&sysfs_accounting,
627+
&sysfs_usage_base,
609628
NULL
610629
};
611630

0 commit comments

Comments
 (0)