mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-03 05:10:16 -05:00
Clarify cross-generation lookup limitation and safety in import_dealloc during rehash
This commit is contained in:
parent
f25fbd0c1b
commit
8396d3aaa1
1 changed files with 10 additions and 4 deletions
|
|
@ -183,10 +183,16 @@ static void import_dealloc(struct snapraid_state* state, const char* dir, struct
|
||||||
/* if we are in a rehash state */
|
/* if we are in a rehash state */
|
||||||
if (state->prevhash != HASH_UNDEFINED) {
|
if (state->prevhash != HASH_UNDEFINED) {
|
||||||
/*
|
/*
|
||||||
* The deallocation record doesn't identify which hash algorithm
|
* The deallocation record stores only one digest per block without
|
||||||
* produced the stored digest, so index it under both algorithms.
|
* recording which hash algorithm generated it. To avoid disk I/O at
|
||||||
* This is safe because state_import_fetch() hashes the candidate
|
* startup, index the stored digest under both algorithms.
|
||||||
* bytes with the requested algorithm before accepting them.
|
*
|
||||||
|
* This is safe against false positives because state_import_fetch()
|
||||||
|
* validates candidate bytes with the requested algorithm upon read.
|
||||||
|
*
|
||||||
|
* Note that cross-generation matches (an old-hash deallocation supplying
|
||||||
|
* a new-hash block, or vice-versa) will miss in hash lookup and fall
|
||||||
|
* back to parity reconstruction. Only same-generation matches will succeed.
|
||||||
*/
|
*/
|
||||||
memcpy(block->prevhash, block->hash, BLOCK_HASH_SIZE);
|
memcpy(block->prevhash, block->hash, BLOCK_HASH_SIZE);
|
||||||
tommy_hashdyn_insert(&state->previmportset, &block->prevnodeset, block, import_block_hash(block->prevhash));
|
tommy_hashdyn_insert(&state->previmportset, &block->prevnodeset, block, import_block_hash(block->prevhash));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue