summaryrefslogtreecommitdiff
path: root/fs/bcachefs/journal_io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-12-14 22:47:42 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:48 +0300
commit1ba8a796b427d312aa68c2e04e00b42ec742883e (patch)
tree575f1dd06ce6c49e99a8746ee066f8c6efc146ec /fs/bcachefs/journal_io.c
parent14d7d61fac9c151a270c6ef6f969993eae9f1bbf (diff)
downloadlinux-1ba8a796b427d312aa68c2e04e00b42ec742883e.tar.xz
bcachefs: Recover from blacklisted journal entries
If it so happens that we crash while dirty, meaning we don't have the superblock clean section, and we erroneously mark a journal entry we wrote as blacklisted, we won't be able to recover. This patch fixes this by adding a fallback: if we've got no superblock clean section, and no non-ignored journal entries, we try the most recent ignored journal entry. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r--fs/bcachefs/journal_io.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index 854a0685db09..a54c06064647 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -1123,9 +1123,6 @@ int bch2_journal_read(struct bch_fs *c, u64 *blacklist_seq, u64 *start_seq)
/*
* Find most recent flush entry, and ignore newer non flush entries -
* those entries will be blacklisted:
- *
- *
- * XXX check for torn write on last journal entry
*/
genradix_for_each_reverse(&c->journal_entries, radix_iter, _i) {
int write = READ;
@@ -1139,13 +1136,13 @@ int bch2_journal_read(struct bch_fs *c, u64 *blacklist_seq, u64 *start_seq)
*blacklist_seq = *start_seq = le64_to_cpu(i->j.seq) + 1;
if (JSET_NO_FLUSH(&i->j)) {
- journal_replay_free(c, i);
+ i->ignore = true;
continue;
}
if (!last_write_torn && !i->csum_good) {
last_write_torn = true;
- journal_replay_free(c, i);
+ i->ignore = true;
continue;
}
@@ -1194,8 +1191,7 @@ int bch2_journal_read(struct bch_fs *c, u64 *blacklist_seq, u64 *start_seq)
if (bch2_journal_seq_is_blacklisted(c, seq, true)) {
fsck_err_on(!JSET_NO_FLUSH(&i->j), c,
"found blacklisted journal entry %llu", seq);
-
- journal_replay_free(c, i);
+ i->ignore = true;
}
}