diff options
Diffstat (limited to 'drivers/md/bcache/journal.c')
-rw-r--r-- | drivers/md/bcache/journal.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index 8c8dfdcd9d4c..ba95ab84b2be 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c | |||
@@ -9,6 +9,8 @@ | |||
9 | #include "debug.h" | 9 | #include "debug.h" |
10 | #include "request.h" | 10 | #include "request.h" |
11 | 11 | ||
12 | #include <trace/events/bcache.h> | ||
13 | |||
12 | /* | 14 | /* |
13 | * Journal replay/recovery: | 15 | * Journal replay/recovery: |
14 | * | 16 | * |
@@ -182,9 +184,14 @@ bsearch: | |||
182 | pr_debug("starting binary search, l %u r %u", l, r); | 184 | pr_debug("starting binary search, l %u r %u", l, r); |
183 | 185 | ||
184 | while (l + 1 < r) { | 186 | while (l + 1 < r) { |
187 | seq = list_entry(list->prev, struct journal_replay, | ||
188 | list)->j.seq; | ||
189 | |||
185 | m = (l + r) >> 1; | 190 | m = (l + r) >> 1; |
191 | read_bucket(m); | ||
186 | 192 | ||
187 | if (read_bucket(m)) | 193 | if (seq != list_entry(list->prev, struct journal_replay, |
194 | list)->j.seq) | ||
188 | l = m; | 195 | l = m; |
189 | else | 196 | else |
190 | r = m; | 197 | r = m; |
@@ -300,7 +307,8 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list, | |||
300 | for (k = i->j.start; | 307 | for (k = i->j.start; |
301 | k < end(&i->j); | 308 | k < end(&i->j); |
302 | k = bkey_next(k)) { | 309 | k = bkey_next(k)) { |
303 | pr_debug("%s", pkey(k)); | 310 | trace_bcache_journal_replay_key(k); |
311 | |||
304 | bkey_copy(op->keys.top, k); | 312 | bkey_copy(op->keys.top, k); |
305 | bch_keylist_push(&op->keys); | 313 | bch_keylist_push(&op->keys); |
306 | 314 | ||
@@ -384,7 +392,7 @@ out: | |||
384 | return; | 392 | return; |
385 | found: | 393 | found: |
386 | if (btree_node_dirty(best)) | 394 | if (btree_node_dirty(best)) |
387 | bch_btree_write(best, true, NULL); | 395 | bch_btree_node_write(best, NULL); |
388 | rw_unlock(true, best); | 396 | rw_unlock(true, best); |
389 | } | 397 | } |
390 | 398 | ||
@@ -617,7 +625,7 @@ static void journal_write_unlocked(struct closure *cl) | |||
617 | bio_reset(bio); | 625 | bio_reset(bio); |
618 | bio->bi_sector = PTR_OFFSET(k, i); | 626 | bio->bi_sector = PTR_OFFSET(k, i); |
619 | bio->bi_bdev = ca->bdev; | 627 | bio->bi_bdev = ca->bdev; |
620 | bio->bi_rw = REQ_WRITE|REQ_SYNC|REQ_META|REQ_FLUSH; | 628 | bio->bi_rw = REQ_WRITE|REQ_SYNC|REQ_META|REQ_FLUSH|REQ_FUA; |
621 | bio->bi_size = sectors << 9; | 629 | bio->bi_size = sectors << 9; |
622 | 630 | ||
623 | bio->bi_end_io = journal_write_endio; | 631 | bio->bi_end_io = journal_write_endio; |
@@ -712,7 +720,8 @@ void bch_journal(struct closure *cl) | |||
712 | spin_lock(&c->journal.lock); | 720 | spin_lock(&c->journal.lock); |
713 | 721 | ||
714 | if (journal_full(&c->journal)) { | 722 | if (journal_full(&c->journal)) { |
715 | /* XXX: tracepoint */ | 723 | trace_bcache_journal_full(c); |
724 | |||
716 | closure_wait(&c->journal.wait, cl); | 725 | closure_wait(&c->journal.wait, cl); |
717 | 726 | ||
718 | journal_reclaim(c); | 727 | journal_reclaim(c); |
@@ -728,13 +737,15 @@ void bch_journal(struct closure *cl) | |||
728 | 737 | ||
729 | if (b * c->sb.block_size > PAGE_SECTORS << JSET_BITS || | 738 | if (b * c->sb.block_size > PAGE_SECTORS << JSET_BITS || |
730 | b > c->journal.blocks_free) { | 739 | b > c->journal.blocks_free) { |
731 | /* XXX: If we were inserting so many keys that they won't fit in | 740 | trace_bcache_journal_entry_full(c); |
741 | |||
742 | /* | ||
743 | * XXX: If we were inserting so many keys that they won't fit in | ||
732 | * an _empty_ journal write, we'll deadlock. For now, handle | 744 | * an _empty_ journal write, we'll deadlock. For now, handle |
733 | * this in bch_keylist_realloc() - but something to think about. | 745 | * this in bch_keylist_realloc() - but something to think about. |
734 | */ | 746 | */ |
735 | BUG_ON(!w->data->keys); | 747 | BUG_ON(!w->data->keys); |
736 | 748 | ||
737 | /* XXX: tracepoint */ | ||
738 | BUG_ON(!closure_wait(&w->wait, cl)); | 749 | BUG_ON(!closure_wait(&w->wait, cl)); |
739 | 750 | ||
740 | closure_flush(&c->journal.io); | 751 | closure_flush(&c->journal.io); |