Checks parity UUID before proceding.

This commit is contained in:
Andrea Mazzoleni 2014-11-09 19:51:58 +01:00
parent af4ec2286f
commit 87e6497665
2 changed files with 18 additions and 5 deletions

View file

@ -19,6 +19,8 @@ SnapRAID HISTORY
* Prints the time spent waiting for each disk also in 'scrub'.
* The CPU usage, speed and ETA estimations are now based on the last 100
seconds rather than from the start.
* Keeps track of the UUID of the parity disks to check them before
operating.
* Windows binary built with gcc 4.8.1 using the MXE cross compiler 2.23.
6.3 2014/7

View file

@ -1026,6 +1026,7 @@ static void state_map(struct snapraid_state* state)
if (state->no_conf)
return;
/* counter for the number of UUID mismatches */
uuid_mismatch = 0;
/* checks if mapping match the disk uuid */
@ -1088,11 +1089,21 @@ static void state_map(struct snapraid_state* state)
continue;
}
/* update the uuid in the mapping */
/* at now we don't enforce uuid for parity */
/* as the user is expected to have a different file name */
/* for each parity file */
pathcpy(state->parity[l].uuid, sizeof(state->parity[l].uuid), uuid);
/* if the uuid is changed */
if (strcmp(uuid, state->parity[l].uuid) != 0) {
/* if the previous uuid is available */
if (state->parity[l].uuid[0] != 0) {
/* count the number of uuid change */
++uuid_mismatch;
fprintf(stderr, "UUID change for parity '%s' from '%s' to '%s'\n", lev_config_name(l), state->parity[l].uuid, uuid);
}
/* update the uuid */
pathcpy(state->parity[l].uuid, sizeof(state->parity[l].uuid), uuid);
/* write the new state with the new uuid */
state->need_write = 1;
}
}
}