diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index d7bbc16b..0597231b 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -291,6 +291,7 @@ void config(char* conf, size_t conf_size, const char* argv0) #define OPT_TEST_IO_ADVISE_DISCARD_32 299 #define OPT_TEST_IO_ADVISE_DIRECT 300 #define OPT_TEST_PARITY_LIMIT 301 +#define OPT_TEST_SKIP_CONTENT_WRITE 302 #if HAVE_GETOPT_LONG struct option long_options[] = { @@ -451,6 +452,9 @@ struct option long_options[] = { /* Set an artificial parity limit */ { "test-parity-limit", 1, 0, OPT_TEST_PARITY_LIMIT }, + /* Skip content write */ + { "test-skip-content-write", 0, 0, OPT_TEST_SKIP_CONTENT_WRITE }, + { 0, 0, 0, 0 } }; #endif @@ -874,6 +878,9 @@ int main(int argc, char* argv[]) case OPT_TEST_PARITY_LIMIT : opt.parity_limit_size = atoll(optarg); break; + case OPT_TEST_SKIP_CONTENT_WRITE : + opt.skip_content_write = 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 92cf181b..12e48b9b 100644 --- a/cmdline/state.h +++ b/cmdline/state.h @@ -102,6 +102,7 @@ struct snapraid_option { unsigned force_scrub_at; /**< Force scrub for the specified number of blocks. */ int force_scrub_even; /**< Force scrub of all the even blocks. */ int force_content_write; /**< Force the update of the content file. */ + int skip_content_write; /**< Skip the update of the content file. */ int force_scan_winfind; /**< Force the use of FindFirst/Next in Windows to list directories. */ int force_progress; /**< Force the use of the progress status. */ unsigned force_autosave_at; /**< Force autosave at the specified block. */ diff --git a/cmdline/sync.c b/cmdline/sync.c index 09000501..95f7147f 100644 --- a/cmdline/sync.c +++ b/cmdline/sync.c @@ -1552,8 +1552,12 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t * Instead, saving the new content file in advance, keeps track of all the parity * that may be modified. */ - if (state->need_write) - state_write(state); + if (!state->opt.skip_content_write) { + if (state->need_write) + state_write(state); + } else { + log_fatal("WARNING! Skipped state write for --test-skip-content-write option.\n"); + } msg_progress("Syncing...\n");