Skip to main content

CacheBlockStorage

Struct CacheBlockStorage 

Source
pub struct CacheBlockStorage<D, H, B, HD, IO> { /* private fields */ }
Expand description

Canonical physical-resource state machine for one cache block.

D, H, and B are backend-owned device, host, and backing resources. HD and IO are backend-owned exact completions. Private resource slots prevent a backend from constructing contradictory phase/resource states.

Implementations§

Source§

impl<D, H, B, HD, IO> CacheBlockStorage<D, H, B, HD, IO>

Source

pub fn device(id: CacheBlockId, device: D, backing: Option<B>) -> Self

Creates device residency, optionally retaining an existing backing.

Source

pub fn host(id: CacheBlockId, host: H, backing: Option<B>) -> Self

Creates host residency, optionally retaining an existing backing.

Source

pub fn disk(id: CacheBlockId, backing: B) -> Self

Creates ready backing-only residency.

Source

pub const fn phase(&self) -> CacheStoragePhase

Current canonical phase.

Source

pub const fn id(&self) -> &CacheBlockId

Block whose physical resources are owned by this state machine.

Source

pub const fn tier(&self) -> CacheTier

Current logical accounting tier.

Source

pub fn device_resource(&self) -> Option<&D>

Backend device resources, including while a demotion is pending.

Source

pub fn host_resource(&self) -> Option<&H>

Backend host resources.

Source

pub fn backing(&self) -> Option<&B>

Durable backing retained by the current phase.

Source

pub fn host_demotion(&self) -> Option<&HD>

Exact pending host-demotion completion.

Source

pub fn io(&self) -> Option<&IO>

Exact pending backing-store completion.

Source§

impl<D, H, B, HD: CacheHostDemotionOperation, IO: CacheIoOperation> CacheBlockStorage<D, H, B, HD, IO>

Source

pub fn io_matches(&self, key: &CacheIoOperationKey) -> bool

Returns whether the exact backing-store operation is pending.

Source

pub fn fail_io_if_matches(&mut self, key: &CacheIoOperationKey) -> bool

Fails the operation only when the exact key is still pending.

Source

pub fn begin_host_demotion( &mut self, operation: HD, ) -> Result<(), CacheStorageError>

Begins an exact device-to-host transition while retaining device state.

Source

pub fn finish_host_demotion( &mut self, operation_id: u64, host: H, ) -> Result<(D, HD), CacheStorageError>

Commits the matching host demotion and returns released device resources.

Source

pub fn fail_host_demotion( &mut self, operation_id: u64, ) -> Result<HD, CacheStorageError>

Abandons the matching host demotion and restores device residency.

Source

pub fn release_device_to_disk(&mut self) -> Result<D, CacheStorageError>

Releases backed device resources directly to backing-only residency.

Source

pub fn release_host_to_disk(&mut self) -> Result<H, CacheStorageError>

Releases backed host resources directly to backing-only residency.

Source

pub fn begin_write(&mut self, operation: IO) -> Result<(), CacheStorageError>

Starts the exact write that owns unbacked host resources.

Source

pub fn finish_write( &mut self, key: &CacheIoOperationKey, backing: B, ) -> Result<(H, IO), CacheStorageError>

Commits the matching write and returns released host resources.

Source

pub fn begin_read(&mut self, operation: IO) -> Result<(), CacheStorageError>

Starts the exact read that owns backing-only resources.

Source

pub fn finish_read( &mut self, key: &CacheIoOperationKey, host: H, ) -> Result<IO, CacheStorageError>

Commits the matching read while retaining its durable backing.

Source

pub fn fail_io( &mut self, key: &CacheIoOperationKey, ) -> Result<IO, CacheStorageError>

Cancels or fails the matching I/O and restores its stable source phase.

Source

pub fn promote_host( &mut self, device: D, ) -> Result<CacheHostPromotion<H>, CacheStorageError>

Promotes stable host resources to device residency.

Source

pub fn restore_host( &mut self, promotion: CacheHostPromotion<H>, ) -> Result<D, CacheStorageError>

Restores host resources after a rejected promotion.

Trait Implementations§

Source§

impl<D: Clone, H: Clone, B: Clone, HD: Clone, IO: Clone> Clone for CacheBlockStorage<D, H, B, HD, IO>

Source§

fn clone(&self) -> CacheBlockStorage<D, H, B, HD, IO>

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<D: Debug, H: Debug, B: Debug, HD: Debug, IO: Debug> Debug for CacheBlockStorage<D, H, B, HD, IO>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D, H, B, HD, IO> Freeze for CacheBlockStorage<D, H, B, HD, IO>
where Option<D>: Freeze, Option<H>: Freeze, Option<B>: Freeze, Option<HD>: Freeze, Option<IO>: Freeze,

§

impl<D, H, B, HD, IO> RefUnwindSafe for CacheBlockStorage<D, H, B, HD, IO>

§

impl<D, H, B, HD, IO> Send for CacheBlockStorage<D, H, B, HD, IO>
where Option<D>: Send, Option<H>: Send, Option<B>: Send, Option<HD>: Send, Option<IO>: Send,

§

impl<D, H, B, HD, IO> Sync for CacheBlockStorage<D, H, B, HD, IO>
where Option<D>: Sync, Option<H>: Sync, Option<B>: Sync, Option<HD>: Sync, Option<IO>: Sync,

§

impl<D, H, B, HD, IO> Unpin for CacheBlockStorage<D, H, B, HD, IO>
where Option<D>: Unpin, Option<H>: Unpin, Option<B>: Unpin, Option<HD>: Unpin, Option<IO>: Unpin,

§

impl<D, H, B, HD, IO> UnsafeUnpin for CacheBlockStorage<D, H, B, HD, IO>

§

impl<D, H, B, HD, IO> UnwindSafe for CacheBlockStorage<D, H, B, HD, IO>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, !>

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.