diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-12-01 11:32:12 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:13 -0400 |
commit | 06b7345cc282ec383942afb3b5b8d42bd9eec1b8 (patch) | |
tree | 90a53cb37cfdd957bfe3e22aa8c08cf343a669c1 /fs/bcachefs/btree_gc.c | |
parent | 5663a4152138fdf23a300934128d77a1bf784237 (diff) | |
download | lwn-06b7345cc282ec383942afb3b5b8d42bd9eec1b8.tar.gz lwn-06b7345cc282ec383942afb3b5b8d42bd9eec1b8.zip |
bcachefs: Include summarized counts in fs_usage
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_gc.c')
-rw-r--r-- | fs/bcachefs/btree_gc.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 75ea243d4bbc..c353fbbed975 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -482,6 +482,24 @@ static void bch2_gc_free(struct bch_fs *c) c->usage[1] = NULL; } +static void fs_usage_reset(struct bch_fs_usage *fs_usage) +{ + unsigned offset = offsetof(typeof(*fs_usage), s.gc_start); + + memset((void *) fs_usage + offset, 0, + sizeof(*fs_usage) - offset); +} + +static void fs_usage_cpy(struct bch_fs_usage *dst, + struct bch_fs_usage *src) +{ + unsigned offset = offsetof(typeof(*dst), s.gc_start); + + memcpy((void *) dst + offset, + (void *) src + offset, + sizeof(*dst) - offset); +} + static void bch2_gc_done_nocheck(struct bch_fs *c) { struct bch_dev *ca; @@ -530,17 +548,12 @@ static void bch2_gc_done_nocheck(struct bch_fs *c) { struct bch_fs_usage src = __bch2_fs_usage_read(c, 1); - struct bch_fs_usage *p; - for_each_possible_cpu(cpu) { - p = per_cpu_ptr(c->usage[0], cpu); - memset(p, 0, offsetof(typeof(*p), online_reserved)); - } + for_each_possible_cpu(cpu) + fs_usage_reset(per_cpu_ptr(c->usage[0], cpu)); preempt_disable(); - memcpy(this_cpu_ptr(c->usage[0]), - &src, - offsetof(typeof(*p), online_reserved)); + fs_usage_cpy(this_cpu_ptr(c->usage[0]), &src); preempt_enable(); } @@ -668,9 +681,14 @@ static void bch2_gc_done(struct bch_fs *c, bool initial) { struct bch_fs_usage dst = __bch2_fs_usage_read(c, 0); struct bch_fs_usage src = __bch2_fs_usage_read(c, 1); - struct bch_fs_usage *p; unsigned r, b; + copy_fs_field(s.hidden, "hidden"); + copy_fs_field(s.data, "data"); + copy_fs_field(s.cached, "cached"); + copy_fs_field(s.reserved, "reserved"); + copy_fs_field(s.nr_inodes, "nr_inodes"); + for (r = 0; r < BCH_REPLICAS_MAX; r++) { for (b = 0; b < BCH_DATA_NR; b++) copy_fs_field(replicas[r].data[b], @@ -685,16 +703,12 @@ static void bch2_gc_done(struct bch_fs *c, bool initial) for (b = 0; b < BCH_DATA_NR; b++) copy_fs_field(buckets[b], "buckets[%s]", bch2_data_types[b]); - copy_fs_field(nr_inodes, "nr_inodes"); - for_each_possible_cpu(cpu) { - p = per_cpu_ptr(c->usage[0], cpu); - memset(p, 0, offsetof(typeof(*p), online_reserved)); - } + for_each_possible_cpu(cpu) + fs_usage_reset(per_cpu_ptr(c->usage[0], cpu)); preempt_disable(); - p = this_cpu_ptr(c->usage[0]); - memcpy(p, &dst, offsetof(typeof(*p), online_reserved)); + fs_usage_cpy(this_cpu_ptr(c->usage[0]), &dst); preempt_enable(); } out: |