Skip to main content

AsyncFileBackend

Struct AsyncFileBackend 

Source
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

Source

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.

Source

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.

Trait Implementations§

Source§

impl BlockBackend for AsyncFileBackend

Source§

fn size_bytes(&self) -> u64

Total size of the backing storage in bytes.
Source§

fn read_at(&self, byte_offset: u64, buf: &mut [u8]) -> Result<()>

Read buf.len() bytes starting at byte_offset. Read more
Source§

fn write_at(&self, byte_offset: u64, buf: &[u8]) -> Result<()>

Write buf.len() bytes starting at byte_offset. Read more
Source§

fn flush(&self) -> Result<()>

Synchronous flush (fsync). Read more
Source§

fn read_only(&self) -> bool

true if the backing storage is opened read-only.
Source§

impl Debug for AsyncFileBackend

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more