disk_layered

Trait LayerIo

Source
pub trait LayerIo:
    'static
    + Send
    + Sync
    + Inspect {
Show 15 methods // Required methods fn layer_type(&self) -> &str; fn sector_count(&self) -> u64; fn sector_size(&self) -> u32; fn disk_id(&self) -> Option<[u8; 16]>; fn physical_sector_size(&self) -> u32; fn is_fua_respected(&self) -> bool; fn is_logically_read_only(&self) -> bool; fn sync_cache(&self) -> impl Future<Output = Result<(), DiskError>> + Send; fn read( &self, buffers: &RequestBuffers<'_>, sector: u64, marker: SectorMarker<'_>, ) -> impl Future<Output = Result<(), DiskError>> + Send; fn write( &self, buffers: &RequestBuffers<'_>, sector: u64, fua: bool, ) -> impl Future<Output = Result<(), DiskError>> + Send; fn unmap( &self, sector: u64, count: u64, block_level_only: bool, next_is_zero: bool, ) -> impl Future<Output = Result<(), DiskError>> + Send; fn unmap_behavior(&self) -> UnmapBehavior; // Provided methods fn optimal_unmap_sectors(&self) -> u32 { ... } fn write_no_overwrite(&self) -> Option<impl WriteNoOverwrite> { ... } fn wait_resize(&self, sector_count: u64) -> impl Future<Output = u64> + Send { ... }
}
Expand description

Metadata and IO for disk layers.

Required Methods§

Source

fn layer_type(&self) -> &str

Returns the layer type name as a string.

This is used for diagnostic purposes.

Source

fn sector_count(&self) -> u64

Returns the current sector count.

For some backing stores, this may change at runtime. If it does, then the backing store must also implement [DiskIo::wait_resize].

Source

fn sector_size(&self) -> u32

Returns the logical sector size of the backing store.

This must not change at runtime.

Source

fn disk_id(&self) -> Option<[u8; 16]>

Optionally returns a 16-byte identifier for the disk, if there is a natural one for this backing store.

This may be exposed to the guest as a unique disk identifier. This must not change at runtime.

Source

fn physical_sector_size(&self) -> u32

Returns the physical sector size of the backing store.

This must not change at runtime.

Source

fn is_fua_respected(&self) -> bool

Returns true if the fua parameter to LayerIo::write is respected by the backing store by ensuring that the IO is immediately committed to disk.

Source

fn is_logically_read_only(&self) -> bool

Returns true if the layer is logically read only.

If this returns true, the layer might still be writable via write_no_overwrite, used to populate the layer as a read cache.

Source

fn sync_cache(&self) -> impl Future<Output = Result<(), DiskError>> + Send

Issues an asynchronous flush operation to the disk.

Source

fn read( &self, buffers: &RequestBuffers<'_>, sector: u64, marker: SectorMarker<'_>, ) -> impl Future<Output = Result<(), DiskError>> + Send

Reads sectors from the layer.

marker is used to specify which sectors have been read. Those that are not read will be passed to the next layer, or zeroed if there are no more layers.

Source

fn write( &self, buffers: &RequestBuffers<'_>, sector: u64, fua: bool, ) -> impl Future<Output = Result<(), DiskError>> + Send

Writes sectors to the layer.

§Panics

The caller must pass a buffer with an integer number of sectors.

Source

fn unmap( &self, sector: u64, count: u64, block_level_only: bool, next_is_zero: bool, ) -> impl Future<Output = Result<(), DiskError>> + Send

Unmap sectors from the layer.

If next_is_zero is true, then the next layer’s content’s are known to be zero. A layer can use this information to just discard the sectors rather than putting them in the zero state (which make take more space).

Source

fn unmap_behavior(&self) -> UnmapBehavior

Returns the behavior of the unmap operation.

Provided Methods§

Source

fn optimal_unmap_sectors(&self) -> u32

Returns the optimal granularity for unmaps, in sectors.

Source

fn write_no_overwrite(&self) -> Option<impl WriteNoOverwrite>

Optionally returns a write-no-overwrite implementation.

Source

fn wait_resize(&self, sector_count: u64) -> impl Future<Output = u64> + Send

Waits for the disk sector size to be different than the specified value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§