Skip to main content

CompressedClusterReadGuard

Struct CompressedClusterReadGuard 

Source
pub(super) struct CompressedClusterReadGuard<'a> {
    host_offset: HostOffset,
    length: NonZero<u64>,
    cluster_bits: u32,
    _lock: RwLockEitherGuard<'a, ()>,
}
Expand description

Read guard for a compressed cluster.

Readers generally do not need to lock L2 tables: Modifications replace mappings atomically, and allocations referenced by a (data) mapping are not freed while the image can be accessed concurrently. However, allocations referenced by compressed mappings may be freed when they are replaced (by concurrent writes), so the L2 table must not be modified from looking up the compressed mapping until its data has been read. This guard ensures that.

Fields§

§host_offset: HostOffset

Offset of the compressed data.

§length: NonZero<u64>

Upper limit on the number of bytes that comprise the compressed data.

§cluster_bits: u32

log2 of the cluster size.

§_lock: RwLockEitherGuard<'a, ()>

Held lock on the L2 table, preventing modifications.

Implementations§

Source§

impl<'a> CompressedClusterReadGuard<'a>

Source

pub fn new( l2_table: &L2Table, cluster: GuestCluster, lock: RwLockEitherGuard<'a, ()>, ) -> Result<Option<Self>>

Create a new guard for reading compressed data from the given cluster, under lock, which prevents concurrent modifications of that cluster.

lock must be a read or write lock on L2Table.writer_lock.

Return None if cluster is not compressed (checked under the guard).

Source

pub async fn read_compressed<S: Storage>( &self, storage: &S, buf: &mut [u8], ) -> Result<()>

Read the compressed cluster.

Read the compressed data from storage (which must be the image’s data file) and decompress it into buf (which must have a length of exactly one cluster).

Trait Implementations§

Source§

impl<'a> Debug for CompressedClusterReadGuard<'a>

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.

§

impl<T> Instrument for T

§

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

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

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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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