939 ASSERT(zio->io_error != 0);
940 zfs_ereport_post(FM_EREPORT_ZFS_PROBE_FAILURE,
941 spa, vd, NULL, 0, 0);
942 zio->io_error = SET_ERROR(ENXIO);
943 }
944
945 mutex_enter(&vd->vdev_probe_lock);
946 ASSERT(vd->vdev_probe_zio == zio);
947 vd->vdev_probe_zio = NULL;
948 mutex_exit(&vd->vdev_probe_lock);
949
950 while ((pio = zio_walk_parents(zio)) != NULL)
951 if (!vdev_accessible(vd, pio))
952 pio->io_error = SET_ERROR(ENXIO);
953
954 kmem_free(vps, sizeof (*vps));
955 }
956 }
957
958 /*
959 * Determine whether this device is accessible by reading and writing
960 * to several known locations: the pad regions of each vdev label
961 * but the first (which we leave alone in case it contains a VTOC).
962 */
963 zio_t *
964 vdev_probe(vdev_t *vd, zio_t *zio)
965 {
966 spa_t *spa = vd->vdev_spa;
967 vdev_probe_stats_t *vps = NULL;
968 zio_t *pio;
969
970 ASSERT(vd->vdev_ops->vdev_op_leaf);
971
972 /*
973 * Don't probe the probe.
974 */
975 if (zio && (zio->io_flags & ZIO_FLAG_PROBE))
976 return (NULL);
977
978 /*
979 * To prevent 'probe storms' when a device fails, we create
980 * just one probe i/o at a time. All zios that want to probe
981 * this vdev will become parents of the probe io.
2162 return (spa_vdev_state_exit(spa, NULL, ENODEV));
2163
2164 if (!vd->vdev_ops->vdev_op_leaf)
2165 return (spa_vdev_state_exit(spa, NULL, ENOTSUP));
2166
2167 /*
2168 * If the vdev is already faulted, then don't do anything.
2169 */
2170 if (vd->vdev_faulted || vd->vdev_degraded)
2171 return (spa_vdev_state_exit(spa, NULL, 0));
2172
2173 vd->vdev_degraded = 1ULL;
2174 if (!vdev_is_dead(vd))
2175 vdev_set_state(vd, B_FALSE, VDEV_STATE_DEGRADED,
2176 aux);
2177
2178 return (spa_vdev_state_exit(spa, vd, 0));
2179 }
2180
2181 /*
2182 * Online the given vdev. If 'unspare' is set, it implies two things. First,
2183 * any attached spare device should be detached when the device finishes
2184 * resilvering. Second, the online should be treated like a 'test' online case,
2185 * so no FMA events are generated if the device fails to open.
2186 */
2187 int
2188 vdev_online(spa_t *spa, uint64_t guid, uint64_t flags, vdev_state_t *newstate)
2189 {
2190 vdev_t *vd, *tvd, *pvd, *rvd = spa->spa_root_vdev;
2191
2192 spa_vdev_state_enter(spa, SCL_NONE);
2193
2194 if ((vd = spa_lookup_by_guid(spa, guid, B_TRUE)) == NULL)
2195 return (spa_vdev_state_exit(spa, NULL, ENODEV));
2196
2197 if (!vd->vdev_ops->vdev_op_leaf)
2198 return (spa_vdev_state_exit(spa, NULL, ENOTSUP));
2199
2200 tvd = vd->vdev_top;
2201 vd->vdev_offline = B_FALSE;
2202 vd->vdev_tmpoffline = B_FALSE;
2203 vd->vdev_checkremove = !!(flags & ZFS_ONLINE_CHECKREMOVE);
2204 vd->vdev_forcefault = !!(flags & ZFS_ONLINE_FORCEFAULT);
2205
|
939 ASSERT(zio->io_error != 0);
940 zfs_ereport_post(FM_EREPORT_ZFS_PROBE_FAILURE,
941 spa, vd, NULL, 0, 0);
942 zio->io_error = SET_ERROR(ENXIO);
943 }
944
945 mutex_enter(&vd->vdev_probe_lock);
946 ASSERT(vd->vdev_probe_zio == zio);
947 vd->vdev_probe_zio = NULL;
948 mutex_exit(&vd->vdev_probe_lock);
949
950 while ((pio = zio_walk_parents(zio)) != NULL)
951 if (!vdev_accessible(vd, pio))
952 pio->io_error = SET_ERROR(ENXIO);
953
954 kmem_free(vps, sizeof (*vps));
955 }
956 }
957
958 /*
959 * Determine whether this device is accessible.
960 *
961 * Read and write to several known locations: the pad regions of each
962 * vdev label but the first, which we leave alone in case it contains
963 * a VTOC.
964 */
965 zio_t *
966 vdev_probe(vdev_t *vd, zio_t *zio)
967 {
968 spa_t *spa = vd->vdev_spa;
969 vdev_probe_stats_t *vps = NULL;
970 zio_t *pio;
971
972 ASSERT(vd->vdev_ops->vdev_op_leaf);
973
974 /*
975 * Don't probe the probe.
976 */
977 if (zio && (zio->io_flags & ZIO_FLAG_PROBE))
978 return (NULL);
979
980 /*
981 * To prevent 'probe storms' when a device fails, we create
982 * just one probe i/o at a time. All zios that want to probe
983 * this vdev will become parents of the probe io.
2164 return (spa_vdev_state_exit(spa, NULL, ENODEV));
2165
2166 if (!vd->vdev_ops->vdev_op_leaf)
2167 return (spa_vdev_state_exit(spa, NULL, ENOTSUP));
2168
2169 /*
2170 * If the vdev is already faulted, then don't do anything.
2171 */
2172 if (vd->vdev_faulted || vd->vdev_degraded)
2173 return (spa_vdev_state_exit(spa, NULL, 0));
2174
2175 vd->vdev_degraded = 1ULL;
2176 if (!vdev_is_dead(vd))
2177 vdev_set_state(vd, B_FALSE, VDEV_STATE_DEGRADED,
2178 aux);
2179
2180 return (spa_vdev_state_exit(spa, vd, 0));
2181 }
2182
2183 /*
2184 * Online the given vdev.
2185 *
2186 * If 'ZFS_ONLINE_UNSPARE' is set, it implies two things. First, any attached
2187 * spare device should be detached when the device finishes resilvering.
2188 * Second, the online should be treated like a 'test' online case, so no FMA
2189 * events are generated if the device fails to open.
2190 */
2191 int
2192 vdev_online(spa_t *spa, uint64_t guid, uint64_t flags, vdev_state_t *newstate)
2193 {
2194 vdev_t *vd, *tvd, *pvd, *rvd = spa->spa_root_vdev;
2195
2196 spa_vdev_state_enter(spa, SCL_NONE);
2197
2198 if ((vd = spa_lookup_by_guid(spa, guid, B_TRUE)) == NULL)
2199 return (spa_vdev_state_exit(spa, NULL, ENODEV));
2200
2201 if (!vd->vdev_ops->vdev_op_leaf)
2202 return (spa_vdev_state_exit(spa, NULL, ENOTSUP));
2203
2204 tvd = vd->vdev_top;
2205 vd->vdev_offline = B_FALSE;
2206 vd->vdev_tmpoffline = B_FALSE;
2207 vd->vdev_checkremove = !!(flags & ZFS_ONLINE_CHECKREMOVE);
2208 vd->vdev_forcefault = !!(flags & ZFS_ONLINE_FORCEFAULT);
2209
|