aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/bcache/btree.c')
-rw-r--r--drivers/md/bcache/btree.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 22b9e34ceb75..5b815e64c1c9 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -1762,33 +1762,34 @@ static void bch_btree_gc(struct cache_set *c)
1762 bch_moving_gc(c); 1762 bch_moving_gc(c);
1763} 1763}
1764 1764
1765static int bch_gc_thread(void *arg) 1765static bool gc_should_run(struct cache_set *c)
1766{ 1766{
1767 struct cache_set *c = arg;
1768 struct cache *ca; 1767 struct cache *ca;
1769 unsigned i; 1768 unsigned i;
1770 1769
1771 while (1) { 1770 for_each_cache(ca, c, i)
1772again: 1771 if (ca->invalidate_needs_gc)
1773 bch_btree_gc(c); 1772 return true;
1774 1773
1775 set_current_state(TASK_INTERRUPTIBLE); 1774 if (atomic_read(&c->sectors_to_gc) < 0)
1776 if (kthread_should_stop()) 1775 return true;
1777 break;
1778 1776
1779 mutex_lock(&c->bucket_lock); 1777 return false;
1778}
1780 1779
1781 for_each_cache(ca, c, i) 1780static int bch_gc_thread(void *arg)
1782 if (ca->invalidate_needs_gc) { 1781{
1783 mutex_unlock(&c->bucket_lock); 1782 struct cache_set *c = arg;
1784 set_current_state(TASK_RUNNING);
1785 goto again;
1786 }
1787 1783
1788 mutex_unlock(&c->bucket_lock); 1784 while (1) {
1785 wait_event_interruptible(c->gc_wait,
1786 kthread_should_stop() || gc_should_run(c));
1789 1787
1790 try_to_freeze(); 1788 if (kthread_should_stop())
1791 schedule(); 1789 break;
1790
1791 set_gc_sectors(c);
1792 bch_btree_gc(c);
1792 } 1793 }
1793 1794
1794 return 0; 1795 return 0;
@@ -1796,11 +1797,10 @@ again:
1796 1797
1797int bch_gc_thread_start(struct cache_set *c) 1798int bch_gc_thread_start(struct cache_set *c)
1798{ 1799{
1799 c->gc_thread = kthread_create(bch_gc_thread, c, "bcache_gc"); 1800 c->gc_thread = kthread_run(bch_gc_thread, c, "bcache_gc");
1800 if (IS_ERR(c->gc_thread)) 1801 if (IS_ERR(c->gc_thread))
1801 return PTR_ERR(c->gc_thread); 1802 return PTR_ERR(c->gc_thread);
1802 1803
1803 set_task_state(c->gc_thread, TASK_INTERRUPTIBLE);
1804 return 0; 1804 return 0;
1805} 1805}
1806 1806