diff --git a/block/src/fixed_vhd_async.rs b/block/src/fixed_vhd_async.rs index e8b28c44c..f1494b4b9 100644 --- a/block/src/fixed_vhd_async.rs +++ b/block/src/fixed_vhd_async.rs @@ -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 { + pub fn new(fd: RawFd, ring_depth: u32, size: u64) -> BlockResult { let raw_file_async = RawFileAsync::new(fd, ring_depth)?; Ok(FixedVhdAsync { diff --git a/block/src/raw_async.rs b/block/src/raw_async.rs index 7fa3208f4..b2dbaa565 100644 --- a/block/src/raw_async.rs +++ b/block/src/raw_async.rs @@ -108,8 +108,7 @@ impl disk_file::AsyncDiskFile for RawFileDisk { } fn new_async_io(&self, ring_depth: u32) -> BlockResult> { - let mut raw = RawFileAsync::new(self.file.as_raw_fd(), ring_depth) - .map_err(|e| BlockError::new(BlockErrorKind::Io, DiskFileError::NewAsyncIo(e)))?; + let mut raw = RawFileAsync::new(self.file.as_raw_fd(), ring_depth)?; raw.alignment = DiskTopology::probe(&self.file).map_or(SECTOR_SIZE, |t| t.logical_block_size); Ok(Box::new(raw) as Box) @@ -124,13 +123,18 @@ pub struct RawFileAsync { } impl RawFileAsync { - pub fn new(fd: RawFd, ring_depth: u32) -> std::io::Result { - let io_uring = IoUring::new(ring_depth)?; - let eventfd = EventFd::new(libc::EFD_NONBLOCK)?; + pub fn new(fd: RawFd, ring_depth: u32) -> BlockResult { + let io_uring = + IoUring::new(ring_depth).map_err(|e| BlockError::new(BlockErrorKind::Io, e))?; + let eventfd = + EventFd::new(libc::EFD_NONBLOCK).map_err(|e| BlockError::new(BlockErrorKind::Io, e))?; // Register the io_uring eventfd that will notify when something in // the completion queue is ready. - io_uring.submitter().register_eventfd(eventfd.as_raw_fd())?; + io_uring + .submitter() + .register_eventfd(eventfd.as_raw_fd()) + .map_err(|e| BlockError::new(BlockErrorKind::Io, e))?; Ok(RawFileAsync { fd,