summaryrefslogtreecommitdiff
path: root/fs/bcachefs/buckets.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-06-18 21:06:42 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:42 -0400
commit649a9b68ac126fc7c8735892d3f833b620c9cbde (patch)
treebd1feb587b8e0a21480537ee9d952157f9043deb /fs/bcachefs/buckets.c
parent937f503605695d2b564394afdfa59b866accd915 (diff)
downloadlwn-649a9b68ac126fc7c8735892d3f833b620c9cbde.tar.gz
lwn-649a9b68ac126fc7c8735892d3f833b620c9cbde.zip
bcachefs: Track sectors of erasure coded data
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/buckets.c')
-rw-r--r--fs/bcachefs/buckets.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index 1ae9403847ca..1198c7bbeab9 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -374,6 +374,11 @@ static inline int is_fragmented_bucket(struct bucket_mark m,
return 0;
}
+static inline int bucket_stripe_sectors(struct bucket_mark m)
+{
+ return m.stripe ? m.dirty_sectors : 0;
+}
+
static inline enum bch_data_type bucket_type(struct bucket_mark m)
{
return m.cached_sectors && !m.dirty_sectors
@@ -443,30 +448,33 @@ static void bch2_dev_usage_update(struct bch_fs *c, struct bch_dev *ca,
struct bucket_mark old, struct bucket_mark new,
bool gc)
{
- struct bch_dev_usage *dev_usage;
+ struct bch_dev_usage *u;
percpu_rwsem_assert_held(&c->mark_lock);
preempt_disable();
- dev_usage = this_cpu_ptr(ca->usage[gc]);
+ u = this_cpu_ptr(ca->usage[gc]);
if (bucket_type(old))
- account_bucket(fs_usage, dev_usage, bucket_type(old),
+ account_bucket(fs_usage, u, bucket_type(old),
-1, -ca->mi.bucket_size);
if (bucket_type(new))
- account_bucket(fs_usage, dev_usage, bucket_type(new),
+ account_bucket(fs_usage, u, bucket_type(new),
1, ca->mi.bucket_size);
- dev_usage->buckets_ec += (int) new.stripe - (int) old.stripe;
- dev_usage->buckets_unavailable +=
+ u->buckets_unavailable +=
is_unavailable_bucket(new) - is_unavailable_bucket(old);
- dev_usage->sectors[old.data_type] -= old.dirty_sectors;
- dev_usage->sectors[new.data_type] += new.dirty_sectors;
- dev_usage->sectors[BCH_DATA_CACHED] +=
+ u->buckets_ec += (int) new.stripe - (int) old.stripe;
+ u->sectors_ec += bucket_stripe_sectors(new) -
+ bucket_stripe_sectors(old);
+
+ u->sectors[old.data_type] -= old.dirty_sectors;
+ u->sectors[new.data_type] += new.dirty_sectors;
+ u->sectors[BCH_DATA_CACHED] +=
(int) new.cached_sectors - (int) old.cached_sectors;
- dev_usage->sectors_fragmented +=
+ u->sectors_fragmented +=
is_fragmented_bucket(new, ca) - is_fragmented_bucket(old, ca);
preempt_enable();