mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-05 14:20:05 -05:00
Index deallocated snapshot blocks in previmportset during rehash
This commit is contained in:
parent
f453a72369
commit
2bf74bc66f
1 changed files with 18 additions and 3 deletions
|
|
@ -159,12 +159,27 @@ static void import_dealloc(struct snapraid_state* state, const char* dir, struct
|
||||||
block->size = read_size;
|
block->size = read_size;
|
||||||
|
|
||||||
memcpy(block->hash, dealloc->blockhash + i * BLOCK_HASH_SIZE, BLOCK_HASH_SIZE);
|
memcpy(block->hash, dealloc->blockhash + i * BLOCK_HASH_SIZE, BLOCK_HASH_SIZE);
|
||||||
hash_invalid_set(block->prevhash);
|
|
||||||
|
|
||||||
/* do not insert invalid hashes */
|
/* do not insert invalid hashes */
|
||||||
if (!hash_is_invalid(block->hash))
|
if (!hash_is_invalid(block->hash)) {
|
||||||
tommy_hashdyn_insert(&state->importset, &block->nodeset, block, import_block_hash(block->hash));
|
tommy_hashdyn_insert(&state->importset, &block->nodeset, block, import_block_hash(block->hash));
|
||||||
/* do not insert prevhash */
|
|
||||||
|
/* if we are in a rehash state */
|
||||||
|
if (state->prevhash != HASH_UNDEFINED) {
|
||||||
|
/*
|
||||||
|
* The deallocation record doesn't identify which hash algorithm
|
||||||
|
* produced the stored digest, so index it under both algorithms.
|
||||||
|
* This is safe because state_import_fetch() hashes the candidate
|
||||||
|
* bytes with the requested algorithm before accepting them.
|
||||||
|
*/
|
||||||
|
memcpy(block->prevhash, block->hash, BLOCK_HASH_SIZE);
|
||||||
|
tommy_hashdyn_insert(&state->previmportset, &block->prevnodeset, block, import_block_hash(block->prevhash));
|
||||||
|
} else {
|
||||||
|
hash_invalid_set(block->prevhash);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hash_invalid_set(block->prevhash);
|
||||||
|
}
|
||||||
|
|
||||||
offset += read_size;
|
offset += read_size;
|
||||||
size -= read_size;
|
size -= read_size;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue