pub struct AsyncFileBackend { /* private fields */ }Expand description
Direct-I/O file-backed BlockBackend for the high-IOPS path.
Differs from SyncFileBackend structurally: lockless positioned
I/O. Uses pread(2) / pwrite(2) via
std::os::unix::fs::FileExt::{read_at, write_at}, so multiple threads
can issue concurrent operations against the same fd without serialising
through a Mutex<File>. The 100 K IOPS budget in
71 § 3 needs the
lockless path — a mutex-serialised engine caps at the latency of one
pread per op (≈ 30 μs ⇒ 33 K IOPS ceiling on a single thread).
F_NOCACHE is not set here because squib-virtio carries
#![forbid(unsafe_code)] (I-CRATE-2): the fcntl(F_NOCACHE) call lives
in squib-host::block_io::set_f_nocache, which can wrap the fd before
it’s handed to this constructor (the operator-supplied path is opened
once at boot, so the small upfront cost is fine). The host-side cache
pressure without F_NOCACHE is small for the Lambda workload profile;
the perf-tuning lane benchmark
(71 § 3) gates
the regression once the bench harness lights up.
Functionally interchangeable with SyncFileBackend; constructed via
Self::open and dropped in via the same Arc<dyn BlockBackend>
the device frontend takes today.
Implementations§
Source§impl AsyncFileBackend
impl AsyncFileBackend
Sourcepub fn open(path: &Path, read_only: bool) -> Result<Self>
pub fn open(path: &Path, read_only: bool) -> Result<Self>
Open path for lockless positioned I/O.
The fd is shared across every thread that calls into BlockBackend;
concurrent positioned I/O is safe via pread/pwrite.
§Errors
std::io::Error if the file cannot be opened.
Sourcepub fn from_file(file: File, read_only: bool) -> Result<Self>
pub fn from_file(file: File, read_only: bool) -> Result<Self>
Wrap an already-open File. Used by squib-host after applying
F_NOCACHE via the unsafe fcntl boundary: the operator constructs
the fd, hands it to us, and we own the read/write side.
§Errors
std::io::Error if the file’s metadata can’t be queried.