| 160 | } |
| 161 | |
| 162 | static void |
| 163 | vdev_initialize_cb(zio_t *zio) |
| 164 | { |
| 165 | vdev_t *vd = zio->io_vd; |
| 166 | mutex_enter(&vd->vdev_initialize_io_lock); |
| 167 | if (zio->io_error == ENXIO && !vdev_writeable(vd)) { |
| 168 | /* |
| 169 | * The I/O failed because the vdev was unavailable; roll the |
| 170 | * last offset back. (This works because spa_sync waits on |
| 171 | * spa_txg_zio before it runs sync tasks.) |
| 172 | */ |
| 173 | uint64_t *off = |
| 174 | &vd->vdev_initialize_offset[zio->io_txg & TXG_MASK]; |
| 175 | *off = MIN(*off, zio->io_offset); |
| 176 | } else { |
| 177 | /* |
| 178 | * Since initializing is best-effort, we ignore I/O errors and |
| 179 | * rely on vdev_probe to determine if the errors are more |
| 180 | * critical. |
| 181 | */ |
| 182 | if (zio->io_error != 0) |
| 183 | vd->vdev_stat.vs_initialize_errors++; |
| 184 | |
| 185 | vd->vdev_initialize_bytes_done += zio->io_orig_size; |
| 186 | } |
| 187 | ASSERT3U(vd->vdev_initialize_inflight, >, 0); |
| 188 | vd->vdev_initialize_inflight--; |
| 189 | cv_broadcast(&vd->vdev_initialize_io_cv); |
| 190 | mutex_exit(&vd->vdev_initialize_io_lock); |
| 191 | |
| 192 | spa_config_exit(vd->vdev_spa, SCL_STATE_ALL, vd); |
| 193 | } |
| 194 | |
| 195 | /* Takes care of physical writing and limiting # of concurrent ZIOs. */ |
| 196 | static int |
nothing calls this directly
no test coverage detected