mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: qcow: Test sub sector O_DIRECT read
Verify that a 512 byte read from an allocated cluster succeeds with O_DIRECT. This exercises the synchronous fallback path in resolve_read() that is taken when alignment is nonzero. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
dd79b1899d
commit
e67195ce48
@@ -1032,4 +1032,25 @@ mod unit_tests {
|
||||
let async_io = disk.new_async_io(1).unwrap();
|
||||
assert!(async_io.alignment() >= SECTOR_SIZE);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_qcow_async_sub_sector_read_with_direct_io() {
|
||||
let temp_file = TempFile::new().unwrap();
|
||||
let disk = match try_create_direct_io_disk(&temp_file, 100 * 1024 * 1024) {
|
||||
Some(d) => d,
|
||||
None => {
|
||||
eprintln!("skipping: O_DIRECT not supported on this filesystem");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let pattern = vec![0xAB; 65536];
|
||||
async_write(&disk, 0, &pattern);
|
||||
|
||||
let buf = async_read(&disk, 0, 512);
|
||||
assert!(
|
||||
buf.iter().all(|&b| b == 0xAB),
|
||||
"sub-sector O_DIRECT read should return written data"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user