Merge tag 'nfs-for-3.15-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
[cascardo/linux.git] / drivers / md / bcache / movinggc.c
index 9eb60d1..cd74903 100644 (file)
@@ -24,12 +24,10 @@ static bool moving_pred(struct keybuf *buf, struct bkey *k)
                                           moving_gc_keys);
        unsigned i;
 
-       for (i = 0; i < KEY_PTRS(k); i++) {
-               struct bucket *g = PTR_BUCKET(c, k, i);
-
-               if (GC_MOVE(g))
+       for (i = 0; i < KEY_PTRS(k); i++)
+               if (ptr_available(c, k, i) &&
+                   GC_MOVE(PTR_BUCKET(c, k, i)))
                        return true;
-       }
 
        return false;
 }
@@ -115,7 +113,7 @@ static void write_moving(struct closure *cl)
                closure_call(&op->cl, bch_data_insert, NULL, cl);
        }
 
-       continue_at(cl, write_moving_finish, system_wq);
+       continue_at(cl, write_moving_finish, op->wq);
 }
 
 static void read_moving_submit(struct closure *cl)
@@ -125,7 +123,7 @@ static void read_moving_submit(struct closure *cl)
 
        bch_submit_bbio(bio, io->op.c, &io->w->key, 0);
 
-       continue_at(cl, write_moving, system_wq);
+       continue_at(cl, write_moving, io->op.wq);
 }
 
 static void read_moving(struct cache_set *c)
@@ -160,6 +158,7 @@ static void read_moving(struct cache_set *c)
                io->w           = w;
                io->op.inode    = KEY_INODE(&w->key);
                io->op.c        = c;
+               io->op.wq       = c->moving_gc_wq;
 
                moving_init(io);
                bio = &io->bio.bio;
@@ -216,7 +215,10 @@ void bch_moving_gc(struct cache_set *c)
                ca->heap.used = 0;
 
                for_each_bucket(b, ca) {
-                       if (!GC_SECTORS_USED(b))
+                       if (GC_MARK(b) == GC_MARK_METADATA ||
+                           !GC_SECTORS_USED(b) ||
+                           GC_SECTORS_USED(b) == ca->sb.bucket_size ||
+                           atomic_read(&b->pin))
                                continue;
 
                        if (!heap_full(&ca->heap)) {