aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/super.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-10-24 20:19:26 -0400
committerKent Overstreet <kmo@daterainc.com>2013-11-11 00:56:04 -0500
commit72a44517f3ca3725dc86081d105457df46448679 (patch)
tree247b859af6c4377ab1ea90fd1fd4e64278ccdbbd /drivers/md/bcache/super.c
parent35fcd848d72683141052aa9880542461577f2dbe (diff)
bcache: Convert gc to a kthread
We needed a dedicated rescuer workqueue for gc anyways... and gc was conceptually a dedicated thread, just one that wasn't running all the time. Switch it to a dedicated thread to make the code a bit more straightforward. Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/super.c')
-rw-r--r--drivers/md/bcache/super.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 84398a82fbe3..f89e2296bde1 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1342,6 +1342,9 @@ static void cache_set_flush(struct closure *cl)
1342 kobject_put(&c->internal); 1342 kobject_put(&c->internal);
1343 kobject_del(&c->kobj); 1343 kobject_del(&c->kobj);
1344 1344
1345 if (c->gc_thread)
1346 kthread_stop(c->gc_thread);
1347
1345 if (!IS_ERR_OR_NULL(c->root)) 1348 if (!IS_ERR_OR_NULL(c->root))
1346 list_add(&c->root->list, &c->btree_cache); 1349 list_add(&c->root->list, &c->btree_cache);
1347 1350
@@ -1579,8 +1582,6 @@ static void run_cache_set(struct cache_set *c)
1579 bch_journal_replay(c, &journal, &op); 1582 bch_journal_replay(c, &journal, &op);
1580 } else { 1583 } else {
1581 pr_notice("invalidating existing data"); 1584 pr_notice("invalidating existing data");
1582 /* Don't want invalidate_buckets() to queue a gc yet */
1583 closure_lock(&c->gc, NULL);
1584 1585
1585 for_each_cache(ca, c, i) { 1586 for_each_cache(ca, c, i) {
1586 unsigned j; 1587 unsigned j;
@@ -1606,12 +1607,12 @@ static void run_cache_set(struct cache_set *c)
1606 1607
1607 err = "cannot allocate new UUID bucket"; 1608 err = "cannot allocate new UUID bucket";
1608 if (__uuid_write(c)) 1609 if (__uuid_write(c))
1609 goto err_unlock_gc; 1610 goto err;
1610 1611
1611 err = "cannot allocate new btree root"; 1612 err = "cannot allocate new btree root";
1612 c->root = bch_btree_node_alloc(c, 0); 1613 c->root = bch_btree_node_alloc(c, 0);
1613 if (IS_ERR_OR_NULL(c->root)) 1614 if (IS_ERR_OR_NULL(c->root))
1614 goto err_unlock_gc; 1615 goto err;
1615 1616
1616 bkey_copy_key(&c->root->key, &MAX_KEY); 1617 bkey_copy_key(&c->root->key, &MAX_KEY);
1617 bch_btree_node_write(c->root, &op.cl); 1618 bch_btree_node_write(c->root, &op.cl);
@@ -1628,12 +1629,12 @@ static void run_cache_set(struct cache_set *c)
1628 1629
1629 bch_journal_next(&c->journal); 1630 bch_journal_next(&c->journal);
1630 bch_journal_meta(c, &op.cl); 1631 bch_journal_meta(c, &op.cl);
1631
1632 /* Unlock */
1633 closure_set_stopped(&c->gc.cl);
1634 closure_put(&c->gc.cl);
1635 } 1632 }
1636 1633
1634 err = "error starting gc thread";
1635 if (bch_gc_thread_start(c))
1636 goto err;
1637
1637 closure_sync(&op.cl); 1638 closure_sync(&op.cl);
1638 c->sb.last_mount = get_seconds(); 1639 c->sb.last_mount = get_seconds();
1639 bcache_write_super(c); 1640 bcache_write_super(c);
@@ -1644,9 +1645,6 @@ static void run_cache_set(struct cache_set *c)
1644 flash_devs_run(c); 1645 flash_devs_run(c);
1645 1646
1646 return; 1647 return;
1647err_unlock_gc:
1648 closure_set_stopped(&c->gc.cl);
1649 closure_put(&c->gc.cl);
1650err: 1648err:
1651 closure_sync(&op.cl); 1649 closure_sync(&op.cl);
1652 /* XXX: test this, it's broken */ 1650 /* XXX: test this, it's broken */