const auto first = ranged_cast<size_t>(ext_begin / BLOCK_SIZE_SUMS);
const auto last = ranged_cast<size_t>(
(ext_end + BLOCK_SIZE_SUMS - 1) / BLOCK_SIZE_SUMS);
+ // A temp file's extents are ordinary btrfs extents and an extent
+ // scan can pick them up like any other -- a temp file that
+ // outlives a transaction boundary reaches the scan queue. That
+ // matters because temp files are recycled: resize() truncates
+ // back to the reserved block and the space is rewritten with
+ // unrelated data. No extent Exclusion covers that, since the
+ // mutation is a truncate of a file rather than a dedupe of the
+ // locked extent, so a ref into a recycled temp file reads
+ // whatever the next user wrote. Every temp file is on the
+ // blacklist, so skip those refs instead of hashing them: they
+ // contribute no data coverage and pass 2 never preads them.
+ if (m_ctx.is_blacklisted(BeesFileId(ref.root(), ref.inum()))) {
+ BEESCOUNT(block_map_ref_tempfile);
+ continue;
+ }
+
if (*prealloc) {
for (size_t i = first; i < min(last, block_count); ++i) {
if (blocks[i].state == BeesTreeBlockState::unreachable) {