]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
bcache: Don't use op->insert_collision
authorKent Overstreet <kmo@daterainc.com>
Thu, 25 Jul 2013 01:06:22 +0000 (18:06 -0700)
committerKent Overstreet <kmo@daterainc.com>
Wed, 11 Sep 2013 01:53:22 +0000 (18:53 -0700)
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>
drivers/md/bcache/btree.c
drivers/md/bcache/movinggc.c
drivers/md/bcache/request.c
drivers/md/bcache/request.h
drivers/md/bcache/writeback.c

index 1ada9dfe234fecb880ff312c1edebfc138fd160b..933c22c7e2762d12f06d03a5cb9a85349bd237c5 100644 (file)
@@ -2215,6 +2215,9 @@ int bch_btree_insert(struct btree_op *op, struct cache_set *c,
                }
        }
 
+       if (op->insert_collision)
+               return -ESRCH;
+
        return ret;
 }
 
index d7404e449b4f3c27551b8dd594ad2707a933b3eb..debcf4c11a0140fc064a16a02fccd6e931000df8 100644 (file)
@@ -52,7 +52,7 @@ static void write_moving_finish(struct closure *cl)
        bio_for_each_segment_all(bv, bio, i)
                __free_page(bv->bv_page);
 
-       if (io->s.op.insert_collision)
+       if (io->s.insert_collision)
                trace_bcache_gc_copy_collision(&io->w->key);
 
        bch_keybuf_del(&io->s.c->moving_gc_keys, io->w);
index 0607ba496ea4426c69b45fa8b86f359aaacecc3a..21e46c830c20212e8001b31c6ca834df1a91f5a6 100644 (file)
@@ -218,6 +218,7 @@ static void bch_data_insert_keys(struct closure *cl)
        struct search *s = container_of(cl, struct search, btree);
        atomic_t *journal_ref = NULL;
        struct bkey *replace_key = s->replace ? &s->replace_key : NULL;
+       int ret;
 
        /*
         * If we're looping, might already be waiting on
@@ -236,8 +237,11 @@ static void bch_data_insert_keys(struct closure *cl)
                                          s->flush_journal
                                          ? &s->cl : NULL);
 
-       if (bch_btree_insert(&s->op, s->c, &s->insert_keys,
-                            journal_ref, replace_key)) {
+       ret = bch_btree_insert(&s->op, s->c, &s->insert_keys,
+                              journal_ref, replace_key);
+       if (ret == -ESRCH) {
+               s->insert_collision = true;
+       } else if (ret) {
                s->error                = -ENOMEM;
                s->insert_data_done     = true;
        }
@@ -977,7 +981,7 @@ static void cached_dev_cache_miss_done(struct closure *cl)
 {
        struct search *s = container_of(cl, struct search, cl);
 
-       if (s->op.insert_collision)
+       if (s->insert_collision)
                bch_mark_cache_miss_collision(s);
 
        if (s->cache_bio) {
index 5ea7a0e6fca039f610a1c43c18dac40fa0123b99..f0e930b4ca893a2b6a303cd595b5ac8d7490fdd6 100644 (file)
@@ -34,6 +34,7 @@ struct search {
 
        unsigned                insert_data_done:1;
        unsigned                replace:1;
+       unsigned                insert_collision:1;
 
        uint16_t                write_prio;
 
index 346a5341facac202927fc8f952dcf6197e4c53f8..312032ef34f721afddcbc68256169164091d3589 100644 (file)
@@ -142,6 +142,7 @@ static void write_dirty_finish(struct closure *cl)
                unsigned i;
                struct btree_op op;
                struct keylist keys;
+               int ret;
 
                bch_btree_op_init(&op, -1);
                bch_keylist_init(&keys);
@@ -153,12 +154,12 @@ static void write_dirty_finish(struct closure *cl)
                for (i = 0; i < KEY_PTRS(&w->key); i++)
                        atomic_inc(&PTR_BUCKET(dc->disk.c, &w->key, i)->pin);
 
-               bch_btree_insert(&op, dc->disk.c, &keys, NULL, &w->key);
+               ret = bch_btree_insert(&op, dc->disk.c, &keys, NULL, &w->key);
 
-               if (op.insert_collision)
+               if (ret)
                        trace_bcache_writeback_collision(&w->key);
 
-               atomic_long_inc(op.insert_collision
+               atomic_long_inc(ret
                                ? &dc->disk.c->writeback_keys_failed
                                : &dc->disk.c->writeback_keys_done);
        }