block: raw: Return BlockResult from RawFileAsync::new

Change RawFileAsync::new() from std::io::Result to BlockResult,
aligning it with RawFileAsyncAio::new(). Each fallible call inside
the constructor now maps to BlockErrorKind::Io explicitly.

FixedVhdAsync::new() follows the same change since its only
fallible operation is constructing a RawFileAsync. The intermediate
DiskFileError::NewAsyncIo wrapping in both new_async_io() call
sites is no longer needed and is removed.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-04-17 11:07:21 +02:00
committed by Rob Bradford
parent cd9fc52472
commit 7294ca99cf
2 changed files with 16 additions and 13 deletions

View File

@@ -75,12 +75,11 @@ impl disk_file::AsyncDiskFile for FixedVhdDiskAsync {
.0
.logical_size()
.map_err(|e| BlockError::new(BlockErrorKind::Io, e))?;
Ok(Box::new(
FixedVhdAsync::new(self.0.as_raw_fd(), ring_depth, size).map_err(|e| {
BlockError::new(BlockErrorKind::Io, DiskFileError::NewAsyncIo(e))
.with_op(ErrorOp::Open)
})?,
))
Ok(Box::new(FixedVhdAsync::new(
self.0.as_raw_fd(),
ring_depth,
size,
)?))
}
}
@@ -90,7 +89,7 @@ pub struct FixedVhdAsync {
}
impl FixedVhdAsync {
pub fn new(fd: RawFd, ring_depth: u32, size: u64) -> std::io::Result<Self> {
pub fn new(fd: RawFd, ring_depth: u32, size: u64) -> BlockResult<Self> {
let raw_file_async = RawFileAsync::new(fd, ring_depth)?;
Ok(FixedVhdAsync {