Centralize canonical SnapRAID block hashing semantics

This commit is contained in:
Andrea Mazzoleni 2026-08-30 23:09:29 +02:00
parent 0ab885d8e5
commit 1a5b5728d2
7 changed files with 87 additions and 33 deletions

View file

@ -775,6 +775,36 @@ void memhash(unsigned kind, const unsigned char* seed, void* digest, const void*
}
}
void memhash_block(unsigned kind, const unsigned char* seed, void* digest, const void* src, size_t logical_size, size_t block_size)
{
assert(logical_size <= block_size);
switch (kind) {
case HASH_MUSEAIR :
/*
* MuseAir defines the identity of the complete canonical RAID
* block. The caller must have zero-padded the buffer after the
* logical end of the file block.
*/
memhash(kind, seed, digest, src, block_size);
break;
case HASH_MURMUR3 :
case HASH_SPOOKY2 :
/*
* Preserve the historical SnapRAID hash semantics for content
* files using legacy hashes.
*/
memhash(kind, seed, digest, src, logical_size);
break;
default :
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Internal inconsistency in hash function %u\n", kind);
exit(EXIT_FAILURE);
break;
/* LCOV_EXCL_STOP */
}
}
const char* hash_config_name(unsigned kind)
{
switch (kind) {