summaryrefslogtreecommitdiff
path: root/fs/bcachefs/buckets.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-01-17 15:18:11 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:51 -0400
commit2ef220cba297ef381a980572154fd17aa2a7e3de (patch)
tree478ce3f9c7d6ec46e987dc44e4961365a554de46 /fs/bcachefs/buckets.c
parentcd9f3dfe58709c7b0793a706d0dd0292a66237d5 (diff)
downloadlwn-2ef220cba297ef381a980572154fd17aa2a7e3de.tar.gz
lwn-2ef220cba297ef381a980572154fd17aa2a7e3de.zip
bcachefs: Fix double counting of stripe block counts by GC
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.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index 11907abd9b4c..95368c9f70c3 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -1273,9 +1273,15 @@ static int bch2_mark_stripe(struct bch_fs *c,
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];
+ unsigned s = stripe_blockcount_get(new_s, i);
+
+ /*
+ * gc recalculates this field from stripe ptr
+ * references:
+ */
+ if (!gc)
+ m->block_sectors[i] = s;
+ m->blocks_nonempty += !!s;
}
if (gc && old_s)