pub struct RefCount {
ref_table: VecCache<u64>,
refcount_table_offset: u64,
refblock_cache: CacheMap<VecCache<u16>>,
refcount_block_entries: u64,
cluster_size: u64,
max_valid_cluster_offset: u64,
}
Expand description
Represents the refcount entries for an open qcow file.
Fields§
§ref_table: VecCache<u64>
§refcount_table_offset: u64
§refblock_cache: CacheMap<VecCache<u16>>
§refcount_block_entries: u64
§cluster_size: u64
§max_valid_cluster_offset: u64
Implementations§
source§impl RefCount
impl RefCount
sourcepub fn new(
raw_file: &mut QcowRawFile,
refcount_table_offset: u64,
refcount_table_entries: u64,
refcount_block_entries: u64,
cluster_size: u64
) -> Result<RefCount>
pub fn new( raw_file: &mut QcowRawFile, refcount_table_offset: u64, refcount_table_entries: u64, refcount_block_entries: u64, cluster_size: u64 ) -> Result<RefCount>
Creates a RefCount
from file
, reading the refcount table from refcount_table_offset
.
refcount_table_entries
specifies the number of refcount blocks used by this image.
refcount_block_entries
indicates the number of refcounts in each refcount block.
Each refcount table entry points to a refcount block.
sourcepub fn refcounts_per_block(&self) -> u64
pub fn refcounts_per_block(&self) -> u64
Returns the number of refcounts per block.
sourcepub fn max_valid_cluster_offset(&self) -> u64
pub fn max_valid_cluster_offset(&self) -> u64
Returns the maximum valid cluster offset in the raw file for this refcount table.
sourcepub fn set_cluster_refcount(
&mut self,
raw_file: &mut QcowRawFile,
cluster_address: u64,
refcount: u16,
new_cluster: Option<(u64, VecCache<u16>)>
) -> Result<Option<u64>, Error>
pub fn set_cluster_refcount( &mut self, raw_file: &mut QcowRawFile, cluster_address: u64, refcount: u16, new_cluster: Option<(u64, VecCache<u16>)> ) -> Result<Option<u64>, Error>
Returns NeedNewCluster
if a new cluster needs to be allocated for refcounts. If an
existing cluster needs to be read, NeedCluster(addr)
is returned. The Caller should
allocate a cluster or read the required one and call this function again with the cluster.
On success, an optional address of a dropped cluster is returned. The dropped cluster can
be reused for other purposes.
sourcepub fn flush_blocks(&mut self, raw_file: &mut QcowRawFile) -> Result<()>
pub fn flush_blocks(&mut self, raw_file: &mut QcowRawFile) -> Result<()>
Flush the dirty refcount blocks. This must be done before flushing the table that points to the blocks.
sourcepub fn flush_table(&mut self, raw_file: &mut QcowRawFile) -> Result<bool>
pub fn flush_table(&mut self, raw_file: &mut QcowRawFile) -> Result<bool>
Flush the refcount table that keeps the address of the refcounts blocks.
Returns true if the table changed since the previous flush_table()
call.
sourcepub fn get_cluster_refcount(
&mut self,
raw_file: &mut QcowRawFile,
address: u64
) -> Result<u16, Error>
pub fn get_cluster_refcount( &mut self, raw_file: &mut QcowRawFile, address: u64 ) -> Result<u16, Error>
Gets the refcount for a cluster with the given address.