Commit 99e56bf5 authored by Kent Overstreet's avatar Kent Overstreet Committed by Greg Kroah-Hartman

bcache: Fix GC_SECTORS_USED() calculation

commit 29ebf465 upstream.

Part of the job of garbage collection is to add up however many sectors
of live data it finds in each bucket, but that doesn't work very well if
it doesn't reset GC_SECTORS_USED() when it starts. Whoops.

This wouldn't have broken anything horribly, but allocation tries to
preferentially reclaim buckets that are mostly empty and that's not
gonna work with an incorrect GC_SECTORS_USED() value.
Signed-off-by: default avatarKent Overstreet <kmo@daterainc.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fe1b7105
...@@ -1419,8 +1419,10 @@ static void btree_gc_start(struct cache_set *c) ...@@ -1419,8 +1419,10 @@ static void btree_gc_start(struct cache_set *c)
for_each_cache(ca, c, i) for_each_cache(ca, c, i)
for_each_bucket(b, ca) { for_each_bucket(b, ca) {
b->gc_gen = b->gen; b->gc_gen = b->gen;
if (!atomic_read(&b->pin)) if (!atomic_read(&b->pin)) {
SET_GC_MARK(b, GC_MARK_RECLAIMABLE); SET_GC_MARK(b, GC_MARK_RECLAIMABLE);
SET_GC_SECTORS_USED(b, 0);
}
} }
for (d = c->devices; for (d = c->devices;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment