Add option to skip content write in sync

This commit is contained in:
Andrea Mazzoleni 2016-05-17 23:17:31 +02:00
parent bec310d50b
commit 4298a238e9
3 changed files with 14 additions and 2 deletions

View file

@ -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);

View file

@ -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. */

View file

@ -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");