]> git.karo-electronics.de Git - linux-beck.git/commitdiff
bcache: Fix an infinite loop in journal replay
authorKent Overstreet <kmo@daterainc.com>
Mon, 2 Jun 2014 22:39:44 +0000 (15:39 -0700)
committerKent Overstreet <kmo@daterainc.com>
Mon, 4 Aug 2014 22:23:03 +0000 (15:23 -0700)
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>
drivers/md/bcache/journal.c

index ead001c9bed8c52be18feaf7504f6ee8caf92d08..fe080ad0e55841e5c95bfcb3dcf3a0f1a703b76c 100644 (file)
@@ -190,9 +190,12 @@ int bch_journal_read(struct cache_set *c, struct list_head *list)
                        if (read_bucket(l))
                                goto bsearch;
 
-               if (list_empty(list))
+               /* no journal entries on this device? */
+               if (l == ca->sb.njournal_buckets)
                        continue;
 bsearch:
+               BUG_ON(list_empty(list));
+
                /* Binary search */
                m = l;
                r = find_next_bit(bitmap, ca->sb.njournal_buckets, l + 1);