bcachefs: Fix bch2_mark_stripe()
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 23 Oct 2020 22:40:30 +0000 (18:40 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:45 +0000 (17:08 -0400)
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>
fs/bcachefs/buckets.c

index 7558e2bffbdd33a78fe4f1af6d3a99da2689fc29..aacc20f71729cf18da6c19e05fa28e6ddde13efc 100644 (file)
@@ -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);