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: L2TableWriteGuardWrite 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
impl PreparedMappingState
Sourcepub fn belongs_to<S: Storage + 'static, F: WrappedFormat<S> + 'static>(
&self,
qcow2: &Qcow2<S, F>,
) -> bool
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