Skip to content

Commit 62264cb

Browse files
russell-islamliuw
authored andcommitted
block: Implement Resizable trait for RawFileDiskAio
Add disk_file::Resizable trait implementation for RawFileDiskAio. Calls file.set_len(size) and wraps the I/O error in BlockError on failure. Signed-off-by: Muminul Islam <muislam@microsoft.com>
1 parent b7cf873 commit 62264cb

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

block/src/raw_async_aio.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ impl disk_file::SparseCapable for RawFileDiskAio {
107107
}
108108
}
109109

110+
impl disk_file::Resizable for RawFileDiskAio {
111+
fn resize(&mut self, size: u64) -> BlockResult<()> {
112+
self.file
113+
.set_len(size)
114+
.map_err(|e| BlockError::new(BlockErrorKind::Io, DiskFileError::ResizeError(e)))
115+
}
116+
}
117+
110118
pub struct RawFileAsyncAio {
111119
fd: RawFd,
112120
ctx: aio::IoContext,

0 commit comments

Comments
 (0)