Skip to content

Commit c420064

Browse files
author
Kent Overstreet
committed
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 <[email protected]>
1 parent 5e105fb commit c420064

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/bcachefs/super-io.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,14 @@ static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out,
470470
return ret;
471471
}
472472

473+
if (rw == WRITE &&
474+
bch2_sb_member_get(sb, sb->dev_idx).seq != sb->seq) {
475+
prt_printf(out, "Invalid superblock: member seq %llu != sb seq %llu",
476+
le64_to_cpu(bch2_sb_member_get(sb, sb->dev_idx).seq),
477+
le64_to_cpu(sb->seq));
478+
return -BCH_ERR_invalid_sb_members_missing;
479+
}
480+
473481
return 0;
474482
}
475483

0 commit comments

Comments
 (0)