| 1480 | } vdev_probe_stats_t; |
| 1481 | |
| 1482 | static void |
| 1483 | vdev_probe_done(zio_t *zio) |
| 1484 | { |
| 1485 | spa_t *spa = zio->io_spa; |
| 1486 | vdev_t *vd = zio->io_vd; |
| 1487 | vdev_probe_stats_t *vps = zio->io_private; |
| 1488 | |
| 1489 | ASSERT(vd->vdev_probe_zio != NULL); |
| 1490 | |
| 1491 | if (zio->io_type == ZIO_TYPE_READ) { |
| 1492 | if (zio->io_error == 0) |
| 1493 | vps->vps_readable = 1; |
| 1494 | if (zio->io_error == 0 && spa_writeable(spa)) { |
| 1495 | zio_nowait(zio_write_phys(vd->vdev_probe_zio, vd, |
| 1496 | zio->io_offset, zio->io_size, zio->io_abd, |
| 1497 | ZIO_CHECKSUM_OFF, vdev_probe_done, vps, |
| 1498 | ZIO_PRIORITY_SYNC_WRITE, vps->vps_flags, B_TRUE)); |
| 1499 | } else { |
| 1500 | abd_free(zio->io_abd); |
| 1501 | } |
| 1502 | } else if (zio->io_type == ZIO_TYPE_WRITE) { |
| 1503 | if (zio->io_error == 0) |
| 1504 | vps->vps_writeable = 1; |
| 1505 | abd_free(zio->io_abd); |
| 1506 | } else if (zio->io_type == ZIO_TYPE_NULL) { |
| 1507 | zio_t *pio; |
| 1508 | zio_link_t *zl; |
| 1509 | |
| 1510 | vd->vdev_cant_read |= !vps->vps_readable; |
| 1511 | vd->vdev_cant_write |= !vps->vps_writeable; |
| 1512 | |
| 1513 | if (vdev_readable(vd) && |
| 1514 | (vdev_writeable(vd) || !spa_writeable(spa))) { |
| 1515 | zio->io_error = 0; |
| 1516 | } else { |
| 1517 | ASSERT(zio->io_error != 0); |
| 1518 | vdev_dbgmsg(vd, "failed probe"); |
| 1519 | (void) zfs_ereport_post(FM_EREPORT_ZFS_PROBE_FAILURE, |
| 1520 | spa, vd, NULL, NULL, 0); |
| 1521 | zio->io_error = SET_ERROR(ENXIO); |
| 1522 | } |
| 1523 | |
| 1524 | mutex_enter(&vd->vdev_probe_lock); |
| 1525 | ASSERT(vd->vdev_probe_zio == zio); |
| 1526 | vd->vdev_probe_zio = NULL; |
| 1527 | mutex_exit(&vd->vdev_probe_lock); |
| 1528 | |
| 1529 | zl = NULL; |
| 1530 | while ((pio = zio_walk_parents(zio, &zl)) != NULL) |
| 1531 | if (!vdev_accessible(vd, pio)) |
| 1532 | pio->io_error = SET_ERROR(ENXIO); |
| 1533 | |
| 1534 | kmem_free(vps, sizeof (*vps)); |
| 1535 | } |
| 1536 | } |
| 1537 | |
| 1538 | /* |
| 1539 | * Determine whether this device is accessible. |
nothing calls this directly
no test coverage detected