summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-08-05 21:44:39 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-08-05 21:44:39 -0800
commit7efc97e6e17cdf0d75e14f918a1ddd5f7f58381e (patch)
treee2d700860d984acb2bc4292bb260349b686b9855
parenta4bd4dbbc8fc366383c4dd4260d30ef7e6baec43 (diff)
bcache: trivial journal related refactoring
-rw-r--r--drivers/md/bcache/btree_update.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/md/bcache/btree_update.c b/drivers/md/bcache/btree_update.c
index ca364c7fce5d..176acff8ea53 100644
--- a/drivers/md/bcache/btree_update.c
+++ b/drivers/md/bcache/btree_update.c
@@ -723,9 +723,20 @@ void bch_btree_journal_key(struct btree_iter *iter,
struct journal_res *res)
{
struct cache_set *c = iter->c;
+ struct journal *j = &c->journal;
struct btree *b = iter->nodes[0];
+ struct btree_write *w = btree_current_write(b);
EBUG_ON(iter->level || b->level);
+ BUG_ON(!res->ref && test_bit(JOURNAL_REPLAY_DONE, &j->flags));
+
+ if (!journal_pin_active(&w->journal))
+ journal_pin_add(j, &w->journal, btree_node_flush);
+
+ if (test_bit(JOURNAL_REPLAY_DONE, &j->flags)) {
+ bch_journal_add_keys(j, res, b->btree_id, insert);
+ btree_bset_last(b)->journal_seq = cpu_to_le64(j->seq);
+ }
if (!btree_node_dirty(b)) {
set_btree_node_dirty(b);
@@ -734,20 +745,6 @@ void bch_btree_journal_key(struct btree_iter *iter,
queue_delayed_work(system_freezable_wq, &b->work,
c->btree_flush_delay * HZ);
}
-
- if (res->ref ||
- !test_bit(JOURNAL_REPLAY_DONE, &c->journal.flags)) {
- struct btree_write *w = btree_current_write(b);
-
- if (!journal_pin_active(&w->journal))
- journal_pin_add(&c->journal, &w->journal,
- btree_node_flush);
- }
-
- if (res->ref) {
- bch_journal_add_keys(&c->journal, res, b->btree_id, insert);
- btree_bset_last(b)->journal_seq = cpu_to_le64(c->journal.seq);
- }
}
static void verify_keys_sorted(struct keylist *l)