]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
bcache: Fix GC_SECTORS_USED() calculation
authorKent Overstreet <kmo@daterainc.com>
Fri, 12 Jul 2013 02:43:21 +0000 (19:43 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 28 Jul 2013 23:30:10 +0000 (16:30 -0700)
commit 29ebf465b9050f241c4433a796a32e6c896a9dcd 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: Kent Overstreet <kmo@daterainc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/bcache/btree.c

index 7a5658f04e62092610b2144faab12ae5fa3976a0..7b687a6f3dec1d310e1c8fe3297d78244f2b691d 100644 (file)
@@ -1419,8 +1419,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);
+                       }
                }
 
        for (d = c->devices;