MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / max_refcount_clusters

Function max_refcount_clusters

block/src/qcow/header.rs:586–597  ·  view source on GitHub ↗
(
    refcount_order: u32,
    cluster_size: u32,
    num_clusters: u32,
)

Source from the content-addressed store, hash-verified

584}
585
586pub(super) fn max_refcount_clusters(
587 refcount_order: u32,
588 cluster_size: u32,
589 num_clusters: u32,
590) -> u64 {
591 // Use u64 as the product of the u32 inputs can overflow.
592 let refcount_bits = 0x01u64 << u64::from(refcount_order);
593 let cluster_bits = u64::from(cluster_size) * 8;
594 let for_data = div_round_up_u64(u64::from(num_clusters) * refcount_bits, cluster_bits);
595 let for_refcounts = div_round_up_u64(for_data * refcount_bits, cluster_bits);
596 for_data + for_refcounts
597}
598
599/// Returns an Error if the given offset doesn't align to a cluster boundary.
600pub(super) fn offset_is_cluster_boundary(offset: u64, cluster_bits: u32) -> Result<()> {

Callers 2

parse_qcowFunction · 0.85

Calls 1

div_round_up_u64Function · 0.85

Tested by

no test coverage detected