pub(super) struct L2TableWriteGuard<'a> {
table: &'a L2Table,
_lock: MutexGuard<'a, ()>,
}
Expand description
Write guard for an L2 table.
Fields§
§table: &'a L2Table
Referenced L2 table.
_lock: MutexGuard<'a, ()>
Held guard mutex on that L2 table.
Implementations§
Source§impl L2TableWriteGuard<'_>
impl L2TableWriteGuard<'_>
Sourcepub fn get_mapping(&self, lookup_cluster: GuestCluster) -> Result<L2Mapping>
pub fn get_mapping(&self, lookup_cluster: GuestCluster) -> Result<L2Mapping>
Look up a cluster mapping.
Sourcepub fn map_cluster(
&mut self,
index: usize,
host_cluster: HostCluster,
) -> Option<(HostCluster, ClusterCount)>
pub fn map_cluster( &mut self, index: usize, host_cluster: HostCluster, ) -> Option<(HostCluster, ClusterCount)>
Enter the given raw data cluster mapping into the L2 table.
If the previous entry pointed to an allocated cluster, return the old allocation so its refcount can be decreased (offset of the first cluster and number of clusters – compressed clusters can span across host cluster boundaries).
If the allocation is reused, None
is returned, so this function only returns Some(_)
if
some cluster is indeed leaked.
Sourcepub fn zero_cluster(
&mut self,
index: usize,
keep_allocation: bool,
) -> Result<Option<(HostCluster, ClusterCount)>>
pub fn zero_cluster( &mut self, index: usize, keep_allocation: bool, ) -> Result<Option<(HostCluster, ClusterCount)>>
Make the given index a zero mapping.
If keep_allocation
is true, keep the zero cluster pre-allocated if there is a
pre-existing single-cluster allocation (i.e. data cluster or pre-allocated zero cluster).
Otherwise, the existing mapping is discarded.
If a previous mapping is discarded, return the old allocation so its refcount can be decreased (offset of the first cluster and number of clusters – compressed clusters can span across host cluster boundaries).
Sourcepub fn discard_cluster(
&mut self,
index: usize,
) -> Option<(HostCluster, ClusterCount)>
pub fn discard_cluster( &mut self, index: usize, ) -> Option<(HostCluster, ClusterCount)>
Remove the given mapping, leaving it empty.
If a previous mapping is discarded, return the old allocation so its refcount can be decreased (offset of the first cluster and number of clusters – compressed clusters can span across host cluster boundaries).