Loading fs/bcachefs/disk_accounting.c +26 −0 Original line number Diff line number Diff line Loading @@ -308,6 +308,32 @@ int bch2_fs_replicas_usage_read(struct bch_fs *c, darray_char *usage) return ret; } void bch2_fs_accounting_to_text(struct printbuf *out, struct bch_fs *c) { struct bch_accounting_mem *acc = &c->accounting[0]; percpu_down_read(&c->mark_lock); out->atomic++; eytzinger0_for_each(i, acc->k.nr) { struct disk_accounting_pos acc_k; bpos_to_disk_accounting_pos(&acc_k, acc->k.data[i].pos); bch2_accounting_key_to_text(out, &acc_k); u64 v[BCH_ACCOUNTING_MAX_COUNTERS]; bch2_accounting_mem_read_counters(c, i, v, ARRAY_SIZE(v), false); prt_str(out, ":"); for (unsigned j = 0; j < acc->k.data[i].nr_counters; j++) prt_printf(out, " %llu", v[j]); prt_newline(out); } --out->atomic; percpu_up_read(&c->mark_lock); } /* Ensures all counters in @src exist in @dst: */ static int copy_counters(struct bch_accounting_mem *dst, struct bch_accounting_mem *src) Loading fs/bcachefs/disk_accounting.h +1 −0 Original line number Diff line number Diff line Loading @@ -193,6 +193,7 @@ static inline void bch2_accounting_mem_read(struct bch_fs *c, struct bpos p, } int bch2_fs_replicas_usage_read(struct bch_fs *, darray_char *); void bch2_fs_accounting_to_text(struct printbuf *, struct bch_fs *); int bch2_accounting_gc_done(struct bch_fs *); Loading fs/bcachefs/sysfs.c +5 −0 Original line number Diff line number Diff line Loading @@ -203,6 +203,7 @@ read_attribute(disk_groups); read_attribute(has_data); read_attribute(alloc_debug); read_attribute(accounting); #define x(t, n, ...) read_attribute(t); BCH_PERSISTENT_COUNTERS() Loading Loading @@ -388,6 +389,9 @@ SHOW(bch2_fs) if (attr == &sysfs_alloc_debug) bch2_fs_alloc_debug_to_text(out, c); if (attr == &sysfs_accounting) bch2_fs_accounting_to_text(out, c); return 0; } Loading Loading @@ -601,6 +605,7 @@ struct attribute *bch2_fs_internal_files[] = { &sysfs_disk_groups, &sysfs_alloc_debug, &sysfs_accounting, NULL }; Loading Loading
fs/bcachefs/disk_accounting.c +26 −0 Original line number Diff line number Diff line Loading @@ -308,6 +308,32 @@ int bch2_fs_replicas_usage_read(struct bch_fs *c, darray_char *usage) return ret; } void bch2_fs_accounting_to_text(struct printbuf *out, struct bch_fs *c) { struct bch_accounting_mem *acc = &c->accounting[0]; percpu_down_read(&c->mark_lock); out->atomic++; eytzinger0_for_each(i, acc->k.nr) { struct disk_accounting_pos acc_k; bpos_to_disk_accounting_pos(&acc_k, acc->k.data[i].pos); bch2_accounting_key_to_text(out, &acc_k); u64 v[BCH_ACCOUNTING_MAX_COUNTERS]; bch2_accounting_mem_read_counters(c, i, v, ARRAY_SIZE(v), false); prt_str(out, ":"); for (unsigned j = 0; j < acc->k.data[i].nr_counters; j++) prt_printf(out, " %llu", v[j]); prt_newline(out); } --out->atomic; percpu_up_read(&c->mark_lock); } /* Ensures all counters in @src exist in @dst: */ static int copy_counters(struct bch_accounting_mem *dst, struct bch_accounting_mem *src) Loading
fs/bcachefs/disk_accounting.h +1 −0 Original line number Diff line number Diff line Loading @@ -193,6 +193,7 @@ static inline void bch2_accounting_mem_read(struct bch_fs *c, struct bpos p, } int bch2_fs_replicas_usage_read(struct bch_fs *, darray_char *); void bch2_fs_accounting_to_text(struct printbuf *, struct bch_fs *); int bch2_accounting_gc_done(struct bch_fs *); Loading
fs/bcachefs/sysfs.c +5 −0 Original line number Diff line number Diff line Loading @@ -203,6 +203,7 @@ read_attribute(disk_groups); read_attribute(has_data); read_attribute(alloc_debug); read_attribute(accounting); #define x(t, n, ...) read_attribute(t); BCH_PERSISTENT_COUNTERS() Loading Loading @@ -388,6 +389,9 @@ SHOW(bch2_fs) if (attr == &sysfs_alloc_debug) bch2_fs_alloc_debug_to_text(out, c); if (attr == &sysfs_accounting) bch2_fs_accounting_to_text(out, c); return 0; } Loading Loading @@ -601,6 +605,7 @@ struct attribute *bch2_fs_internal_files[] = { &sysfs_disk_groups, &sysfs_alloc_debug, &sysfs_accounting, NULL }; Loading