Skip to main content

WriteCaching

Enum WriteCaching 

Source
pub enum WriteCaching {
    Cached,
    WriteThrough,
}
Expand description

Where a write is allowed to stop: in the system cache, or past it (M12.3, D-25 in DESIGN-NOTES.md).

This is BuildIoRingWriteFile’s FILE_WRITE_FLAGS parameter, which the crate previously hardcoded to FILE_WRITE_FLAGS_NONE – so a consumer reading this API saw ordering but no way to express anything about caching at all, and could reasonably conclude the ring did not expose it. It does; the crate was narrowing the platform to what its own examples needed.

§What write-through is, and what it is not

Worth stating precisely, because conflating these produced a wrong recommendation in the exchange that prompted this work.

It is a first-level cache directive: it tells the OS not to leave the data sitting in the system cache. Its practical value is latency shaping – data already at the device makes a later flush shorter, which can matter when the flush is on a commit path.

It is not a durability guarantee, and it is not FUA. Whether it becomes a Force Unit Access bit on the underlying command depends on the driver, the volume, and whether the device’s write cache is enabled – none of which this API can see or promise. A write that completes with WriteCaching::WriteThrough may still be sitting in a volatile device cache, and will be lost on power failure like any other.

The flush operation is the only durability primitive the ring has, and only with FlushCoverage::CoversPrecedingOperations. Reaching for write-through instead of a covering flush is the mistake this doc exists to prevent; reaching for it as well is a legitimate latency optimization.

Variants§

§

Cached

FILE_WRITE_FLAGS_NONE: the write may be satisfied into the system cache, and reaching the device is a later flush’s job.

The default, and the right choice for the streaming writes of an epoch that a covering flush will close.

§

WriteThrough

FILE_WRITE_FLAGS_WRITE_THROUGH: ask the OS not to leave the data in the system cache.

A latency-shaping knob, not a durability marker – see this type’s docs. It does not remove the need for a flush.

Trait Implementations§

Source§

impl Clone for WriteCaching

Source§

fn clone(&self) -> WriteCaching

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WriteCaching

Source§

impl Debug for WriteCaching

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for WriteCaching

Source§

fn default() -> WriteCaching

Returns the “default value” for a type. Read more
Source§

impl Eq for WriteCaching

Source§

impl PartialEq for WriteCaching

Source§

fn eq(&self, other: &WriteCaching) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WriteCaching

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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.