* Convenience function to stop trimming of a vdev tree and set all trim * thread pointers to NULL. */
| 1074 | * thread pointers to NULL. |
| 1075 | */ |
| 1076 | void |
| 1077 | vdev_trim_stop_all(vdev_t *vd, vdev_trim_state_t tgt_state) |
| 1078 | { |
| 1079 | spa_t *spa = vd->vdev_spa; |
| 1080 | list_t vd_list; |
| 1081 | vdev_t *vd_l2cache; |
| 1082 | |
| 1083 | ASSERT(MUTEX_HELD(&spa_namespace_lock)); |
| 1084 | |
| 1085 | list_create(&vd_list, sizeof (vdev_t), |
| 1086 | offsetof(vdev_t, vdev_trim_node)); |
| 1087 | |
| 1088 | vdev_trim_stop_all_impl(vd, tgt_state, &vd_list); |
| 1089 | |
| 1090 | /* |
| 1091 | * Iterate over cache devices and request stop trimming the |
| 1092 | * whole device in case we export the pool or remove the cache |
| 1093 | * device prematurely. |
| 1094 | */ |
| 1095 | for (int i = 0; i < spa->spa_l2cache.sav_count; i++) { |
| 1096 | vd_l2cache = spa->spa_l2cache.sav_vdevs[i]; |
| 1097 | vdev_trim_stop_all_impl(vd_l2cache, tgt_state, &vd_list); |
| 1098 | } |
| 1099 | |
| 1100 | vdev_trim_stop_wait(spa, &vd_list); |
| 1101 | |
| 1102 | if (vd->vdev_spa->spa_sync_on) { |
| 1103 | /* Make sure that our state has been synced to disk */ |
| 1104 | txg_wait_synced(spa_get_dsl(vd->vdev_spa), 0); |
| 1105 | } |
| 1106 | |
| 1107 | list_destroy(&vd_list); |
| 1108 | } |
| 1109 | |
| 1110 | /* |
| 1111 | * Conditionally restarts a manual TRIM given its on-disk state. |
no test coverage detected