Commit 6b708de64adb6dc8319e7aeac922b46904fbeeec

Authored by Kent Overstreet
1 parent 913dc33fb2

bcache: Fix an infinite loop in journal replay

When running with multiple cache devices, if one of the devices has a completely
empty journal but we'd already found some journal entries on a previosu device
we'd go into an infinite loop.

Change-Id: I1dcdc0d738192746de28f40e8b08825b0dea5e2b
Signed-off-by: Kent Overstreet <kmo@daterainc.com>

Showing 1 changed file with 4 additions and 1 deletions Side-by-side Diff

drivers/md/bcache/journal.c
... ... @@ -190,9 +190,12 @@
190 190 if (read_bucket(l))
191 191 goto bsearch;
192 192  
193   - if (list_empty(list))
  193 + /* no journal entries on this device? */
  194 + if (l == ca->sb.njournal_buckets)
194 195 continue;
195 196 bsearch:
  197 + BUG_ON(list_empty(list));
  198 +
196 199 /* Binary search */
197 200 m = l;
198 201 r = find_next_bit(bitmap, ca->sb.njournal_buckets, l + 1);