diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-07-12 01:42:14 -0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-07-12 03:22:48 -0400 |
commit | faa5673617656ee58369a3cfe4a312cfcdc59c81 (patch) | |
tree | 856e124ab4abab846bea0cdca7e41581eddf061f /drivers/md | |
parent | 5caa52afc5abd1396e4af720469abb5843a71eb8 (diff) |
bcache: Journal replay fix
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>
Cc: linux-stable <stable@vger.kernel.org> # >= v3.10
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/bcache/journal.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index 4b250667bb7f..ba95ab84b2be 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c | |||
@@ -184,9 +184,14 @@ bsearch: | |||
184 | pr_debug("starting binary search, l %u r %u", l, r); | 184 | pr_debug("starting binary search, l %u r %u", l, r); |
185 | 185 | ||
186 | while (l + 1 < r) { | 186 | while (l + 1 < r) { |
187 | seq = list_entry(list->prev, struct journal_replay, | ||
188 | list)->j.seq; | ||
189 | |||
187 | m = (l + r) >> 1; | 190 | m = (l + r) >> 1; |
191 | read_bucket(m); | ||
188 | 192 | ||
189 | if (read_bucket(m)) | 193 | if (seq != list_entry(list->prev, struct journal_replay, |
194 | list)->j.seq) | ||
190 | l = m; | 195 | l = m; |
191 | else | 196 | else |
192 | r = m; | 197 | r = m; |