diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2016-11-19 19:03:35 -0900 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2016-11-23 14:09:24 -0900 |
commit | 338aa4a90e963dd1c7c5eb73f81d34ddca3450d1 (patch) | |
tree | b661c9a3f097547cbf04e0020f82f1877c8ab813 | |
parent | 16a5616e202075fda7dc7a83f550f6e5892fee80 (diff) |
bcache: slim struct btree a bit more
-rw-r--r-- | drivers/md/bcache/btree_cache.c | 1 | ||||
-rw-r--r-- | drivers/md/bcache/btree_types.h | 1 | ||||
-rw-r--r-- | drivers/md/bcache/btree_update.c | 22 |
3 files changed, 18 insertions, 6 deletions
diff --git a/drivers/md/bcache/btree_cache.c b/drivers/md/bcache/btree_cache.c index 207cf0f3f1b9..42c2609db4b0 100644 --- a/drivers/md/bcache/btree_cache.c +++ b/drivers/md/bcache/btree_cache.c @@ -87,7 +87,6 @@ static struct btree *mca_bucket_alloc(struct cache_set *c, gfp_t gfp) six_lock_init(&b->lock); INIT_LIST_HEAD(&b->list); - b->writes[1].index = 1; INIT_LIST_HEAD(&b->write_blocked); mca_data_alloc(c, b, gfp); diff --git a/drivers/md/bcache/btree_types.h b/drivers/md/bcache/btree_types.h index e834a54c2376..5b22b84188df 100644 --- a/drivers/md/bcache/btree_types.h +++ b/drivers/md/bcache/btree_types.h @@ -17,7 +17,6 @@ struct open_bucket; struct btree_interior_update; struct btree_write { - unsigned index; struct journal_entry_pin journal; struct closure_waitlist wait; }; diff --git a/drivers/md/bcache/btree_update.c b/drivers/md/bcache/btree_update.c index 5ee107de38b3..0224e4176aa5 100644 --- a/drivers/md/bcache/btree_update.c +++ b/drivers/md/bcache/btree_update.c @@ -698,11 +698,12 @@ overwrite: clobber_u64s, k->u64s); } -static void btree_node_flush(struct journal *j, struct journal_entry_pin *pin) +static void __btree_node_flush(struct journal *j, struct journal_entry_pin *pin, + unsigned i) { struct cache_set *c = container_of(j, struct cache_set, journal); struct btree_write *w = container_of(pin, struct btree_write, journal); - struct btree *b = container_of(w, struct btree, writes[w->index]); + struct btree *b = container_of(w, struct btree, writes[i]); six_lock_read(&b->lock); /* @@ -719,10 +720,20 @@ static void btree_node_flush(struct journal *j, struct journal_entry_pin *pin) * shouldn't: */ if (!b->level) - __bch_btree_node_write(c, b, NULL, w->index); + __bch_btree_node_write(c, b, NULL, i); six_unlock_read(&b->lock); } +static void btree_node_flush0(struct journal *j, struct journal_entry_pin *pin) +{ + return __btree_node_flush(j, pin, 0); +} + +static void btree_node_flush1(struct journal *j, struct journal_entry_pin *pin) +{ + return __btree_node_flush(j, pin, 1); +} + void bch_btree_journal_key(struct btree_iter *iter, struct bkey_i *insert, struct journal_res *res) @@ -736,7 +747,10 @@ void bch_btree_journal_key(struct btree_iter *iter, EBUG_ON(!res->ref && test_bit(JOURNAL_REPLAY_DONE, &j->flags)); if (!journal_pin_active(&w->journal)) - bch_journal_pin_add(j, &w->journal, btree_node_flush); + bch_journal_pin_add(j, &w->journal, + btree_node_write_idx(b) == 0 + ? btree_node_flush0 + : btree_node_flush1); if (res->ref) { bch_journal_add_keys(j, res, b->btree_id, insert); |