Skip to content

Commit c5ed7ce

Browse files
committed
crimson/seastore: use DMA alignment for block size instead of stat
Before this fix, BlockSegmentManager used stat.block_size (typically 512 bytes from file_stat()) as the alignment requirement for writes. However, Seastar's DMA engine requires alignment to disk_write_dma_alignment() (typically 4096 bytes, the logical block size) for performant writes. This mismatch caused failures in BlockSegmentManager::segment_write(): 1. Crimson believed block_size was 512 bytes (from file_stat()) 2. Crimson prepared 512-byte aligned buffers for writing 3. Seastar's internal::sanitize_iovecs() trimmed the unaligned portions based on the actual 4096-byte DMA alignment requirement 4. This left an empty buffer (512 bytes trimmed from 512-byte buffer) 5. The write operation returned 0 bytes written 6. The assertion 'written != len' failed in do_writev() The fix queries the actual DMA alignment requirement from Seastar via file.disk_write_dma_alignment() and uses that as block_size throughout the segment manager. This ensures all writes are properly aligned for Seastar's DMA engine. Signed-off-by: Kefu Chai <[email protected]>
1 parent e59cb2c commit c5ed7ce

File tree

1 file changed

+3
-0
lines changed
  • src/crimson/os/seastore/segment_manager

1 file changed

+3
-0
lines changed

src/crimson/os/seastore/segment_manager/block.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ open_device_ret open_device(
267267
).then([stat, &path, FNAME](auto file) mutable {
268268
return file.size().then([stat, file, &path, FNAME](auto size) mutable {
269269
stat.size = size;
270+
// Use Seastar's DMA alignment requirement instead of stat's block_size
271+
// to ensure writes are properly aligned for optimal performance
272+
stat.block_size = file.disk_write_dma_alignment();
270273
INFO("path={} successful, size=0x{:x}, block_size=0x{:x}",
271274
path, stat.size, stat.block_size);
272275
return std::make_pair(file, stat);

0 commit comments

Comments
 (0)