Skip to content

Commit 783cc8b

Browse files
russell-islamliuw
authored andcommitted
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>
1 parent 6df7cda commit 783cc8b

2 files changed

Lines changed: 2 additions & 44 deletions

File tree

block/src/raw_async_aio.rs

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ use log::warn;
1414
use vmm_sys_util::aio;
1515
use vmm_sys_util::eventfd::EventFd;
1616

17-
use crate::async_io::{
18-
AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFile, DiskFileError, DiskFileResult,
19-
};
17+
use crate::async_io::{AsyncIo, AsyncIoError, AsyncIoResult, BorrowedDiskFd, DiskFileError};
2018
use crate::error::{BlockError, BlockErrorKind, BlockResult};
2119
use crate::{DiskTopology, SECTOR_SIZE, disk_file, probe_sparse_support, query_device_size};
2220

@@ -31,45 +29,6 @@ impl RawFileDiskAio {
3129
}
3230
}
3331

34-
impl DiskFile for RawFileDiskAio {
35-
fn logical_size(&mut self) -> DiskFileResult<u64> {
36-
Ok(query_device_size(&self.file)
37-
.map_err(DiskFileError::Size)?
38-
.0)
39-
}
40-
41-
fn physical_size(&mut self) -> DiskFileResult<u64> {
42-
Ok(query_device_size(&self.file)
43-
.map_err(DiskFileError::Size)?
44-
.1)
45-
}
46-
47-
fn new_async_io(&self, ring_depth: u32) -> DiskFileResult<Box<dyn AsyncIo>> {
48-
let mut raw = RawFileAsyncAio::new(self.file.as_raw_fd(), ring_depth)
49-
.map_err(DiskFileError::NewAsyncIo)?;
50-
raw.alignment =
51-
DiskTopology::probe(&self.file).map_or(SECTOR_SIZE, |t| t.logical_block_size);
52-
Ok(Box::new(raw) as Box<dyn AsyncIo>)
53-
}
54-
55-
fn topology(&mut self) -> DiskTopology {
56-
if let Ok(topology) = DiskTopology::probe(&self.file) {
57-
topology
58-
} else {
59-
warn!("Unable to get device topology. Using default topology");
60-
DiskTopology::default()
61-
}
62-
}
63-
64-
fn supports_sparse_operations(&self) -> bool {
65-
probe_sparse_support(&self.file)
66-
}
67-
68-
fn fd(&mut self) -> BorrowedDiskFd<'_> {
69-
BorrowedDiskFd::new(self.file.as_raw_fd())
70-
}
71-
}
72-
7332
impl disk_file::DiskSize for RawFileDiskAio {
7433
fn logical_size(&self) -> BlockResult<u64> {
7534
query_device_size(&self.file)

vmm/src/device_manager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use arch::layout::{APIC_START, IOAPIC_SIZE, IOAPIC_START};
3232
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
3333
use arch::{DeviceType, MmioDeviceInfo};
3434
use arch::{NumaNodes, layout};
35-
use block::async_io::DiskFile;
3635
use block::disk_file::DiskBackend;
3736
use block::error::BlockError;
3837
use block::fixed_vhd_sync::FixedVhdDiskSync;
@@ -2760,7 +2759,7 @@ impl DeviceManager {
27602759
}
27612760
} else if !disk_cfg.disable_aio && self.aio_is_supported() {
27622761
info!("Using asynchronous RAW disk file (aio)");
2763-
DiskBackend::Legacy(Box::new(RawFileDiskAio::new(file)) as Box<dyn DiskFile>)
2762+
DiskBackend::Next(Box::new(RawFileDiskAio::new(file)))
27642763
} else {
27652764
info!("Using synchronous RAW disk file");
27662765
DiskBackend::Next(Box::new(RawFileDiskSync::new(file)))

0 commit comments

Comments
 (0)