mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: raw: Remove EOPNOTSUPP skip from test_write_zeroes
The WriteZeroesAt fallback means write_zeroes no longer fails on filesystems that lack fallocate support. The skip is now dead code. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
d7a7d73622
commit
028c99b39c
@@ -13,7 +13,7 @@
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
|
|
||||||
use crate::async_io::{AsyncIo, AsyncIoError};
|
use crate::async_io::AsyncIo;
|
||||||
|
|
||||||
fn next_completion(async_io: &mut dyn AsyncIo) -> (u64, i32) {
|
fn next_completion(async_io: &mut dyn AsyncIo) -> (u64, i32) {
|
||||||
let completion = async_io.next_completed_request().expect("No completion");
|
let completion = async_io.next_completed_request().expect("No completion");
|
||||||
@@ -67,8 +67,7 @@ pub fn test_punch_hole(async_io: &mut dyn AsyncIo, file: &mut File) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Tests writing zeroes to a 512 KB region inside a 4 MB file and verifying
|
/// Tests writing zeroes to a 512 KB region inside a 4 MB file and verifying
|
||||||
/// surrounding data is preserved. Gracefully skips when the filesystem does
|
/// surrounding data is preserved.
|
||||||
/// not support `FALLOC_FL_ZERO_RANGE`.
|
|
||||||
pub fn test_write_zeroes(async_io: &mut dyn AsyncIo, file: &mut File) {
|
pub fn test_write_zeroes(async_io: &mut dyn AsyncIo, file: &mut File) {
|
||||||
// Write 4MB of data
|
// Write 4MB of data
|
||||||
let data = vec![0xBB; 4 * 1024 * 1024];
|
let data = vec![0xBB; 4 * 1024 * 1024];
|
||||||
@@ -78,17 +77,7 @@ pub fn test_write_zeroes(async_io: &mut dyn AsyncIo, file: &mut File) {
|
|||||||
// Write zeros in the middle (512KB at offset 2MB)
|
// Write zeros in the middle (512KB at offset 2MB)
|
||||||
let offset = 2 * 1024 * 1024;
|
let offset = 2 * 1024 * 1024;
|
||||||
let length = 512 * 1024;
|
let length = 512 * 1024;
|
||||||
let write_zeroes_result = async_io.write_zeroes(offset, length, 2);
|
async_io.write_zeroes(offset, length, 2).unwrap();
|
||||||
|
|
||||||
// FALLOC_FL_ZERO_RANGE might not be supported on all filesystems (e.g., tmpfs)
|
|
||||||
// If it fails with ENOTSUP, skip the test
|
|
||||||
if let Err(AsyncIoError::WriteZeroes(ref e)) = write_zeroes_result
|
|
||||||
&& (e.raw_os_error() == Some(libc::EOPNOTSUPP) || e.raw_os_error() == Some(libc::ENOTSUP))
|
|
||||||
{
|
|
||||||
eprintln!("Skipping test_write_zeroes: filesystem doesn't support FALLOC_FL_ZERO_RANGE");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
write_zeroes_result.unwrap();
|
|
||||||
|
|
||||||
// Check completion
|
// Check completion
|
||||||
let (user_data, result) = next_completion(async_io);
|
let (user_data, result) = next_completion(async_io);
|
||||||
|
|||||||
Reference in New Issue
Block a user