bcache: wait for buckets when allocating new btree root
authorSlava Pestov <sp@daterainc.com>
Tue, 22 Apr 2014 01:23:12 +0000 (18:23 -0700)
committerKent Overstreet <kmo@daterainc.com>
Mon, 4 Aug 2014 22:23:03 +0000 (15:23 -0700)
Tested:
- sometimes bcache_tier test would hang on startup with a failure
  to allocate the btree root -- no longer seeing this

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

index 7347b61009615089e307fba6b5964fcb83ad2040..9dd9f1c4d0d97e088e7e9b99385aa6e4e5a50b38 100644 (file)
@@ -1060,15 +1060,15 @@ static void btree_node_free(struct btree *b)
        mutex_unlock(&b->c->bucket_lock);
 }
 
-struct btree *bch_btree_node_alloc(struct cache_set *c, struct btree_op *op,
-                                  int level)
+struct btree *__bch_btree_node_alloc(struct cache_set *c, struct btree_op *op,
+                                    int level, bool wait)
 {
        BKEY_PADDED(key) k;
        struct btree *b = ERR_PTR(-EAGAIN);
 
        mutex_lock(&c->bucket_lock);
 retry:
-       if (__bch_bucket_alloc_set(c, RESERVE_BTREE, &k.key, 1, op != NULL))
+       if (__bch_bucket_alloc_set(c, RESERVE_BTREE, &k.key, 1, wait))
                goto err;
 
        bkey_put(c, &k.key);
@@ -1100,6 +1100,12 @@ err:
        return b;
 }
 
+static struct btree *bch_btree_node_alloc(struct cache_set *c,
+                                         struct btree_op *op, int level)
+{
+       return __bch_btree_node_alloc(c, op, level, op != NULL);
+}
+
 static struct btree *btree_node_alloc_replacement(struct btree *b,
                                                  struct btree_op *op)
 {
index 91dfa5e696857ded36b3de7b66a8f862d9540cea..00441821f5adbe68d31e3c4225e52f83e1ec7dfe 100644 (file)
@@ -242,7 +242,8 @@ void __bch_btree_node_write(struct btree *, struct closure *);
 void bch_btree_node_write(struct btree *, struct closure *);
 
 void bch_btree_set_root(struct btree *);
-struct btree *bch_btree_node_alloc(struct cache_set *, struct btree_op *, int);
+struct btree *__bch_btree_node_alloc(struct cache_set *, struct btree_op *,
+                                    int, bool);
 struct btree *bch_btree_node_get(struct cache_set *, struct btree_op *,
                                 struct bkey *, int, bool);
 
index 6ceaec35b8719152d3decdb3e7a0da3bfdcb029e..3b043a04d9bd712fcfcdbe34abfa18487bd35a3d 100644 (file)
@@ -1669,7 +1669,7 @@ static void run_cache_set(struct cache_set *c)
                        goto err;
 
                err = "cannot allocate new btree root";
-               c->root = bch_btree_node_alloc(c, NULL, 0);
+               c->root = __bch_btree_node_alloc(c, NULL, 0, true);
                if (IS_ERR_OR_NULL(c->root))
                        goto err;
 
This page took 0.027107 seconds and 5 git commands to generate.