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>
impl<D, H, B, HD, IO> CacheBlockStorage<D, H, B, HD, IO>
Sourcepub fn device(id: CacheBlockId, device: D, backing: Option<B>) -> Self
pub fn device(id: CacheBlockId, device: D, backing: Option<B>) -> Self
Creates device residency, optionally retaining an existing backing.
Sourcepub fn host(id: CacheBlockId, host: H, backing: Option<B>) -> Self
pub fn host(id: CacheBlockId, host: H, backing: Option<B>) -> Self
Creates host residency, optionally retaining an existing backing.
Sourcepub fn disk(id: CacheBlockId, backing: B) -> Self
pub fn disk(id: CacheBlockId, backing: B) -> Self
Creates ready backing-only residency.
Sourcepub const fn phase(&self) -> CacheStoragePhase
pub const fn phase(&self) -> CacheStoragePhase
Current canonical phase.
Sourcepub const fn id(&self) -> &CacheBlockId
pub const fn id(&self) -> &CacheBlockId
Block whose physical resources are owned by this state machine.
Sourcepub fn device_resource(&self) -> Option<&D>
pub fn device_resource(&self) -> Option<&D>
Backend device resources, including while a demotion is pending.
Sourcepub fn host_resource(&self) -> Option<&H>
pub fn host_resource(&self) -> Option<&H>
Backend host resources.
Sourcepub fn host_demotion(&self) -> Option<&HD>
pub fn host_demotion(&self) -> Option<&HD>
Exact pending host-demotion completion.
Source§impl<D, H, B, HD: CacheHostDemotionOperation, IO: CacheIoOperation> CacheBlockStorage<D, H, B, HD, IO>
impl<D, H, B, HD: CacheHostDemotionOperation, IO: CacheIoOperation> CacheBlockStorage<D, H, B, HD, IO>
Sourcepub fn io_matches(&self, key: &CacheIoOperationKey) -> bool
pub fn io_matches(&self, key: &CacheIoOperationKey) -> bool
Returns whether the exact backing-store operation is pending.
Sourcepub fn fail_io_if_matches(&mut self, key: &CacheIoOperationKey) -> bool
pub fn fail_io_if_matches(&mut self, key: &CacheIoOperationKey) -> bool
Fails the operation only when the exact key is still pending.
Sourcepub fn begin_host_demotion(
&mut self,
operation: HD,
) -> Result<(), CacheStorageError>
pub fn begin_host_demotion( &mut self, operation: HD, ) -> Result<(), CacheStorageError>
Begins an exact device-to-host transition while retaining device state.
Sourcepub fn finish_host_demotion(
&mut self,
operation_id: u64,
host: H,
) -> Result<(D, HD), CacheStorageError>
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.
Sourcepub fn fail_host_demotion(
&mut self,
operation_id: u64,
) -> Result<HD, CacheStorageError>
pub fn fail_host_demotion( &mut self, operation_id: u64, ) -> Result<HD, CacheStorageError>
Abandons the matching host demotion and restores device residency.
Sourcepub fn release_device_to_disk(&mut self) -> Result<D, CacheStorageError>
pub fn release_device_to_disk(&mut self) -> Result<D, CacheStorageError>
Releases backed device resources directly to backing-only residency.
Sourcepub fn release_host_to_disk(&mut self) -> Result<H, CacheStorageError>
pub fn release_host_to_disk(&mut self) -> Result<H, CacheStorageError>
Releases backed host resources directly to backing-only residency.
Sourcepub fn begin_write(&mut self, operation: IO) -> Result<(), CacheStorageError>
pub fn begin_write(&mut self, operation: IO) -> Result<(), CacheStorageError>
Starts the exact write that owns unbacked host resources.
Sourcepub fn finish_write(
&mut self,
key: &CacheIoOperationKey,
backing: B,
) -> Result<(H, IO), CacheStorageError>
pub fn finish_write( &mut self, key: &CacheIoOperationKey, backing: B, ) -> Result<(H, IO), CacheStorageError>
Commits the matching write and returns released host resources.
Sourcepub fn begin_read(&mut self, operation: IO) -> Result<(), CacheStorageError>
pub fn begin_read(&mut self, operation: IO) -> Result<(), CacheStorageError>
Starts the exact read that owns backing-only resources.
Sourcepub fn finish_read(
&mut self,
key: &CacheIoOperationKey,
host: H,
) -> Result<IO, CacheStorageError>
pub fn finish_read( &mut self, key: &CacheIoOperationKey, host: H, ) -> Result<IO, CacheStorageError>
Commits the matching read while retaining its durable backing.
Sourcepub fn fail_io(
&mut self,
key: &CacheIoOperationKey,
) -> Result<IO, CacheStorageError>
pub fn fail_io( &mut self, key: &CacheIoOperationKey, ) -> Result<IO, CacheStorageError>
Cancels or fails the matching I/O and restores its stable source phase.
Sourcepub fn promote_host(
&mut self,
device: D,
) -> Result<CacheHostPromotion<H>, CacheStorageError>
pub fn promote_host( &mut self, device: D, ) -> Result<CacheHostPromotion<H>, CacheStorageError>
Promotes stable host resources to device residency.
Sourcepub fn restore_host(
&mut self,
promotion: CacheHostPromotion<H>,
) -> Result<D, CacheStorageError>
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>
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>
fn clone(&self) -> CacheBlockStorage<D, H, B, HD, IO>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more