bcachefs: Improve journal entry validate code
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 13 Nov 2020 19:39:43 +0000 (14:39 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:47 +0000 (17:08 -0400)
commit35ef6df5ca67347c606e418eb3ef71870ea97ba7
tree43b7036f7a7ed6a9f08f6efb1bbbb18a407e2916
parenteb8e6e9ccbb4ba37c04a7cff032975b4df7d63c7
bcachefs: Improve journal entry validate code

Previously, the journal entry read code was changed so that if we got a
journal entry that failed validation, we'd try to use it, preferring to
use a good version from another device if available.

But this left a bug where if an earlier validation check (say, checksum)
failed, the later checks (for last_seq) wouldn't run and we'd end up
using a journal entry with a garbage last_seq field. This fixes that so
that the later validation checks run and if necessary change those
fields to something sensible.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal_io.c