aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-09-10 21:46:36 -0400
committerKent Overstreet <kmo@daterainc.com>2013-11-11 00:55:59 -0500
commit4f3d40147b8d0ce7055e241e1d263e0aa2b2b46d (patch)
treeb49db9c82d6301c01734fa40c42ab470cdde0414 /drivers
parente7c590eb63509c5d5f48a390d23aa25f4417ac96 (diff)
bcache: Add explicit keylist arg to btree_insert()
Some refactoring - better to explicitly pass stuff around instead of having it all in the "big bag of state", struct btree_op. Going to prune struct btree_op quite a bit over time. Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/bcache/btree.c26
-rw-r--r--drivers/md/bcache/btree.h2
-rw-r--r--drivers/md/bcache/journal.c2
-rw-r--r--drivers/md/bcache/request.c2
-rw-r--r--drivers/md/bcache/writeback.c2
5 files changed, 18 insertions, 16 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 08a85327431c..fc3cae5c94b2 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -2109,30 +2109,32 @@ out:
2109 return ret; 2109 return ret;
2110} 2110}
2111 2111
2112static int bch_btree_insert_recurse(struct btree *b, struct btree_op *op) 2112static int bch_btree_insert_recurse(struct btree *b, struct btree_op *op,
2113 struct keylist *keys)
2113{ 2114{
2114 if (bch_keylist_empty(&op->keys)) 2115 if (bch_keylist_empty(keys))
2115 return 0; 2116 return 0;
2116 2117
2117 if (b->level) { 2118 if (b->level) {
2118 struct bkey *insert = op->keys.bottom; 2119 struct bkey *k;
2119 struct bkey *k = bch_next_recurse_key(b, &START_KEY(insert));
2120 2120
2121 k = bch_next_recurse_key(b, &START_KEY(keys->bottom));
2121 if (!k) { 2122 if (!k) {
2122 btree_bug(b, "no key to recurse on at level %i/%i", 2123 btree_bug(b, "no key to recurse on at level %i/%i",
2123 b->level, b->c->root->level); 2124 b->level, b->c->root->level);
2124 2125
2125 op->keys.top = op->keys.bottom; 2126 keys->top = keys->bottom;
2126 return -EIO; 2127 return -EIO;
2127 } 2128 }
2128 2129
2129 return btree(insert_recurse, k, b, op); 2130 return btree(insert_recurse, k, b, op, keys);
2130 } else { 2131 } else {
2131 return bch_btree_insert_node(b, op, &op->keys); 2132 return bch_btree_insert_node(b, op, keys);
2132 } 2133 }
2133} 2134}
2134 2135
2135int bch_btree_insert(struct btree_op *op, struct cache_set *c) 2136int bch_btree_insert(struct btree_op *op, struct cache_set *c,
2137 struct keylist *keys)
2136{ 2138{
2137 int ret = 0; 2139 int ret = 0;
2138 2140
@@ -2142,11 +2144,11 @@ int bch_btree_insert(struct btree_op *op, struct cache_set *c)
2142 */ 2144 */
2143 clear_closure_blocking(&op->cl); 2145 clear_closure_blocking(&op->cl);
2144 2146
2145 BUG_ON(bch_keylist_empty(&op->keys)); 2147 BUG_ON(bch_keylist_empty(keys));
2146 2148
2147 while (!bch_keylist_empty(&op->keys)) { 2149 while (!bch_keylist_empty(keys)) {
2148 op->lock = 0; 2150 op->lock = 0;
2149 ret = btree_root(insert_recurse, c, op); 2151 ret = btree_root(insert_recurse, c, op, keys);
2150 2152
2151 if (ret == -EAGAIN) { 2153 if (ret == -EAGAIN) {
2152 ret = 0; 2154 ret = 0;
@@ -2157,7 +2159,7 @@ int bch_btree_insert(struct btree_op *op, struct cache_set *c)
2157 pr_err("error %i trying to insert key for %s", 2159 pr_err("error %i trying to insert key for %s",
2158 ret, op_type(op)); 2160 ret, op_type(op));
2159 2161
2160 while ((k = bch_keylist_pop(&op->keys))) 2162 while ((k = bch_keylist_pop(keys)))
2161 bkey_put(c, k, 0); 2163 bkey_put(c, k, 0);
2162 } 2164 }
2163 } 2165 }
diff --git a/drivers/md/bcache/btree.h b/drivers/md/bcache/btree.h
index 73bd62105e39..967aacd20625 100644
--- a/drivers/md/bcache/btree.h
+++ b/drivers/md/bcache/btree.h
@@ -384,7 +384,7 @@ struct btree *bch_btree_node_get(struct cache_set *, struct bkey *,
384 384
385int bch_btree_insert_check_key(struct btree *, struct btree_op *, 385int bch_btree_insert_check_key(struct btree *, struct btree_op *,
386 struct bkey *); 386 struct bkey *);
387int bch_btree_insert(struct btree_op *, struct cache_set *); 387int bch_btree_insert(struct btree_op *, struct cache_set *, struct keylist *);
388 388
389int bch_btree_search_recurse(struct btree *, struct btree_op *); 389int bch_btree_search_recurse(struct btree *, struct btree_op *);
390 390
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 9e8775872dba..5abe5d5fc183 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -320,7 +320,7 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list,
320 op->journal = i->pin; 320 op->journal = i->pin;
321 atomic_inc(op->journal); 321 atomic_inc(op->journal);
322 322
323 ret = bch_btree_insert(op, s); 323 ret = bch_btree_insert(op, s, &op->keys);
324 if (ret) 324 if (ret)
325 goto err; 325 goto err;
326 326
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index 9ed334ca484d..7fd84ce9e835 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -607,7 +607,7 @@ void bch_btree_insert_async(struct closure *cl)
607 struct btree_op *op = container_of(cl, struct btree_op, cl); 607 struct btree_op *op = container_of(cl, struct btree_op, cl);
608 struct search *s = container_of(op, struct search, op); 608 struct search *s = container_of(op, struct search, op);
609 609
610 if (bch_btree_insert(op, op->c)) { 610 if (bch_btree_insert(op, op->c, &op->keys)) {
611 s->error = -ENOMEM; 611 s->error = -ENOMEM;
612 op->insert_data_done = true; 612 op->insert_data_done = true;
613 } 613 }
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index b842fbfbf1db..8ffc8ec7231d 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -311,7 +311,7 @@ static void write_dirty_finish(struct closure *cl)
311 for (i = 0; i < KEY_PTRS(&w->key); i++) 311 for (i = 0; i < KEY_PTRS(&w->key); i++)
312 atomic_inc(&PTR_BUCKET(dc->disk.c, &w->key, i)->pin); 312 atomic_inc(&PTR_BUCKET(dc->disk.c, &w->key, i)->pin);
313 313
314 bch_btree_insert(&op, dc->disk.c); 314 bch_btree_insert(&op, dc->disk.c, &op.keys);
315 closure_sync(&op.cl); 315 closure_sync(&op.cl);
316 316
317 if (op.insert_collision) 317 if (op.insert_collision)