* Clear the error counts associated with this vdev. Unlike vdev_online() and * vdev_offline(), we assume the spa config is locked. We also clear all * children. If 'vd' is NULL, then the user wants to clear all vdevs. */
| 3936 | * children. If 'vd' is NULL, then the user wants to clear all vdevs. |
| 3937 | */ |
| 3938 | void |
| 3939 | vdev_clear(spa_t *spa, vdev_t *vd) |
| 3940 | { |
| 3941 | vdev_t *rvd = spa->spa_root_vdev; |
| 3942 | |
| 3943 | ASSERT(spa_config_held(spa, SCL_STATE_ALL, RW_WRITER) == SCL_STATE_ALL); |
| 3944 | |
| 3945 | if (vd == NULL) |
| 3946 | vd = rvd; |
| 3947 | |
| 3948 | vd->vdev_stat.vs_read_errors = 0; |
| 3949 | vd->vdev_stat.vs_write_errors = 0; |
| 3950 | vd->vdev_stat.vs_checksum_errors = 0; |
| 3951 | vd->vdev_stat.vs_slow_ios = 0; |
| 3952 | |
| 3953 | for (int c = 0; c < vd->vdev_children; c++) |
| 3954 | vdev_clear(spa, vd->vdev_child[c]); |
| 3955 | |
| 3956 | /* |
| 3957 | * It makes no sense to "clear" an indirect vdev. |
| 3958 | */ |
| 3959 | if (!vdev_is_concrete(vd)) |
| 3960 | return; |
| 3961 | |
| 3962 | /* |
| 3963 | * If we're in the FAULTED state or have experienced failed I/O, then |
| 3964 | * clear the persistent state and attempt to reopen the device. We |
| 3965 | * also mark the vdev config dirty, so that the new faulted state is |
| 3966 | * written out to disk. |
| 3967 | */ |
| 3968 | if (vd->vdev_faulted || vd->vdev_degraded || |
| 3969 | !vdev_readable(vd) || !vdev_writeable(vd)) { |
| 3970 | /* |
| 3971 | * When reopening in response to a clear event, it may be due to |
| 3972 | * a fmadm repair request. In this case, if the device is |
| 3973 | * still broken, we want to still post the ereport again. |
| 3974 | */ |
| 3975 | vd->vdev_forcefault = B_TRUE; |
| 3976 | |
| 3977 | vd->vdev_faulted = vd->vdev_degraded = 0ULL; |
| 3978 | vd->vdev_cant_read = B_FALSE; |
| 3979 | vd->vdev_cant_write = B_FALSE; |
| 3980 | vd->vdev_stat.vs_aux = 0; |
| 3981 | |
| 3982 | vdev_reopen(vd == rvd ? rvd : vd->vdev_top); |
| 3983 | |
| 3984 | vd->vdev_forcefault = B_FALSE; |
| 3985 | |
| 3986 | if (vd != rvd && vdev_writeable(vd->vdev_top)) |
| 3987 | vdev_state_dirty(vd->vdev_top); |
| 3988 | |
| 3989 | /* If a resilver isn't required, check if vdevs can be culled */ |
| 3990 | if (vd->vdev_aux == NULL && !vdev_is_dead(vd) && |
| 3991 | !dsl_scan_resilvering(spa->spa_dsl_pool) && |
| 3992 | !dsl_scan_resilver_scheduled(spa->spa_dsl_pool)) |
| 3993 | spa_async_request(spa, SPA_ASYNC_RESILVER_DONE); |
| 3994 | |
| 3995 | spa_event_notify(spa, vd, NULL, ESC_ZFS_VDEV_CLEAR); |