From 89132d0fcdb19845f3c11e35cf13e494bc2cd590 Mon Sep 17 00:00:00 2001 From: Changwei Ye Date: Tue, 1 Sep 2026 14:57:48 +0800 Subject: [PATCH] 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. --- src/blockstore/blockstore_disk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blockstore/blockstore_disk.cpp b/src/blockstore/blockstore_disk.cpp index 447ac610..6b8b3f5f 100644 --- a/src/blockstore/blockstore_disk.cpp +++ b/src/blockstore/blockstore_disk.cpp @@ -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"); } -- 2.47.3