block: Remove redundant BlockBackend trait

BlockBackend predated the disk_file trait family and only carried
logical_size and physical_size, which the disk backends expose
through the disk_file traits DiskSize and PhysicalSize.

It added no polymorphism while its Read, Write and Seek supertraits
forced an unused cursor. Dropping the trait removes the dead code
it was keeping alive.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-06-23 17:19:52 +02:00
committed by Bo Chen
parent 17cc156ccb
commit 755d42eec0
6 changed files with 10 additions and 87 deletions

View File

@@ -7,14 +7,13 @@ use std::io::{self, Read, Seek, SeekFrom, Write};
use std::os::fd::{AsFd, BorrowedFd};
use std::os::unix::fs::FileExt;
use std::os::unix::io::{AsRawFd, RawFd};
use std::result;
use vmm_sys_util::file_traits::FileSync;
use vmm_sys_util::seek_hole::SeekHole;
use vmm_sys_util::write_zeroes::{PunchHole, WriteZeroesAt};
use crate::aligned_buffer::AlignedBuffer;
use crate::{BlockBackend, SECTOR_SIZE, probe_direct_alignment, query_device_size};
use crate::{SECTOR_SIZE, probe_direct_alignment, query_device_size};
/// True when `buf_ptr`/`len`/`offset` already satisfy `alignment`
/// (`alignment == 0` means no O_DIRECT, so everything is "aligned").
@@ -225,20 +224,6 @@ impl SeekHole for AlignedFile {
}
}
impl BlockBackend for AlignedFile {
fn logical_size(&self) -> result::Result<u64, crate::Error> {
Ok(query_device_size(&self.file)
.map_err(crate::Error::RawFileError)?
.0)
}
fn physical_size(&self) -> result::Result<u64, crate::Error> {
Ok(query_device_size(&self.file)
.map_err(crate::Error::RawFileError)?
.1)
}
}
impl Clone for AlignedFile {
fn clone(&self) -> Self {
self.try_clone().expect("AlignedFile cloning failed")