Compare commits

...

1 Commits

Author SHA1 Message Date
89132d0fcd Fix size check for journal_offset when sharing meta device
When journal_device and meta_device share the same device, but they
are separate from data_device (e.g., Data on HDD, while Meta and Journal
are on a shared NVMe SSD), the boundary check for journal_offset incorrectly
compared the offset against data_device_size.

This could lead to out-of-bounds I/O on the NVMe SSD if the configured
journal offset was larger than the SSD but smaller than the HDD, or it
could cause false-positive startup failures if the HDD was smaller than
the NVMe SSD.

This fix ensures that journal_offset is appropriately checked against
meta_device_size when it is available (i.e., when meta and data are on
different devices), and falls back to data_device_size only when all
three share the same physical device.
2026-09-01 15:03:25 +08:00

View File

@@ -473,7 +473,7 @@ void blockstore_disk_t::open_journal()
journal_fd = meta_fd;
journal_device_sect = meta_device_sect;
journal_device_size = 0;
if (journal_offset >= data_device_size)
if (journal_offset >= (meta_device_size > 0 ? meta_device_size : data_device_size))
{
throw std::runtime_error("journal_offset exceeds device size");
}