diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-01-24 20:25:40 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:15 -0400 |
commit | 3e0745e28363c1675a05775425312c049d5857b3 (patch) | |
tree | afc9b3624a8c4ee3e168d9f9b70600a9b6459653 /fs/bcachefs/buckets.c | |
parent | 42b72e0ba226fa15dda0fb9e9f1646a1ae5d03fd (diff) | |
download | lwn-3e0745e28363c1675a05775425312c049d5857b3.tar.gz lwn-3e0745e28363c1675a05775425312c049d5857b3.zip |
bcachefs: initialize fs usage summary in recovery
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/buckets.c')
-rw-r--r-- | fs/bcachefs/buckets.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index d919c1cacee5..f65132a0ebf4 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -114,6 +114,33 @@ void bch2_bucket_seq_cleanup(struct bch_fs *c) } } +void bch2_fs_usage_initialize(struct bch_fs *c) +{ + struct bch_fs_usage *usage; + unsigned i, nr; + + percpu_down_write(&c->mark_lock); + nr = sizeof(struct bch_fs_usage) / sizeof(u64) + c->replicas.nr; + usage = (void *) bch2_acc_percpu_u64s((void *) c->usage[0], nr); + + for (i = 0; i < c->replicas.nr; i++) { + struct bch_replicas_entry *e = + cpu_replicas_entry(&c->replicas, i); + + switch (e->data_type) { + case BCH_DATA_BTREE: + case BCH_DATA_USER: + usage->s.data += usage->data[i]; + break; + case BCH_DATA_CACHED: + usage->s.cached += usage->data[i]; + break; + } + } + + percpu_up_write(&c->mark_lock); +} + #define bch2_usage_read_raw(_stats) \ ({ \ typeof(*this_cpu_ptr(_stats)) _acc; \ |