block: raw: Handle O_DIRECT in the raw async workers

The raw sync, io_uring and AIO workers now own an AlignedFile and use
it for the O_DIRECT alignment value and for the unaligned fallback.
Aligned operations keep the fast preadv and pwritev iovec path straight
to the kernel. When the offset or an iovec base or length is not a
multiple of the probed alignment, the worker gathers the iovecs into
one contiguous host buffer and runs a synchronous RMW through
AlignedFile, then scatters the result back into guest memory.

RawDisk constructs the AlignedFile from the disk file and the direct
flag and passes it into each worker, so alignment is probed once at
open time. The fixed VHD workers are threaded through the same
AlignedFile based constructors using a non-direct AlignedFile to
preserve current behavior.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-06-19 21:48:33 +02:00
committed by Rob Bradford
parent 516f4e447d
commit 2359003001
12 changed files with 304 additions and 148 deletions

View File

@@ -28,7 +28,7 @@ use crate::util::{
pub fn micro_bench_aio_drain(control: &PerformanceTestControl) -> f64 {
let num_ops = control.num_ops.expect("num_ops required") as usize;
let tmp = util::sized_tempfile(num_ops);
let disk = RawDisk::new(tmp.as_file().try_clone().unwrap(), RawBackend::Aio);
let disk = RawDisk::new(tmp.as_file().try_clone().unwrap(), RawBackend::Aio, false);
let mut aio = disk
.create_async_io(num_ops as u32)
.expect("failed to create AIO context");