mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
block: Remove legacy DiskFile impl from RawFileDiskAio
Remove the old async_io::DiskFile trait implementation from RawFileDiskAio, now that the new disk_file trait hierarchy is fully implemented. Clean up unused imports: DiskFile and DiskFileResult from crate::async_io. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
@@ -14,9 +14,7 @@ use log::warn;
|
||||
use vmm_sys_util::aio;
|
||||
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::{DiskTopology, SECTOR_SIZE, disk_file, probe_sparse_support, query_device_size};
|
||||
|
||||
@@ -31,45 +29,6 @@ impl RawFileDiskAio {
|
||||
}
|
||||
}
|
||||
|
||||
impl DiskFile for RawFileDiskAio {
|
||||
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 = RawFileAsyncAio::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 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 RawFileDiskAio {
|
||||
fn logical_size(&self) -> BlockResult<u64> {
|
||||
query_device_size(&self.file)
|
||||
|
||||
@@ -32,7 +32,6 @@ use arch::layout::{APIC_START, IOAPIC_SIZE, IOAPIC_START};
|
||||
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
|
||||
use arch::{DeviceType, MmioDeviceInfo};
|
||||
use arch::{NumaNodes, layout};
|
||||
use block::async_io::DiskFile;
|
||||
use block::disk_file::DiskBackend;
|
||||
use block::error::BlockError;
|
||||
use block::fixed_vhd_sync::FixedVhdDiskSync;
|
||||
@@ -2760,7 +2759,7 @@ impl DeviceManager {
|
||||
}
|
||||
} else if !disk_cfg.disable_aio && self.aio_is_supported() {
|
||||
info!("Using asynchronous RAW disk file (aio)");
|
||||
DiskBackend::Legacy(Box::new(RawFileDiskAio::new(file)) as Box<dyn DiskFile>)
|
||||
DiskBackend::Next(Box::new(RawFileDiskAio::new(file)))
|
||||
} else {
|
||||
info!("Using synchronous RAW disk file");
|
||||
DiskBackend::Next(Box::new(RawFileDiskSync::new(file)))
|
||||
|
||||
Reference in New Issue
Block a user