]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
bcache: Fix a shutdown bug
authorKent Overstreet <kmo@daterainc.com>
Thu, 20 Feb 2014 03:48:26 +0000 (19:48 -0800)
committerKent Overstreet <kmo@daterainc.com>
Wed, 26 Feb 2014 02:42:49 +0000 (18:42 -0800)
Shutdown wasn't cancelling/waiting on journal_write_work()

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
drivers/md/bcache/journal.c
drivers/md/bcache/journal.h
drivers/md/bcache/super.c

index 18039affc306b539e187b9b57ba3f1c3c3b95e3d..e38c5997bf12706afa0e649bd96e80d284a9a758 100644 (file)
@@ -536,6 +536,7 @@ void bch_journal_next(struct journal *j)
        atomic_set(&fifo_back(&j->pin), 1);
 
        j->cur->data->seq       = ++j->seq;
+       j->cur->dirty           = false;
        j->cur->need_write      = false;
        j->cur->data->keys      = 0;
 
@@ -731,7 +732,10 @@ static void journal_write_work(struct work_struct *work)
                                           struct cache_set,
                                           journal.work);
        spin_lock(&c->journal.lock);
-       journal_try_write(c);
+       if (c->journal.cur->dirty)
+               journal_try_write(c);
+       else
+               spin_unlock(&c->journal.lock);
 }
 
 /*
@@ -761,7 +765,8 @@ atomic_t *bch_journal(struct cache_set *c,
        if (parent) {
                closure_wait(&w->wait, parent);
                journal_try_write(c);
-       } else if (!w->need_write) {
+       } else if (!w->dirty) {
+               w->dirty = true;
                schedule_delayed_work(&c->journal.work,
                                      msecs_to_jiffies(c->journal_delay_ms));
                spin_unlock(&c->journal.lock);
index 9180c44650759b61b843ea8fe763a38b62277cd4..e3c39457afbb19a7a47b9c23eb9b127520223523 100644 (file)
@@ -95,6 +95,7 @@ struct journal_write {
 
        struct cache_set        *c;
        struct closure_waitlist wait;
+       bool                    dirty;
        bool                    need_write;
 };
 
index 24a3a1546caa7a4c8e9c0aa70c9461574f87a591..c70521fe57a60597b71b7a3b210664e3d52be784 100644 (file)
@@ -1403,6 +1403,10 @@ static void cache_set_flush(struct closure *cl)
                if (ca->alloc_thread)
                        kthread_stop(ca->alloc_thread);
 
+       cancel_delayed_work_sync(&c->journal.work);
+       /* flush last journal entry if needed */
+       c->journal.work.work.func(&c->journal.work.work);
+
        closure_return(cl);
 }