diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-07-24 21:06:22 -0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-11-11 00:56:30 -0500 |
commit | 6054c6d4da1940c7bf8870c6393773aa794f53d8 (patch) | |
tree | 5851d01503e16884cc733284ae102d27d0fe71ca /drivers/md | |
parent | 1b207d80d5b986fb305bc899357435d319319513 (diff) |
bcache: Don't use op->insert_collision
When we convert bch_btree_insert() to bch_btree_map_leaf_nodes(), we
won't be passing struct btree_op to bch_btree_insert() anymore - so we
need a different way of returning whether there was a collision (really,
a replace collision).
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/bcache/btree.c | 3 | ||||
-rw-r--r-- | drivers/md/bcache/movinggc.c | 2 | ||||
-rw-r--r-- | drivers/md/bcache/request.c | 10 | ||||
-rw-r--r-- | drivers/md/bcache/request.h | 1 | ||||
-rw-r--r-- | drivers/md/bcache/writeback.c | 7 |
5 files changed, 16 insertions, 7 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 7a1d8dc19e61..441524dd2d77 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c | |||
@@ -2227,6 +2227,9 @@ int bch_btree_insert(struct btree_op *op, struct cache_set *c, | |||
2227 | } | 2227 | } |
2228 | } | 2228 | } |
2229 | 2229 | ||
2230 | if (op->insert_collision) | ||
2231 | return -ESRCH; | ||
2232 | |||
2230 | return ret; | 2233 | return ret; |
2231 | } | 2234 | } |
2232 | 2235 | ||
diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c index c45ba4f21bae..601c96a62b30 100644 --- a/drivers/md/bcache/movinggc.c +++ b/drivers/md/bcache/movinggc.c | |||
@@ -52,7 +52,7 @@ static void write_moving_finish(struct closure *cl) | |||
52 | bio_for_each_segment_all(bv, bio, i) | 52 | bio_for_each_segment_all(bv, bio, i) |
53 | __free_page(bv->bv_page); | 53 | __free_page(bv->bv_page); |
54 | 54 | ||
55 | if (io->s.op.insert_collision) | 55 | if (io->s.insert_collision) |
56 | trace_bcache_gc_copy_collision(&io->w->key); | 56 | trace_bcache_gc_copy_collision(&io->w->key); |
57 | 57 | ||
58 | bch_keybuf_del(&io->s.c->moving_gc_keys, io->w); | 58 | bch_keybuf_del(&io->s.c->moving_gc_keys, io->w); |
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 16a3e16f3ff4..bcce06a1e466 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c | |||
@@ -218,6 +218,7 @@ static void bch_data_insert_keys(struct closure *cl) | |||
218 | struct search *s = container_of(cl, struct search, btree); | 218 | struct search *s = container_of(cl, struct search, btree); |
219 | atomic_t *journal_ref = NULL; | 219 | atomic_t *journal_ref = NULL; |
220 | struct bkey *replace_key = s->replace ? &s->replace_key : NULL; | 220 | struct bkey *replace_key = s->replace ? &s->replace_key : NULL; |
221 | int ret; | ||
221 | 222 | ||
222 | /* | 223 | /* |
223 | * If we're looping, might already be waiting on | 224 | * If we're looping, might already be waiting on |
@@ -236,8 +237,11 @@ static void bch_data_insert_keys(struct closure *cl) | |||
236 | s->flush_journal | 237 | s->flush_journal |
237 | ? &s->cl : NULL); | 238 | ? &s->cl : NULL); |
238 | 239 | ||
239 | if (bch_btree_insert(&s->op, s->c, &s->insert_keys, | 240 | ret = bch_btree_insert(&s->op, s->c, &s->insert_keys, |
240 | journal_ref, replace_key)) { | 241 | journal_ref, replace_key); |
242 | if (ret == -ESRCH) { | ||
243 | s->insert_collision = true; | ||
244 | } else if (ret) { | ||
241 | s->error = -ENOMEM; | 245 | s->error = -ENOMEM; |
242 | s->insert_data_done = true; | 246 | s->insert_data_done = true; |
243 | } | 247 | } |
@@ -977,7 +981,7 @@ static void cached_dev_cache_miss_done(struct closure *cl) | |||
977 | { | 981 | { |
978 | struct search *s = container_of(cl, struct search, cl); | 982 | struct search *s = container_of(cl, struct search, cl); |
979 | 983 | ||
980 | if (s->op.insert_collision) | 984 | if (s->insert_collision) |
981 | bch_mark_cache_miss_collision(s); | 985 | bch_mark_cache_miss_collision(s); |
982 | 986 | ||
983 | if (s->cache_bio) { | 987 | if (s->cache_bio) { |
diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index 5ea7a0e6fca0..f0e930b4ca89 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h | |||
@@ -34,6 +34,7 @@ struct search { | |||
34 | 34 | ||
35 | unsigned insert_data_done:1; | 35 | unsigned insert_data_done:1; |
36 | unsigned replace:1; | 36 | unsigned replace:1; |
37 | unsigned insert_collision:1; | ||
37 | 38 | ||
38 | uint16_t write_prio; | 39 | uint16_t write_prio; |
39 | 40 | ||
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index 346a5341faca..312032ef34f7 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c | |||
@@ -142,6 +142,7 @@ static void write_dirty_finish(struct closure *cl) | |||
142 | unsigned i; | 142 | unsigned i; |
143 | struct btree_op op; | 143 | struct btree_op op; |
144 | struct keylist keys; | 144 | struct keylist keys; |
145 | int ret; | ||
145 | 146 | ||
146 | bch_btree_op_init(&op, -1); | 147 | bch_btree_op_init(&op, -1); |
147 | bch_keylist_init(&keys); | 148 | bch_keylist_init(&keys); |
@@ -153,12 +154,12 @@ static void write_dirty_finish(struct closure *cl) | |||
153 | for (i = 0; i < KEY_PTRS(&w->key); i++) | 154 | for (i = 0; i < KEY_PTRS(&w->key); i++) |
154 | atomic_inc(&PTR_BUCKET(dc->disk.c, &w->key, i)->pin); | 155 | atomic_inc(&PTR_BUCKET(dc->disk.c, &w->key, i)->pin); |
155 | 156 | ||
156 | bch_btree_insert(&op, dc->disk.c, &keys, NULL, &w->key); | 157 | ret = bch_btree_insert(&op, dc->disk.c, &keys, NULL, &w->key); |
157 | 158 | ||
158 | if (op.insert_collision) | 159 | if (ret) |
159 | trace_bcache_writeback_collision(&w->key); | 160 | trace_bcache_writeback_collision(&w->key); |
160 | 161 | ||
161 | atomic_long_inc(op.insert_collision | 162 | atomic_long_inc(ret |
162 | ? &dc->disk.c->writeback_keys_failed | 163 | ? &dc->disk.c->writeback_keys_failed |
163 | : &dc->disk.c->writeback_keys_done); | 164 | : &dc->disk.c->writeback_keys_done); |
164 | } | 165 | } |