bcache: Fix GC_SECTORS_USED() calculation
authorKent Overstreet <kmo@daterainc.com>
Fri, 12 Jul 2013 02:43:21 +0000 (19:43 -0700)
committerKent Overstreet <kmo@daterainc.com>
Fri, 12 Jul 2013 07:22:48 +0000 (00:22 -0700)
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: Kent Overstreet <kmo@daterainc.com>
Cc: linux-stable <stable@vger.kernel.org> # >= v3.10
drivers/md/bcache/btree.c

index 15b58239c683128dad93d4aa2caec57dfe6b3cf6..ee372884c405444886671901e45c3834626f383a 100644 (file)
@@ -1410,8 +1410,10 @@ static void btree_gc_start(struct cache_set *c)
        for_each_cache(ca, c, i)
                for_each_bucket(b, ca) {
                        b->gc_gen = b->gen;
-                       if (!atomic_read(&b->pin))
+                       if (!atomic_read(&b->pin)) {
                                SET_GC_MARK(b, GC_MARK_RECLAIMABLE);
+                               SET_GC_SECTORS_USED(b, 0);
+                       }
                }
 
        mutex_unlock(&c->bucket_lock);
This page took 0.02783 seconds and 5 git commands to generate.