]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
bcache: fix crash with incomplete cache set
authorSlava Pestov <sp@daterainc.com>
Fri, 11 Jul 2014 19:17:41 +0000 (12:17 -0700)
committerKent Overstreet <kmo@daterainc.com>
Mon, 4 Aug 2014 22:23:04 +0000 (15:23 -0700)
Change-Id: I6abde52afe917633480caaf4e2518f42a816d886

drivers/md/bcache/bcache.h
drivers/md/bcache/super.c

index d2ebcf3230942ab7872025c9fbf177ae515aded4..04f7bc28ef832b6dded6d10e810ddbfbfada4fca 100644 (file)
@@ -477,9 +477,13 @@ struct gc_stat {
  * CACHE_SET_STOPPING always gets set first when we're closing down a cache set;
  * we'll continue to run normally for awhile with CACHE_SET_STOPPING set (i.e.
  * flushing dirty data).
+ *
+ * CACHE_SET_RUNNING means all cache devices have been registered and journal
+ * replay is complete.
  */
 #define CACHE_SET_UNREGISTERING                0
 #define        CACHE_SET_STOPPING              1
+#define        CACHE_SET_RUNNING               2
 
 struct cache_set {
        struct closure          cl;
index 29dd1e8ae19f26f7613c95d995e2a7651a3f5b6f..72fbaf79b0c80408f15057d45b09b5518588121d 100644 (file)
@@ -1284,6 +1284,9 @@ int bch_flash_dev_create(struct cache_set *c, uint64_t size)
        if (test_bit(CACHE_SET_STOPPING, &c->flags))
                return -EINTR;
 
+       if (!test_bit(CACHE_SET_RUNNING, &c->flags))
+               return -EPERM;
+
        u = uuid_find_empty(c);
        if (!u) {
                pr_err("Can't create volume, no room for UUID");
@@ -1706,6 +1709,7 @@ static void run_cache_set(struct cache_set *c)
 
        flash_devs_run(c);
 
+       set_bit(CACHE_SET_RUNNING, &c->flags);
        return;
 err:
        closure_sync(&cl);