* Stop trimming a device, with the resultant trimming state being tgt_state. * For blocking behavior pass NULL for vd_list. Otherwise, when a list_t is * provided the stopping vdev is inserted in to the list. Callers are then * required to call vdev_trim_stop_wait() to block for all the trim threads * to exit. The caller must hold vdev_trim_lock and must not be writing to * the spa config,
| 1024 | * reader before exiting. |
| 1025 | */ |
| 1026 | void |
| 1027 | vdev_trim_stop(vdev_t *vd, vdev_trim_state_t tgt_state, list_t *vd_list) |
| 1028 | { |
| 1029 | ASSERT(!spa_config_held(vd->vdev_spa, SCL_CONFIG|SCL_STATE, RW_WRITER)); |
| 1030 | ASSERT(MUTEX_HELD(&vd->vdev_trim_lock)); |
| 1031 | ASSERT(vd->vdev_ops->vdev_op_leaf); |
| 1032 | ASSERT(vdev_is_concrete(vd)); |
| 1033 | |
| 1034 | /* |
| 1035 | * Allow cancel requests to proceed even if the trim thread has |
| 1036 | * stopped. |
| 1037 | */ |
| 1038 | if (vd->vdev_trim_thread == NULL && tgt_state != VDEV_TRIM_CANCELED) |
| 1039 | return; |
| 1040 | |
| 1041 | vdev_trim_change_state(vd, tgt_state, 0, 0, 0); |
| 1042 | vd->vdev_trim_exit_wanted = B_TRUE; |
| 1043 | |
| 1044 | if (vd_list == NULL) { |
| 1045 | vdev_trim_stop_wait_impl(vd); |
| 1046 | } else { |
| 1047 | ASSERT(MUTEX_HELD(&spa_namespace_lock)); |
| 1048 | list_insert_tail(vd_list, vd); |
| 1049 | } |
| 1050 | } |
| 1051 | |
| 1052 | /* |
| 1053 | * Requests that all listed vdevs stop trimming. |
no test coverage detected