]> git.karo-electronics.de Git - linux-beck.git/commitdiff
bcache: Fix a journalling reclaim after recovery bug
authorKent Overstreet <kmo@daterainc.com>
Thu, 13 Mar 2014 20:44:21 +0000 (13:44 -0700)
committerKent Overstreet <kmo@daterainc.com>
Tue, 18 Mar 2014 19:21:48 +0000 (12:21 -0700)
On recovery we weren't correctly keeping track of what journal buckets had open
journal entries, thus it was possible for them to be overwritten until we'd
written all new journal entries.

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
drivers/md/bcache/journal.c

index 97e6a92da9999f1b25e8c8fb6a30315932b17584..4152a911989625179c0ece0ac6eb5a048d559774 100644 (file)
@@ -237,8 +237,14 @@ bsearch:
                for (i = 0; i < ca->sb.njournal_buckets; i++)
                        if (ja->seq[i] > seq) {
                                seq = ja->seq[i];
-                               ja->cur_idx = ja->discard_idx =
-                                       ja->last_idx = i;
+                               /*
+                                * When journal_reclaim() goes to allocate for
+                                * the first time, it'll use the bucket after
+                                * ja->cur_idx
+                                */
+                               ja->cur_idx = i;
+                               ja->last_idx = ja->discard_idx = (i + 1) %
+                                       ca->sb.njournal_buckets;
 
                        }
        }