From 5219d3a49a81597f696559b94ac5001f3815c603 Mon Sep 17 00:00:00 2001 From: Kamil Skalski Date: Tue, 17 Mar 2026 07:45:17 +0800 Subject: [PATCH] fix(fs): align write size to 4096 to support all NVMEs --- fs/src/io_uring/file_creator.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/src/io_uring/file_creator.rs b/fs/src/io_uring/file_creator.rs index 0c7c7745abb..2119813915d 100644 --- a/fs/src/io_uring/file_creator.rs +++ b/fs/src/io_uring/file_creator.rs @@ -33,9 +33,10 @@ use { // 32 pages (Maximum Data Transfer Size) * page size (MPSMIN = Memory Page Size) = 128KiB. pub const DEFAULT_WRITE_SIZE: IoSize = 512 * 1024; -// Write size and file offset alignment for use with direct IO - all modern file systems -// effectively use this constant. -const DIRECT_IO_WRITE_LEN_ALIGNMENT: IoSize = 512; +// O_DIRECT requires I/O length, offset, and buffer address to be aligned to the device's logical +// block size: 512 bytes on most block devices, but 4096 on some NVMes. Use 4096 to avoid +// per-device detection at runtime. +const DIRECT_IO_WRITE_LEN_ALIGNMENT: IoSize = 4096; // Status flags (updatable on file-descriptor) used as default upon file creation. const DEFAULT_STATUS_FLAGS: libc::c_int = O_NOATIME;