summaryrefslogtreecommitdiff
path: root/fs/bcachefs/buckets.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-10-23 18:40:30 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:45 -0400
commit5b088c1dd005ec0fbddfa3664d3095caef6ae52e (patch)
tree0a4e17de1a661af92e25fc4fc6848d8f1ba98217 /fs/bcachefs/buckets.c
parentb88e971e45fe61fba435c65cc2f66fb3a5136461 (diff)
downloadlwn-5b088c1dd005ec0fbddfa3664d3095caef6ae52e.tar.gz
lwn-5b088c1dd005ec0fbddfa3664d3095caef6ae52e.zip
bcachefs: Fix bch2_mark_stripe()
There's no reason not to always recalculate these fields 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.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index 7558e2bffbdd..aacc20f71729 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -1264,6 +1264,13 @@ static int bch2_mark_stripe(struct bch_fs *c,
m->algorithm = new_s->algorithm;
m->nr_blocks = new_s->nr_blocks;
m->nr_redundant = new_s->nr_redundant;
+ m->blocks_nonempty = 0;
+
+ for (i = 0; i < new_s->nr_blocks; i++) {
+ m->block_sectors[i] =
+ stripe_blockcount_get(new_s, i);
+ m->blocks_nonempty += !!m->block_sectors[i];
+ }
if (gc && old_s)
update_replicas(c, fs_usage, &m->r.e,
@@ -1275,17 +1282,6 @@ static int bch2_mark_stripe(struct bch_fs *c,
update_replicas(c, fs_usage, &m->r.e,
((s64) m->sectors * m->nr_redundant));
- /* gc recalculates these fields: */
- if (!(flags & BTREE_TRIGGER_GC)) {
- m->blocks_nonempty = 0;
-
- for (i = 0; i < new_s->nr_blocks; i++) {
- m->block_sectors[i] =
- stripe_blockcount_get(new_s, i);
- m->blocks_nonempty += !!m->block_sectors[i];
- }
- }
-
if (!gc) {
spin_lock(&c->ec_stripes_heap_lock);
bch2_stripes_heap_update(c, m, idx);