]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/seastore: clamp block_size to laddr_t::UNIT_SIZE on small-LBA devices 69006/head
authorKefu Chai <k.chai@proxmox.com>
Wed, 20 May 2026 00:55:55 +0000 (08:55 +0800)
committerKefu Chai <k.chai@proxmox.com>
Wed, 20 May 2026 00:57:38 +0000 (08:57 +0800)
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 <k.chai@proxmox.com>
src/crimson/os/seastore/segment_manager/block.cc

index fcc1eced90969cb2e8a32fe4b8d4ccc2c2f6ed51..c7fd161627ffa7ea72c46b9fb3bf82eabac5dae6 100644 (file)
@@ -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<uint64_t>(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);