Skip to content

Commit

Permalink
Review feedback 2
Browse files Browse the repository at this point in the history
* Fixed missing taskq_destroy when exporting a pool which is
  being actively trimmed.
* Add auto/manual TRIM coverage to ztest.
* Temporarily disable manualtrim_004_pos.

Signed-off-by: Brian Behlendorf <[email protected]>
  • Loading branch information
behlendorf committed Jun 1, 2017
1 parent 794eae7 commit 00c6144
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cmd/ztest/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ ztest_func_t ztest_spa_upgrade;
ztest_func_t ztest_fletcher;
ztest_func_t ztest_fletcher_incr;
ztest_func_t ztest_verify_dnode_bt;
ztest_func_t ztest_man_trim;

uint64_t zopt_always = 0ULL * NANOSEC; /* all the time */
uint64_t zopt_incessant = 1ULL * NANOSEC / 10; /* every 1/10 second */
Expand Down Expand Up @@ -384,6 +385,7 @@ ztest_info_t ztest_info[] = {
ZTI_INIT(ztest_fletcher, 1, &zopt_rarely),
ZTI_INIT(ztest_fletcher_incr, 1, &zopt_rarely),
ZTI_INIT(ztest_verify_dnode_bt, 1, &zopt_sometimes),
ZTI_INIT(ztest_man_trim, 1, &zopt_sometimes),
};

#define ZTEST_FUNCS (sizeof (ztest_info) / sizeof (ztest_info_t))
Expand Down Expand Up @@ -5017,6 +5019,21 @@ ztest_verify_dnode_bt(ztest_ds_t *zd, uint64_t id)
}
}

/*
* Start then stop a manual TRIM.
*/
void
ztest_man_trim(ztest_ds_t *zd, uint64_t id)
{
uint64_t rate = 1 << ztest_random(30);
boolean_t fulltrim = (ztest_random(5) > 0);
spa_t *spa = ztest_spa;

spa_man_trim(spa, rate, fulltrim);
(void) poll(NULL, 0, 100); /* wait a moment, then stop the TRIM. */
spa_man_trim_stop(spa);
}

/* ARGSUSED */
void
ztest_dsl_prop_get_set(ztest_ds_t *zd, uint64_t id)
Expand Down Expand Up @@ -5052,6 +5069,8 @@ ztest_spa_prop_get_set(ztest_ds_t *zd, uint64_t id)
(void) ztest_spa_prop_set_uint64(ZPOOL_PROP_DEDUPDITTO,
ZIO_DEDUPDITTO_MIN + ztest_random(ZIO_DEDUPDITTO_MIN));

(void) ztest_spa_prop_set_uint64(ZPOOL_PROP_AUTOTRIM, ztest_random(2));

VERIFY0(spa_prop_get(ztest_spa, &props));

if (ztest_opts.zo_verbose >= 6)
Expand Down
9 changes: 9 additions & 0 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,15 @@ spa_unload(spa_t *spa)
spa_auto_trim_taskq_destroy(spa);
mutex_exit(&spa->spa_auto_trim_lock);

/*
* Destroy manual trim taskq if needed, this may be required if the
* async task was unable to run prior to being suspended.
*/
mutex_enter(&spa->spa_man_trim_lock);
if (spa->spa_man_trim_taskq)
spa_man_trim_taskq_destroy(spa);
mutex_exit(&spa->spa_man_trim_lock);

/*
* Even though vdev_free() also calls vdev_metaslab_fini, we need
* to call it earlier, before we wait for async i/o to complete.
Expand Down
3 changes: 3 additions & 0 deletions tests/zfs-tests/tests/functional/trim/manualtrim_004_pos.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ verify_runnable "global"
log_assert "Verify 'zpool online|offline|replace' while TRIMming"
log_onexit cleanup_trim

# XXX - Disabled for automated testing only
log_unsupported "Skipping until issue is resolved"

log_must truncate -s $VDEV_SIZE $VDEVS
log_must zpool create -o cachefile=none -f $TRIMPOOL raidz $VDEVS

Expand Down

0 comments on commit 00c6144

Please sign in to comment.