size_t d_count = 0, c_count = 0, p_count = 0, u_count = 0;
for (const auto &part : parts) {
- // Round up: a sub-block tail (e.g. a 971-byte final block) is a
- // real dedupe/copy op and must still appear in the count and the
- // bar. Plain truncation here floored it to zero blocks and
- // dropped it from both, producing a spurious "0d0c0p0u []".
- const uint64_t N = (part.size + BLOCK_SIZE_SUMS - 1) / BLOCK_SIZE_SUMS;
+ // Determine a hole part's sub-kind (unreachable vs zero/prealloc)
+ // up front so the block count can round unreachable regions down,
+ // matching scan_next_region_block_count / scan_next_plan_init. A
+ // sub-block past-EOF unreachable tail shares its block with the
+ // preceding data/copy part and frees nothing, so it floors to
+ // zero blocks and drops out of the bar — the C/D/0 char for that
+ // block already represents it. Every other kind rounds up, so a
+ // real sub-block dedupe/copy/hole tail (e.g. a 971-byte final
+ // block) still appears.
+ bool unreachable = false;
+ if (part.kind == BeesTreeExtentKind::hole) {
+ for (const auto ®ion : dst_bm->m_regions) {
+ if (region.m_begin <= part.begin && region.m_end > part.begin) {
+ unreachable =
+ region.m_state == BeesTreeBlockState::unreachable;
+ break;
+ }
+ }
+ }
+ const uint64_t N = scan_next_region_block_count(unreachable, part.size,
+ ranged_cast<uint64_t>(BLOCK_SIZE_SUMS));
if (N == 0) continue;
int log_len = 0;
c_count++;
bar += "C" + string(log_len, 'c');
} else if (part.kind == BeesTreeExtentKind::hole) {
- BeesTreeBlockState state = BeesTreeBlockState::zero;
- for (const auto ®ion : dst_bm->m_regions) {
- if (region.m_begin <= part.begin && region.m_end > part.begin) {
- state = region.m_state;
- break;
- }
- }
- if (state == BeesTreeBlockState::unreachable) {
+ if (unreachable) {
u_count++;
bar += "U" + string(log_len, 'u');
} else {