@@ -1761,8 +1761,10 @@ static void bch_btree_gc_finish(struct cache_set *c)
ca = c->cache;
ca->invalidate_needs_gc = 0;
- for (k = ca->sb.d; k < ca->sb.d + ca->sb.keys; k++)
- SET_GC_MARK(ca->buckets + *k, GC_MARK_METADATA);
+ /* Range [first_bucket, first_bucket + keys) is for journal buckets */
+ for (i = ca->sb.first_bucket;
+ i < ca->sb.first_bucket + ca->sb.njournal_buckets; i++)
+ SET_GC_MARK(ca->buckets + i, GC_MARK_METADATA);
for (k = ca->prio_buckets;
k < ca->prio_buckets + prio_buckets(ca) * 2; k++)