aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/alloc.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-07-10 21:31:58 -0400
committerKent Overstreet <kmo@daterainc.com>2013-07-12 03:22:49 -0400
commit79826c35eb99cd3c0873b8396f45fa26c87fb0b0 (patch)
tree0812a5cfdb0b15321af8c3f57eb4d8790e928d9e /drivers/md/bcache/alloc.c
parent29ebf465b9050f241c4433a796a32e6c896a9dcd (diff)
bcache: Allocation kthread fixes
The alloc kthread should've been using try_to_freeze() - and also there was the potential for the alloc kthread to get woken up after it had shut down, which would have been bad. Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/alloc.c')
-rw-r--r--drivers/md/bcache/alloc.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
index b54b73b9b2b7..e45f5575fd4d 100644
--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -63,6 +63,7 @@
63#include "bcache.h" 63#include "bcache.h"
64#include "btree.h" 64#include "btree.h"
65 65
66#include <linux/freezer.h>
66#include <linux/kthread.h> 67#include <linux/kthread.h>
67#include <linux/random.h> 68#include <linux/random.h>
68#include <trace/events/bcache.h> 69#include <trace/events/bcache.h>
@@ -363,11 +364,10 @@ do { \
363 break; \ 364 break; \
364 \ 365 \
365 mutex_unlock(&(ca)->set->bucket_lock); \ 366 mutex_unlock(&(ca)->set->bucket_lock); \
366 if (test_bit(CACHE_SET_STOPPING_2, &ca->set->flags)) { \ 367 if (kthread_should_stop()) \
367 closure_put(&ca->set->cl); \
368 return 0; \ 368 return 0; \
369 } \
370 \ 369 \
370 try_to_freeze(); \
371 schedule(); \ 371 schedule(); \
372 mutex_lock(&(ca)->set->bucket_lock); \ 372 mutex_lock(&(ca)->set->bucket_lock); \
373 } \ 373 } \
@@ -547,14 +547,12 @@ int bch_bucket_alloc_set(struct cache_set *c, unsigned watermark,
547 547
548int bch_cache_allocator_start(struct cache *ca) 548int bch_cache_allocator_start(struct cache *ca)
549{ 549{
550 ca->alloc_thread = kthread_create(bch_allocator_thread, 550 struct task_struct *k = kthread_run(bch_allocator_thread,
551 ca, "bcache_allocator"); 551 ca, "bcache_allocator");
552 if (IS_ERR(ca->alloc_thread)) 552 if (IS_ERR(k))
553 return PTR_ERR(ca->alloc_thread); 553 return PTR_ERR(k);
554
555 closure_get(&ca->set->cl);
556 wake_up_process(ca->alloc_thread);
557 554
555 ca->alloc_thread = k;
558 return 0; 556 return 0;
559} 557}
560 558