diff --git a/cmdline/scan.c b/cmdline/scan.c index 148ac0be..cb86cc7e 100644 --- a/cmdline/scan.c +++ b/cmdline/scan.c @@ -1626,7 +1626,10 @@ static int state_diffscan(struct snapraid_state* state, int is_diff) for (i = scanlist; i != 0; i = i->next) { struct snapraid_scan* scan = i->data; #if HAVE_THREAD - thread_create(&scan->thread, scan_disk, scan); + if (state->opt.skip_multi_scan) + scan_disk(scan); + else + thread_create(&scan->thread, scan_disk, scan); #else scan_disk(scan); #endif @@ -1639,7 +1642,8 @@ static int state_diffscan(struct snapraid_state* state, int is_diff) void* retval; /* wait for thread termination */ - thread_join(scan->thread, &retval); + if (!state->opt.skip_multi_scan) + thread_join(scan->thread, &retval); } #endif diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index 36656662..55a943e1 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -307,6 +307,7 @@ void config(char* conf, size_t conf_size, const char* argv0) #define OPT_TEST_SKIP_CONTENT_WRITE 302 #define OPT_TEST_SKIP_SPACE_HOLDER 303 #define OPT_TEST_FORMAT 304 +#define OPT_TEST_SKIP_MULTI_SCAN 305 #if HAVE_GETOPT_LONG struct option long_options[] = { @@ -475,6 +476,9 @@ struct option long_options[] = { /* Set the output format */ { "test-fmt", 1, 0, OPT_TEST_FORMAT }, + /* Skip thread in disk scan */ + { "test-skip-multi-scan", 0, 0, OPT_TEST_SKIP_MULTI_SCAN }, + { 0, 0, 0, 0 } }; #endif @@ -929,6 +933,9 @@ int main(int argc, char* argv[]) /* LCOV_EXCL_STOP */ } break; + case OPT_TEST_SKIP_MULTI_SCAN : + opt.skip_multi_scan = 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 e91e0cfe..d9e30bdd 100644 --- a/cmdline/state.h +++ b/cmdline/state.h @@ -119,6 +119,7 @@ struct snapraid_option { int auto_conf; /**< Allow to run without configuration file. */ int force_stats; /**< Force stats print during process. */ uint64_t parity_limit_size; /**< Test limit for parity files. */ + int skip_multi_scan; /**< Don't use threads in scan. */ }; struct snapraid_state {