mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-03 13:20:28 -05:00
Fix touch abort before the first sync when no content file exists
This commit is contained in:
parent
20e081d5ac
commit
a0d6bc288a
3 changed files with 56 additions and 1 deletions
|
|
@ -5428,6 +5428,37 @@ void state_read(struct snapraid_state* state)
|
|||
state->checked_read = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if all configured parity splits have persistent sizes.
|
||||
*/
|
||||
int state_is_write_ready(struct snapraid_state* state)
|
||||
{
|
||||
unsigned l, s;
|
||||
|
||||
for (l = 0; l < state->level; ++l) {
|
||||
for (s = 0; s < state->parity[l].split_mac; ++s) {
|
||||
if (state->parity[l].split_map[s].size == PARITY_SIZE_INVALID)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Require sync to initialize parity sizes before commands that can save content.
|
||||
* Check before modifying timestamps or metadata, as a later write could fail
|
||||
* even if the command has no blocks to process (e.g. a missing content replica).
|
||||
*/
|
||||
void state_require_write_ready(struct snapraid_state* state)
|
||||
{
|
||||
if (!state_is_write_ready(state)) {
|
||||
log_fatal(EUSER, "The array has not been synced yet, or its parity configuration has changed.\n");
|
||||
log_fatal(EUSER, "Run 'snapraid sync' before '%s'.\n", state->command);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
struct state_verify_thread_context {
|
||||
struct snapraid_state* state;
|
||||
struct snapraid_content* content;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue