Skip to content

Commit

Permalink
bcache: Journal replay fix
Browse files Browse the repository at this point in the history
commit faa5673 upstream.

The journal replay code starts by finding something that looks like a
valid journal entry, then it does a binary search over the unchecked
region of the journal for the journal entries with the highest sequence
numbers.

Trouble is, the logic was wrong - journal_read_bucket() returns true if
it found journal entries we need, but if the range of journal entries
we're looking for loops around the end of the journal - in that case
journal_read_bucket() could return true when it hadn't found the highest
sequence number we'd seen yet, and in that case the binary search did
the wrong thing. Whoops.

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Kent Overstreet authored and gregkh committed Jul 28, 2013
1 parent 99e56bf commit 5e20e8b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/md/bcache/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,14 @@ int bch_journal_read(struct cache_set *c, struct list_head *list,
pr_debug("starting binary search, l %u r %u", l, r);

while (l + 1 < r) {
seq = list_entry(list->prev, struct journal_replay,
list)->j.seq;

m = (l + r) >> 1;
read_bucket(m);

if (read_bucket(m))
if (seq != list_entry(list->prev, struct journal_replay,
list)->j.seq)
l = m;
else
r = m;
Expand Down

0 comments on commit 5e20e8b

Please sign in to comment.