diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index 041b2934..438c10d8 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -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); diff --git a/cmdline/state.h b/cmdline/state.h index f00f89e5..fdbfb7ac 100644 --- a/cmdline/state.h +++ b/cmdline/state.h @@ -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. */ }; /** diff --git a/cmdline/sync.c b/cmdline/sync.c index 4c925b26..e0a2aafe 100644 --- a/cmdline/sync.c +++ b/cmdline/sync.c @@ -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 */