raidz_test: respect wall time

When timeout is specified (-t), stop worker threads in the middle of work units.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Gvozden Neskovic <neskovic@gmail.com>
Issue #5180 
Closes #5190
This commit is contained in:
Gvozden Neskovic 2016-10-01 00:19:51 +02:00 committed by Brian Behlendorf
parent 2db28197fe
commit 292d573e70
2 changed files with 28 additions and 10 deletions

View File

@ -369,6 +369,10 @@ run_gen_check(raidz_test_opts_t *opts)
for (fn = 0; fn < RAIDZ_GEN_NUM; fn++) {
/* Check if should stop */
if (rto_opts.rto_should_stop)
return (err);
/* create suitable raidz_map */
rm_test = init_raidz_map(opts, &zio_test, fn+1);
VERIFY(rm_test);
@ -418,6 +422,10 @@ run_rec_check_impl(raidz_test_opts_t *opts, raidz_map_t *rm, const int fn)
if (x0 >= rm->rm_cols - raidz_parity(rm))
continue;
/* Check if should stop */
if (rto_opts.rto_should_stop)
return (err);
LOG(D_DEBUG, "[%d] ", x0);
tgtidx[2] = x0 + raidz_parity(rm);
@ -442,6 +450,10 @@ run_rec_check_impl(raidz_test_opts_t *opts, raidz_map_t *rm, const int fn)
if (x1 >= rm->rm_cols - raidz_parity(rm))
continue;
/* Check if should stop */
if (rto_opts.rto_should_stop)
return (err);
LOG(D_DEBUG, "[%d %d] ", x0, x1);
tgtidx[1] = x0 + raidz_parity(rm);
@ -475,6 +487,10 @@ run_rec_check_impl(raidz_test_opts_t *opts, raidz_map_t *rm, const int fn)
rm->rm_cols - raidz_parity(rm))
continue;
/* Check if should stop */
if (rto_opts.rto_should_stop)
return (err);
LOG(D_DEBUG, "[%d %d %d]", x0, x1, x2);
tgtidx[0] = x0 + raidz_parity(rm);
@ -620,20 +636,19 @@ sweep_thread(void *arg)
static int
run_sweep(void)
{
static const size_t dcols_v[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
static const size_t ashift_v[] = { 9, 12 };
static const size_t offset_cnt = 4;
static const size_t dcols_v[] = { 1, 2, 3, 4, 5, 6, 7, 8, 12, 15, 16 };
static const size_t ashift_v[] = { 9, 12, 14 };
static const size_t size_v[] = { 1 << 9, 21 * (1 << 9), 13 * (1 << 12),
1 << 17, (1 << 20) - (1 << 12), SPA_MAXBLOCKSIZE };
(void) setvbuf(stdout, NULL, _IONBF, 0);
ulong_t total_comb = ARRAY_SIZE(size_v) * ARRAY_SIZE(ashift_v) *
ARRAY_SIZE(dcols_v) * offset_cnt;
ARRAY_SIZE(dcols_v);
ulong_t tried_comb = 0;
hrtime_t time_diff, start_time = gethrtime();
raidz_test_opts_t *opts;
int a, d, o, s;
int a, d, s;
max_free_slots = free_slots = MAX(2, boot_ncpus);
@ -642,11 +657,9 @@ run_sweep(void)
for (s = 0; s < ARRAY_SIZE(size_v); s++)
for (a = 0; a < ARRAY_SIZE(ashift_v); a++)
for (o = 0; o < offset_cnt; o++)
for (d = 0; d < ARRAY_SIZE(dcols_v); d++) {
if ((size_v[s] < (1 << ashift_v[a]) * o) ||
(size_v[s] < (1 << ashift_v[a]) * dcols_v[d])) {
if (size_v[s] < (1 << ashift_v[a])) {
total_comb--;
continue;
}
@ -664,6 +677,7 @@ run_sweep(void)
if (rto_opts.rto_sweep_timeout > 0 &&
time_diff >= rto_opts.rto_sweep_timeout) {
sweep_state = SWEEP_TIMEOUT;
rto_opts.rto_should_stop = B_TRUE;
mutex_exit(&sem_mtx);
goto exit;
}
@ -686,7 +700,7 @@ run_sweep(void)
opts = umem_zalloc(sizeof (raidz_test_opts_t), UMEM_NOFAIL);
opts->rto_ashift = ashift_v[a];
opts->rto_dcols = dcols_v[d];
opts->rto_offset = (1 << ashift_v[a]) * o;
opts->rto_offset = (1 << ashift_v[a]) * rand();
opts->rto_dsize = size_v[s];
opts->rto_v = 0; /* be quiet */

View File

@ -49,6 +49,9 @@ typedef struct raidz_test_opts {
size_t rto_sanity;
size_t rto_gdb;
/* non-user options */
boolean_t rto_should_stop;
zio_t *zio_golden;
raidz_map_t *rm_golden;
} raidz_test_opts_t;
@ -62,7 +65,8 @@ static const raidz_test_opts_t rto_opts_defaults = {
.rto_sweep = 0,
.rto_benchmark = 0,
.rto_sanity = 0,
.rto_gdb = 0
.rto_gdb = 0,
.rto_should_stop = B_FALSE
};
extern raidz_test_opts_t rto_opts;