diff --git a/block/src/raw_async.rs b/block/src/raw_async.rs index 153a0a94f..42309edda 100644 --- a/block/src/raw_async.rs +++ b/block/src/raw_async.rs @@ -121,6 +121,24 @@ impl disk_file::Resizable for RawFileDisk { impl disk_file::DiskFile for RawFileDisk {} +impl disk_file::AsyncDiskFile for RawFileDisk { + fn try_clone(&self) -> BlockResult> { + let file = self + .file + .try_clone() + .map_err(|e| BlockError::new(BlockErrorKind::Io, DiskFileError::Clone(e)))?; + Ok(Box::new(RawFileDisk { file })) + } + + 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)))?; + raw.alignment = + DiskTopology::probe(&self.file).map_or(SECTOR_SIZE, |t| t.logical_block_size); + Ok(Box::new(raw) as Box) + } +} + pub struct RawFileAsync { fd: RawFd, io_uring: IoUring,