You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix sanity_check to handle first boot and distinguish header corruption
On first boot (format_devices path), all devices have invalid headers on
disk when PhysicalDev is constructed — before write_super_block is called.
The original code blindly memcmp'd header vs footer on garbage data,
causing a crash on HDD devices where mirror_super_block=1.
In load_devices, a device with an invalid header goes to pdevs_to_format
and then format_single_device. At that point m_first_blk_hdr (and thus
m_pdev_info.system_uuid) is already populated from other valid devices in
the cluster. So if the footer on disk is valid and its system_uuid matches,
it means the footer survived but the header was corrupted — not a fresh
device. If the footer uuid does not match (or footer is invalid), it is
leftover/garbage data and safe to treat as first boot.
New logic:
- Header valid: compare header and footer as before
- Header invalid, footer valid + uuid matches cluster: header corruption, assert
- Otherwise: first boot / leftover data, skip validation
0 commit comments