diff options
author | Slava Pestov <sp@daterainc.com> | 2014-04-21 21:23:12 -0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2014-08-04 18:23:03 -0400 |
commit | c5aa4a3157b55bdca18dd2a9d9f43314470b6d32 (patch) | |
tree | 561c55e24a7bc8d646ef2af5bb039b7b815bb676 /drivers/md | |
parent | a664d0f05a2ec02c8f042db536d84d15d6e19e81 (diff) |
bcache: wait for buckets when allocating new btree root
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>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/bcache/btree.c | 12 | ||||
-rw-r--r-- | drivers/md/bcache/btree.h | 3 | ||||
-rw-r--r-- | drivers/md/bcache/super.c | 2 |
3 files changed, 12 insertions, 5 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 7347b6100961..9dd9f1c4d0d9 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c | |||
@@ -1060,15 +1060,15 @@ static void btree_node_free(struct btree *b) | |||
1060 | mutex_unlock(&b->c->bucket_lock); | 1060 | mutex_unlock(&b->c->bucket_lock); |
1061 | } | 1061 | } |
1062 | 1062 | ||
1063 | struct btree *bch_btree_node_alloc(struct cache_set *c, struct btree_op *op, | 1063 | struct btree *__bch_btree_node_alloc(struct cache_set *c, struct btree_op *op, |
1064 | int level) | 1064 | int level, bool wait) |
1065 | { | 1065 | { |
1066 | BKEY_PADDED(key) k; | 1066 | BKEY_PADDED(key) k; |
1067 | struct btree *b = ERR_PTR(-EAGAIN); | 1067 | struct btree *b = ERR_PTR(-EAGAIN); |
1068 | 1068 | ||
1069 | mutex_lock(&c->bucket_lock); | 1069 | mutex_lock(&c->bucket_lock); |
1070 | retry: | 1070 | retry: |
1071 | if (__bch_bucket_alloc_set(c, RESERVE_BTREE, &k.key, 1, op != NULL)) | 1071 | if (__bch_bucket_alloc_set(c, RESERVE_BTREE, &k.key, 1, wait)) |
1072 | goto err; | 1072 | goto err; |
1073 | 1073 | ||
1074 | bkey_put(c, &k.key); | 1074 | bkey_put(c, &k.key); |
@@ -1100,6 +1100,12 @@ err: | |||
1100 | return b; | 1100 | return b; |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | static struct btree *bch_btree_node_alloc(struct cache_set *c, | ||
1104 | struct btree_op *op, int level) | ||
1105 | { | ||
1106 | return __bch_btree_node_alloc(c, op, level, op != NULL); | ||
1107 | } | ||
1108 | |||
1103 | static struct btree *btree_node_alloc_replacement(struct btree *b, | 1109 | static struct btree *btree_node_alloc_replacement(struct btree *b, |
1104 | struct btree_op *op) | 1110 | struct btree_op *op) |
1105 | { | 1111 | { |
diff --git a/drivers/md/bcache/btree.h b/drivers/md/bcache/btree.h index 91dfa5e69685..00441821f5ad 100644 --- a/drivers/md/bcache/btree.h +++ b/drivers/md/bcache/btree.h | |||
@@ -242,7 +242,8 @@ void __bch_btree_node_write(struct btree *, struct closure *); | |||
242 | void bch_btree_node_write(struct btree *, struct closure *); | 242 | void bch_btree_node_write(struct btree *, struct closure *); |
243 | 243 | ||
244 | void bch_btree_set_root(struct btree *); | 244 | void bch_btree_set_root(struct btree *); |
245 | struct btree *bch_btree_node_alloc(struct cache_set *, struct btree_op *, int); | 245 | struct btree *__bch_btree_node_alloc(struct cache_set *, struct btree_op *, |
246 | int, bool); | ||
246 | struct btree *bch_btree_node_get(struct cache_set *, struct btree_op *, | 247 | struct btree *bch_btree_node_get(struct cache_set *, struct btree_op *, |
247 | struct bkey *, int, bool); | 248 | struct bkey *, int, bool); |
248 | 249 | ||
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 6ceaec35b871..3b043a04d9bd 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c | |||
@@ -1669,7 +1669,7 @@ static void run_cache_set(struct cache_set *c) | |||
1669 | goto err; | 1669 | goto err; |
1670 | 1670 | ||
1671 | err = "cannot allocate new btree root"; | 1671 | err = "cannot allocate new btree root"; |
1672 | c->root = bch_btree_node_alloc(c, NULL, 0); | 1672 | c->root = __bch_btree_node_alloc(c, NULL, 0, true); |
1673 | if (IS_ERR_OR_NULL(c->root)) | 1673 | if (IS_ERR_OR_NULL(c->root)) |
1674 | goto err; | 1674 | goto err; |
1675 | 1675 | ||