ARGSUSED */
| 6515 | |
| 6516 | /* ARGSUSED */ |
| 6517 | void |
| 6518 | ztest_trim(ztest_ds_t *zd, uint64_t id) |
| 6519 | { |
| 6520 | spa_t *spa = ztest_spa; |
| 6521 | int error = 0; |
| 6522 | |
| 6523 | mutex_enter(&ztest_vdev_lock); |
| 6524 | |
| 6525 | spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER); |
| 6526 | |
| 6527 | /* Random leaf vdev */ |
| 6528 | vdev_t *rand_vd = ztest_random_concrete_vdev_leaf(spa->spa_root_vdev); |
| 6529 | if (rand_vd == NULL) { |
| 6530 | spa_config_exit(spa, SCL_VDEV, FTAG); |
| 6531 | mutex_exit(&ztest_vdev_lock); |
| 6532 | return; |
| 6533 | } |
| 6534 | |
| 6535 | /* |
| 6536 | * The random vdev we've selected may change as soon as we |
| 6537 | * drop the spa_config_lock. We create local copies of things |
| 6538 | * we're interested in. |
| 6539 | */ |
| 6540 | uint64_t guid = rand_vd->vdev_guid; |
| 6541 | char *path = strdup(rand_vd->vdev_path); |
| 6542 | boolean_t active = rand_vd->vdev_trim_thread != NULL; |
| 6543 | |
| 6544 | zfs_dbgmsg("vd %p, guid %llu", rand_vd, guid); |
| 6545 | spa_config_exit(spa, SCL_VDEV, FTAG); |
| 6546 | |
| 6547 | uint64_t cmd = ztest_random(POOL_TRIM_FUNCS); |
| 6548 | uint64_t rate = 1 << ztest_random(30); |
| 6549 | boolean_t partial = (ztest_random(5) > 0); |
| 6550 | boolean_t secure = (ztest_random(5) > 0); |
| 6551 | |
| 6552 | nvlist_t *vdev_guids = fnvlist_alloc(); |
| 6553 | nvlist_t *vdev_errlist = fnvlist_alloc(); |
| 6554 | fnvlist_add_uint64(vdev_guids, path, guid); |
| 6555 | error = spa_vdev_trim(spa, vdev_guids, cmd, rate, partial, |
| 6556 | secure, vdev_errlist); |
| 6557 | fnvlist_free(vdev_guids); |
| 6558 | fnvlist_free(vdev_errlist); |
| 6559 | |
| 6560 | switch (cmd) { |
| 6561 | case POOL_TRIM_CANCEL: |
| 6562 | if (ztest_opts.zo_verbose >= 4) { |
| 6563 | (void) printf("Cancel TRIM %s", path); |
| 6564 | if (!active) |
| 6565 | (void) printf(" failed (no TRIM active)"); |
| 6566 | (void) printf("\n"); |
| 6567 | } |
| 6568 | break; |
| 6569 | case POOL_TRIM_START: |
| 6570 | if (ztest_opts.zo_verbose >= 4) { |
| 6571 | (void) printf("Start TRIM %s", path); |
| 6572 | if (active && error == 0) |
| 6573 | (void) printf(" failed (already active)"); |
| 6574 | else if (error != 0) |
nothing calls this directly
no test coverage detected