diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-03-09 00:10:08 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-03-14 04:22:26 +0300 |
commit | c42006458b4239b7eb50f33af523b67c7a55e42e (patch) | |
tree | d1b1f90ddd3b531cb2330a23acdb1e8410089908 /fs | |
parent | 5e105fb806c622cd8b3da0031e74367a3b8a326b (diff) | |
download | linux-c42006458b4239b7eb50f33af523b67c7a55e42e.tar.xz |
bcachefs: Check for writing superblocks with nonsense member seq fields
We're seeing some unmountable filesystems due to split brain detection
going awry; it seems we somehow wrote out superblocks where we updated
the superblock seq without updating any member seq fields.
A given device's superblock should always have the main seq equal to
it's member seq field, so this is easy to check for.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/super-io.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index 38a5073202c5..010daebf987b 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -470,6 +470,14 @@ static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out, return ret; } + if (rw == WRITE && + bch2_sb_member_get(sb, sb->dev_idx).seq != sb->seq) { + prt_printf(out, "Invalid superblock: member seq %llu != sb seq %llu", + le64_to_cpu(bch2_sb_member_get(sb, sb->dev_idx).seq), + le64_to_cpu(sb->seq)); + return -BCH_ERR_invalid_sb_members_missing; + } + return 0; } |