summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-11-20 16:44:17 -0900
committerKent Overstreet <kent.overstreet@gmail.com>2016-11-20 16:48:48 -0900
commitdbb116a20f1db109ae51f59eae9939168eb56b35 (patch)
tree7c5d3e5a0c49446c167887dd584e59a2241e987b
parent5145bfd0b97aa00cb9a0f67d7473300f915aeeb8 (diff)
bcache: fix a bug with the journal seq blacklist machinery
-rw-r--r--drivers/md/bcache/journal.c6
-rw-r--r--drivers/md/bcache/super.c11
2 files changed, 16 insertions, 1 deletions
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 6c3cc983dd79..a1b08e1c3ef1 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -331,7 +331,11 @@ int bch_journal_seq_should_ignore(struct cache_set *c, u64 seq, struct btree *b)
if (seq <= j->seq)
goto out;
- cache_set_inconsistent_on(seq > j->seq + 2, c,
+ /*
+ * Decrease this back to j->seq + 2 when we next rev the on disk format:
+ * increasing it temporarily to work around bug in old kernels
+ */
+ cache_set_inconsistent_on(seq > j->seq + 4, c,
"bset journal seq too far in the future: %llu > %llu",
seq, j->seq);
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 69b44f81495c..e790503b9a92 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1344,6 +1344,17 @@ static const char *run_cache_set(struct cache_set *c)
bch_verbose(c, "journal replay done");
+ /*
+ * Write a new journal entry _before_ we start journalling new
+ * data - otherwise, we could end up with btree node bsets with
+ * journal seqs arbitrarily far in the future vs. the most
+ * recently written journal entry on disk, if we crash before
+ * writing the next journal entry:
+ */
+ err = "error writing journal entry";
+ if (bch_journal_meta(&c->journal))
+ goto err;
+
bch_verbose(c, "starting fs gc:");
err = "error in fs gc";
ret = bch_gc_inode_nlinks(c);