Ensure that writer buffers are flushed before synchronizing parity writes
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-win (push) Waiting to run
CodeQL / Analyze (push) Waiting to run

This commit is contained in:
Andrea Mazzoleni 2025-09-25 12:46:15 +02:00
parent 5fd41d215b
commit 30474cfb80
7 changed files with 130 additions and 35 deletions

View file

@ -4915,3 +4915,29 @@ void generate_configuration(const char* path)
state_done(&state);
}
/**
* Flush and sync the parity files.
*/
int state_flush(struct snapraid_state* state, struct snapraid_io* io, struct snapraid_parity_handle* parity_handle, block_off_t blockcur)
{
unsigned l;
if (io)
io_flush(io);
/* flush all parity handles to ensure data is written to disk */
for (l = 0; l < state->level; ++l) {
int ret = parity_sync(&parity_handle[l]);
if (ret == -1) {
/* LCOV_EXCL_START */
log_tag("parity_error:%u:%s: Sync error\n", blockcur, lev_config_name(l));
log_fatal("DANGER! Unexpected sync error in %s disk.\n", lev_name(l));
log_fatal("Ensure that disk '%s' is sane.\n", lev_config_name(l));
return -1;
/* LCOV_EXCL_STOP */
}
}
return 0;
}