mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: vhd: Enable O_DIRECT for fixed VHD images
Thread the direct flag from the disk open options through VhdDisk into the AlignedFile the workers run on, so a fixed VHD opened with direct=on issues O_DIRECT I/O instead of buffered I/O. Alignment is probed once on that AlignedFile and reused by the sync and io_uring workers. Advertise host topology from VhdDisk::topology by probing the underlying file. On a 4096 byte sector filesystem opened with O_DIRECT this reports logical_block_size 4096 to the guest, so the guest never issues 512 byte I/O that the host kernel would reject as misaligned. Falls back to the default topology with a warning when the probe fails. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
693987b9e2
commit
6633072a28
@@ -127,7 +127,7 @@ fn open_fixed_vhd(
|
||||
if io_uring_supported() {
|
||||
info!("Opening fixed VHD disk file with io_uring backend");
|
||||
return Ok(Box::new(
|
||||
VhdDisk::new(file, true).map_err(|e| e.with_path(options.path))?,
|
||||
VhdDisk::new(file, true, options.direct).map_err(|e| e.with_path(options.path))?,
|
||||
));
|
||||
}
|
||||
info!("io_uring runtime probe failed for fixed VHD, using synchronous backend");
|
||||
@@ -135,7 +135,7 @@ fn open_fixed_vhd(
|
||||
|
||||
info!("Opening fixed VHD disk file with synchronous backend");
|
||||
Ok(Box::new(
|
||||
VhdDisk::new(file, false).map_err(|e| e.with_path(options.path))?,
|
||||
VhdDisk::new(file, false, options.direct).map_err(|e| e.with_path(options.path))?,
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user