* `block_bytes`: Number of data bytes read.
* `block_hash`: Number of block hashes computed.
- * `block_map_ref_tempfile`: A data ref was excluded from block map coverage because it points into a file on bees's blacklist, which includes its own temporary files. Temp files are recycled, so the data at such a ref may already belong to an unrelated write; it is not hashed.
+ * `block_map_ref_hashtable`: A data ref was excluded from block map coverage because it points into bees's hash table file. The hash table is not deduplicated.
+ * `block_map_ref_tempfile`: A data ref was excluded from block map coverage because it points into a file on bees's blacklist (other than the hash table), which includes its own temporary files. Temp files are recycled, so the data at such a ref may already belong to an unrelated write; it is not hashed.
* `block_map_ref_unopenable`: A data ref was excluded from block map coverage because its file could not be opened — typically a ref in a deleted file or snapshot that lingers in the ref list until the last open fd closes or the subvol cleaner runs. Blocks covered only by such refs are classified as unreachable.
* `block_ms`: Total time reading data blocks.
* `block_read`: Number of data blocks read.
m_blacklist.erase(fid);
}
+void
+BeesContext::blacklist_insert_hash_table(const BeesFileId &fid)
+{
+ blacklist_insert(fid);
+ unique_lock<mutex> lock(m_blacklist_mutex);
+ m_hash_table_fid = fid;
+}
+
+bool
+BeesContext::is_hash_table_file(const BeesFileId &fid) const
+{
+ unique_lock<mutex> lock(m_blacklist_mutex);
+ return !!m_hash_table_fid && fid == m_hash_table_fid;
+}
+
bool
BeesContext::is_blacklisted(const BeesFileId &fid) const
{
// 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()))) {
+ // The hash table is blacklisted too, but it is not a temp
+ // file: its extents are ordinary and the crawler reaches
+ // them normally. Skip without hashing it.
+ if (m_ctx.is_hash_table_file(BeesFileId(ref.root(), ref.inum()))) {
+ BEESCOUNT(block_map_ref_hashtable);
+ continue;
+ }
// Reaching here means the transid floor did not keep the
// crawler off this extent, so say so loudly with the whole
// extent rather than incrementing a counter nobody reads.
// If Hash is a btrfs, Root must be the same one
if (root_info.fsid() != hash_info.fsid()) return;
// Hash is on the same one, blacklist it
- m_ctx->blacklist_insert(BeesFileId(m_fd));
+ m_ctx->blacklist_insert_hash_table(BeesFileId(m_fd));
});
}
mutable mutex m_blacklist_mutex;
set<BeesFileId> m_blacklist; ///< Files excluded from deduplication.
+ BeesFileId m_hash_table_fid; ///< The hash table file, if on this filesystem.
mutable mutex m_temp_transid_mutex;
/// Earliest transid at which each live temp file materialized data.
/// Empty when no temp file currently holds data.
void blacklist_erase(const BeesFileId &fid);
/// Return true if @p fid is on the blacklist.
bool is_blacklisted(const BeesFileId &fid) const;
+ /// Blacklist @p fid and remember it as the hash table file.
+ void blacklist_insert_hash_table(const BeesFileId &fid);
+ /// Return true if @p fid is the hash table file.
+ bool is_hash_table_file(const BeesFileId &fid) const;
/// Record that temp file @p fid materialized data at @p transid.
/// Idempotent: the first transid recorded since the last reset wins,