(
refcount_order: u32,
cluster_size: u32,
num_clusters: u32,
)
| 584 | } |
| 585 | |
| 586 | pub(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. |
| 600 | pub(super) fn offset_is_cluster_boundary(offset: u64, cluster_bits: u32) -> Result<()> { |
no test coverage detected