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: HostOffsetOffset of the compressed data.
length: NonZero<u64>Upper limit on the number of bytes that comprise the compressed data.
cluster_bits: u32log2 of the cluster size.
_lock: RwLockEitherGuard<'a, ()>Held lock on the L2 table, preventing modifications.
Implementations§
Source§impl<'a> CompressedClusterReadGuard<'a>
impl<'a> CompressedClusterReadGuard<'a>
Sourcepub fn new(
l2_table: &L2Table,
cluster: GuestCluster,
lock: RwLockEitherGuard<'a, ()>,
) -> Result<Option<Self>>
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).