From: Kent Overstreet Date: Sun, 17 Jan 2021 20:18:11 +0000 (-0500) Subject: bcachefs: Fix double counting of stripe block counts by GC X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2ef220cba297ef381a980572154fd17aa2a7e3de;p=linux.git bcachefs: Fix double counting of stripe block counts by GC Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 11907abd9b4c8..95368c9f70c33 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)