mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Switch RawFileDisk to DiskBackend::Next
Update device_manager.rs to construct DiskBackend::Next instead of DiskBackend::Legacy for the io_uring raw backend. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
@@ -11,9 +11,7 @@ use libc::{FALLOC_FL_KEEP_SIZE, FALLOC_FL_PUNCH_HOLE, FALLOC_FL_ZERO_RANGE};
|
||||
use log::warn;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
use crate::async_io::{
|
||||
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
|
||||
};
|
||||
use crate::async_io::{AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFileError};
|
||||
use crate::error::{BlockError, BlockErrorKind, BlockResult};
|
||||
use crate::{
|
||||
BatchRequest, DiskTopology, RequestType, SECTOR_SIZE, disk_file, probe_sparse_support,
|
||||
@@ -31,49 +29,6 @@ impl RawFileDisk {
|
||||
}
|
||||
}
|
||||
|
||||
impl DiskFile for RawFileDisk {
|
||||
fn logical_size(&mut self) -> DiskFileResult<u64> {
|
||||
Ok(query_device_size(&self.file)
|
||||
.map_err(DiskFileError::Size)?
|
||||
.0)
|
||||
}
|
||||
|
||||
fn physical_size(&mut self) -> DiskFileResult<u64> {
|
||||
Ok(query_device_size(&self.file)
|
||||
.map_err(DiskFileError::Size)?
|
||||
.1)
|
||||
}
|
||||
|
||||
fn new_async_io(&self, ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
|
||||
let mut raw = RawFileAsync::new(self.file.as_raw_fd(), ring_depth)
|
||||
.map_err(DiskFileError::NewAsyncIo)?;
|
||||
raw.alignment =
|
||||
DiskTopology::probe(&self.file).map_or(SECTOR_SIZE, |t| t.logical_block_size);
|
||||
Ok(Box::new(raw) as Box<dyn AsyncIo>)
|
||||
}
|
||||
|
||||
fn topology(&mut self) -> DiskTopology {
|
||||
if let Ok(topology) = DiskTopology::probe(&self.file) {
|
||||
topology
|
||||
} else {
|
||||
warn!("Unable to get device topology. Using default topology");
|
||||
DiskTopology::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn resize(&mut self, size: u64) -> DiskFileResult<()> {
|
||||
self.file.set_len(size).map_err(DiskFileError::ResizeError)
|
||||
}
|
||||
|
||||
fn supports_sparse_operations(&self) -> bool {
|
||||
probe_sparse_support(&self.file)
|
||||
}
|
||||
|
||||
fn fd(&mut self) -> BorrowedDiskFd<'_> {
|
||||
BorrowedDiskFd::new(self.file.as_raw_fd())
|
||||
}
|
||||
}
|
||||
|
||||
impl disk_file::DiskSize for RawFileDisk {
|
||||
fn logical_size(&self) -> BlockResult<u64> {
|
||||
query_device_size(&self.file)
|
||||
|
||||
@@ -2756,9 +2756,7 @@ impl DeviceManager {
|
||||
unreachable!("Checked in if statement above");
|
||||
#[cfg(feature = "io_uring")]
|
||||
{
|
||||
DiskBackend::Legacy(
|
||||
Box::new(RawFileDisk::new(file)) as Box<dyn DiskFile>
|
||||
)
|
||||
DiskBackend::Next(Box::new(RawFileDisk::new(file)))
|
||||
}
|
||||
} else if !disk_cfg.disable_aio && self.aio_is_supported() {
|
||||
info!("Using asynchronous RAW disk file (aio)");
|
||||
|
||||
Reference in New Issue
Block a user