Track current and previous hash generations for deallocated blocks
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run

This commit is contained in:
Andrea Mazzoleni 2026-09-25 23:40:58 +02:00
parent 0440d74fb5
commit b023939c6b
6 changed files with 103 additions and 61 deletions

View file

@ -18,6 +18,7 @@ void state_rehash(struct snapraid_state* state)
{
block_off_t blockmax;
block_off_t i;
int has_pending_dealloc = 0;
blockmax = parity_allocated_size(state);
@ -38,8 +39,17 @@ void state_rehash(struct snapraid_state* state)
/* LCOV_EXCL_STOP */
}
/* deleted-only positions are not counted in unsynced_blocks, but their hashes still need the current generation */
for (tommy_node* node = state->disklist; node != 0; node = node->next) {
struct snapraid_disk* disk = node->data;
if (!tommy_list_empty(&disk->dealloclist)) {
has_pending_dealloc = 1;
break;
}
}
/* a rehash can start only from a fully synchronized state */
if (state->unsynced_blocks != 0) {
if (state->unsynced_blocks != 0 || has_pending_dealloc) {
/* LCOV_EXCL_START */
log_tag("summary:exit:sync_required\n");
log_fatal(EUSER, "You cannot start a rehash with an incomplete sync.\n");