diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-11-19 21:45:00 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-11-19 21:45:00 -0500 |
commit | 7e0fbb0144960197a53f188908afdf85cf15f446 (patch) | |
tree | bdb6ae3520d63b44662209faf3325799f98ef8df | |
parent | 505230a110904050c2b9ae1d57afef6678c4595c (diff) |
Update bcachefs sources to ed88ebf18c bcachefs: Handle last journal write being torn
-rw-r--r-- | .bcachefs_revision | 2 | ||||
-rw-r--r-- | libbcachefs/journal_io.c | 39 |
2 files changed, 26 insertions, 15 deletions
diff --git a/.bcachefs_revision b/.bcachefs_revision index 8bdba8c8..a58de04b 100644 --- a/.bcachefs_revision +++ b/.bcachefs_revision @@ -1 +1 @@ -586e7c5498345c048985f6864f07ce36adde48be +ed88ebf18cd1ef0a3439ebfdf0059d37bb4d4249 diff --git a/libbcachefs/journal_io.c b/libbcachefs/journal_io.c index 01150635..8c86bf06 100644 --- a/libbcachefs/journal_io.c +++ b/libbcachefs/journal_io.c @@ -1107,7 +1107,7 @@ int bch2_journal_read(struct bch_fs *c, u64 *blacklist_seq, u64 *start_seq) struct bch_dev *ca; unsigned iter; struct printbuf buf = PRINTBUF; - bool degraded = false; + bool degraded = false, last_write_torn = false; u64 seq, last_seq = 0; int ret = 0; @@ -1143,8 +1143,13 @@ 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; + i = *_i; if (!i || i->ignore) @@ -1153,21 +1158,27 @@ int bch2_journal_read(struct bch_fs *c, u64 *blacklist_seq, u64 *start_seq) if (!*start_seq) *blacklist_seq = *start_seq = le64_to_cpu(i->j.seq) + 1; - if (!JSET_NO_FLUSH(&i->j)) { - int write = READ; - if (journal_entry_err_on(le64_to_cpu(i->j.last_seq) > le64_to_cpu(i->j.seq), - c, &i->j, NULL, - "invalid journal entry: last_seq > seq (%llu > %llu)", - le64_to_cpu(i->j.last_seq), - le64_to_cpu(i->j.seq))) - i->j.last_seq = i->j.seq; - - last_seq = le64_to_cpu(i->j.last_seq); - *blacklist_seq = le64_to_cpu(i->j.seq) + 1; - break; + if (JSET_NO_FLUSH(&i->j)) { + journal_replay_free(c, i); + continue; } - journal_replay_free(c, i); + if (!last_write_torn && !i->csum_good) { + last_write_torn = true; + journal_replay_free(c, i); + continue; + } + + if (journal_entry_err_on(le64_to_cpu(i->j.last_seq) > le64_to_cpu(i->j.seq), + c, &i->j, NULL, + "invalid journal entry: last_seq > seq (%llu > %llu)", + le64_to_cpu(i->j.last_seq), + le64_to_cpu(i->j.seq))) + i->j.last_seq = i->j.seq; + + last_seq = le64_to_cpu(i->j.last_seq); + *blacklist_seq = le64_to_cpu(i->j.seq) + 1; + break; } if (!*start_seq) { |