Add a new test option to force parity update

This commit is contained in:
Andrea Mazzoleni 2016-01-04 10:40:41 +01:00
parent a9701d3e7c
commit 62aba9228a
3 changed files with 9 additions and 1 deletions

View file

@ -248,6 +248,7 @@ void config(char* conf, size_t conf_size, const char* argv0)
#define OPT_NO_WARNINGS 286
#define OPT_TEST_FAKE_UUID 287
#define OPT_TEST_MATCH_FIRST_UUID 288
#define OPT_TEST_FORCE_PARITY_UPDATE 289
#if HAVE_GETOPT_LONG
struct option long_options[] = {
@ -372,6 +373,9 @@ struct option long_options[] = {
/* Match first UUID */
{ "test-match-first-uuid", 0, 0, OPT_TEST_MATCH_FIRST_UUID },
/* Force parity update even if all the data is not changed */
{ "test-force-parity-update", 0, 0, OPT_TEST_FORCE_PARITY_UPDATE },
{ 0, 0, 0, 0 }
};
#endif
@ -747,6 +751,9 @@ int main(int argc, char* argv[])
case OPT_TEST_MATCH_FIRST_UUID :
opt.match_first_uuid = 1;
break;
case OPT_TEST_FORCE_PARITY_UPDATE :
opt.force_parity_update = 1;
break;
default :
/* LCOV_EXCL_START */
log_fatal("Unknown option '%c'\n", (char)c);

View file

@ -107,6 +107,7 @@ struct snapraid_option {
int expected_missing; /**< If missing files are expected and should not be reported. */
int fake_uuid; /**< Set fakes UUID for testing. */
int match_first_uuid; /**< Force the matching of the first UUID. */
int force_parity_update; /**< Force parity update even if data is not changed. */
};
/**

View file

@ -554,7 +554,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* have the hash cleared (::clear_past_hash flag), and then they won't never match the hash. */
/* We are treating only CHG blocks created at runtime. */
/* In such case, we can avoid to update parity, because it would be the same as before */
parity_needs_to_be_updated = 0;
parity_needs_to_be_updated = state->opt.force_parity_update;
/* if the block is marked as bad, we force the parity update */
/* because the bad block may be the result of a wrong parity */