aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2014-02-19 22:48:26 -0500
committerKent Overstreet <kmo@daterainc.com>2014-02-25 21:42:49 -0500
commitdabb44334060b4b84051b34c58573e57cc7432b2 (patch)
tree7372c3f3d4d6309c4ee4214494f93c6e7fcc3d58 /drivers/md/bcache
parent1b4eaf3d3809a658c85911e92d9ff64086931efa (diff)
bcache: Fix a shutdown bug
Shutdown wasn't cancelling/waiting on journal_write_work() Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache')
-rw-r--r--drivers/md/bcache/journal.c9
-rw-r--r--drivers/md/bcache/journal.h1
-rw-r--r--drivers/md/bcache/super.c4
3 files changed, 12 insertions, 2 deletions
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 18039affc306..e38c5997bf12 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -536,6 +536,7 @@ void bch_journal_next(struct journal *j)
536 atomic_set(&fifo_back(&j->pin), 1); 536 atomic_set(&fifo_back(&j->pin), 1);
537 537
538 j->cur->data->seq = ++j->seq; 538 j->cur->data->seq = ++j->seq;
539 j->cur->dirty = false;
539 j->cur->need_write = false; 540 j->cur->need_write = false;
540 j->cur->data->keys = 0; 541 j->cur->data->keys = 0;
541 542
@@ -731,7 +732,10 @@ static void journal_write_work(struct work_struct *work)
731 struct cache_set, 732 struct cache_set,
732 journal.work); 733 journal.work);
733 spin_lock(&c->journal.lock); 734 spin_lock(&c->journal.lock);
734 journal_try_write(c); 735 if (c->journal.cur->dirty)
736 journal_try_write(c);
737 else
738 spin_unlock(&c->journal.lock);
735} 739}
736 740
737/* 741/*
@@ -761,7 +765,8 @@ atomic_t *bch_journal(struct cache_set *c,
761 if (parent) { 765 if (parent) {
762 closure_wait(&w->wait, parent); 766 closure_wait(&w->wait, parent);
763 journal_try_write(c); 767 journal_try_write(c);
764 } else if (!w->need_write) { 768 } else if (!w->dirty) {
769 w->dirty = true;
765 schedule_delayed_work(&c->journal.work, 770 schedule_delayed_work(&c->journal.work,
766 msecs_to_jiffies(c->journal_delay_ms)); 771 msecs_to_jiffies(c->journal_delay_ms));
767 spin_unlock(&c->journal.lock); 772 spin_unlock(&c->journal.lock);
diff --git a/drivers/md/bcache/journal.h b/drivers/md/bcache/journal.h
index 9180c4465075..e3c39457afbb 100644
--- a/drivers/md/bcache/journal.h
+++ b/drivers/md/bcache/journal.h
@@ -95,6 +95,7 @@ struct journal_write {
95 95
96 struct cache_set *c; 96 struct cache_set *c;
97 struct closure_waitlist wait; 97 struct closure_waitlist wait;
98 bool dirty;
98 bool need_write; 99 bool need_write;
99}; 100};
100 101
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 24a3a1546caa..c70521fe57a6 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1403,6 +1403,10 @@ static void cache_set_flush(struct closure *cl)
1403 if (ca->alloc_thread) 1403 if (ca->alloc_thread)
1404 kthread_stop(ca->alloc_thread); 1404 kthread_stop(ca->alloc_thread);
1405 1405
1406 cancel_delayed_work_sync(&c->journal.work);
1407 /* flush last journal entry if needed */
1408 c->journal.work.work.func(&c->journal.work.work);
1409
1406 closure_return(cl); 1410 closure_return(cl);
1407} 1411}
1408 1412