Skip to main content

PreparedMappingState

Struct PreparedMappingState 

Source
pub(super) struct PreparedMappingState {
    l2_table: L2TableWriteGuard,
    l2_changes: Vec<(usize, HostCluster, Option<PendingClusters>)>,
    clusters_to_free: Arc<ClustersToFreeList>,
}
Expand description

State of a data mapping that has been prepared, but not committed yet.

Created by Qcow2::do_prepare_data_mapping(), to be passed to Qcow2::do_commit_data_mapping().

Dropping this discards the prepared mapping, i.e. enters the clusters that have been allocated for it into the list of clusters to free.

Fields§

§l2_table: L2TableWriteGuard

Write guard on the L2 table that is to be modified.

Held so that nobody else modifies the affected L2 entries before the mapping is committed or dropped; in particular, nobody else may prepare a mapping for the same guest clusters.

This also occupies an L2 cache entry for as long as it exists, because the cache only evicts tables that nothing else refers to. Prepared mappings are held across data I/O, so holding several of them can pin the whole L2 cache: If no entry can be evicted, loading another L2 table fails with an I/O error (“Cannot evict entry from cache; everything is in use”) instead of waiting for an entry to become available.

§l2_changes: Vec<(usize, HostCluster, Option<PendingClusters>)>

What to enter into the L2 table: L2 index, host cluster, and the guard for the host cluster if it has been newly allocated.

§clusters_to_free: Arc<ClustersToFreeList>

The image’s list of clusters to free, to identify which image this state belongs to.

Implementations§

Source§

impl PreparedMappingState

Source

pub fn belongs_to<S: Storage + 'static, F: WrappedFormat<S> + 'static>( &self, qcow2: &Qcow2<S, F>, ) -> bool

Check whether this state belongs to the given qcow2 image instance

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