block: aligned: Add seeking cursor and drop RawFile

RawFile wrapped AlignedFile only to add a seek position and the file
trait impls that the qcow and vhost_user_block code expects. Fold that
position and every impl onto AlignedFile so the wrapper layer goes away
and callers work with a single O_DIRECT aware file type.

AlignedFile now tracks a cursor and implements Read, Write, Seek,
WriteZeroesAt, PunchHole, FileSync, SeekHole, BlockBackend, Clone,
AsRawFd and AsFd in addition to the positional FileExt path. The
direct_io flag is dropped because alignment already encodes it, where
a zero alignment means the file was not opened with O_DIRECT.

All RawFile uses in the qcow internals and vhost_user_block move to
AlignedFile, and raw_file.rs is removed.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
Anatol Belski
2026-06-19 20:39:33 +02:00
committed by Rob Bradford
parent 4c7e2b83c1
commit 516f4e447d
9 changed files with 292 additions and 364 deletions

View File

@@ -15,7 +15,7 @@ pub mod factory;
mod io_impl;
pub use io_impl::{async_io, fcntl, request};
pub(crate) mod aligned_buffer;
pub(crate) mod aligned_file;
pub mod aligned_file;
pub mod formats;
mod sparse;
use std::alloc::{Layout, alloc_zeroed};
@@ -29,6 +29,7 @@ use std::path::Path;
use std::str::FromStr;
use std::{cmp, mem, result};
pub use aligned_file::AlignedFile;
use formats::qcow::internal as qcow;
#[cfg(feature = "io_uring")]
use io_uring::{IoUring, Probe, opcode};