From: Kefu Chai Date: Wed, 20 May 2026 00:55:55 +0000 (+0800) Subject: crimson/seastore: clamp block_size to laddr_t::UNIT_SIZE on small-LBA devices X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a47da78c0dcd18dbe3ae67f8030d43f46aa5b7cd;p=ceph.git crimson/seastore: clamp block_size to laddr_t::UNIT_SIZE on small-LBA devices Seastar's file::disk_write_dma_alignment() faithfully reports what the kernel exposes for the underlying device. On block devices in 512-byte LBA mode (the factory default for many NVMe SSDs), it correctly returns 512. SeaStore's internal addressing, however, operates at a 4 KiB page granularity defined by laddr_t::UNIT_SIZE, and SeaStore::_mount() asserts that block_size >= UNIT_SIZE. As a result, ceph-osd-crimson --mkfs --osd-objectstore seastore aborts on any device shipped in 512-LBA mode: seastore.cc:344 ceph_assert(block_size >= laddr_t::UNIT_SIZE) seastore requires a device block size of at least 4096 bytes, but the primary device at '/var/lib/ceph/osd/ceph-N/block' reports block_size=512 The reported alignment is not wrong; it is the minimum Linux enforces for O_DIRECT on that device, so users with optimization in mind can override it through io_properties.yaml. But SeaStore can run correctly on 512-LBA devices as long as it issues only 4 KiB-aligned I/O (which is also 512-aligned, so the device is happy). Clamp the captured block_size to laddr_t::UNIT_SIZE so SeaStore can host an OSD on 512-LBA storage without operator intervention, while still honoring larger device-reported alignments when present. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/os/seastore/segment_manager/block.cc b/src/crimson/os/seastore/segment_manager/block.cc index fcc1eced9096..c7fd161627ff 100644 --- a/src/crimson/os/seastore/segment_manager/block.cc +++ b/src/crimson/os/seastore/segment_manager/block.cc @@ -305,9 +305,11 @@ open_device_ret open_device( ).then([stat, &path, FNAME](auto file) mutable { return file.size().then([stat, file, &path, FNAME](auto size) mutable { stat.size = size; - // Use Seastar's DMA alignment requirement instead of stat's block_size - // to ensure writes are properly aligned for optimal performance - stat.block_size = file.disk_write_dma_alignment(); + // Use Seastar's DMA alignment for optimal I/O alignment; clamp to + // laddr_t::UNIT_SIZE since SeaStore operates at 4 KiB granularity + // and rejects smaller device-reported block sizes. + stat.block_size = std::max(file.disk_write_dma_alignment(), + laddr_t::UNIT_SIZE); INFO("path={} successful, size=0x{:x}, block_size=0x{:x}", path, stat.size, stat.block_size); return std::make_pair(file, stat);