MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vdev_offline_locked

Function vdev_offline_locked

freebsd/contrib/openzfs/module/zfs/vdev.c:3811–3919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3809}
3810
3811static int
3812vdev_offline_locked(spa_t *spa, uint64_t guid, uint64_t flags)
3813{
3814 vdev_t *vd, *tvd;
3815 int error = 0;
3816 uint64_t generation;
3817 metaslab_group_t *mg;
3818
3819top:
3820 spa_vdev_state_enter(spa, SCL_ALLOC);
3821
3822 if ((vd = spa_lookup_by_guid(spa, guid, B_TRUE)) == NULL)
3823 return (spa_vdev_state_exit(spa, NULL, SET_ERROR(ENODEV)));
3824
3825 if (!vd->vdev_ops->vdev_op_leaf)
3826 return (spa_vdev_state_exit(spa, NULL, SET_ERROR(ENOTSUP)));
3827
3828 if (vd->vdev_ops == &vdev_draid_spare_ops)
3829 return (spa_vdev_state_exit(spa, NULL, ENOTSUP));
3830
3831 tvd = vd->vdev_top;
3832 mg = tvd->vdev_mg;
3833 generation = spa->spa_config_generation + 1;
3834
3835 /*
3836 * If the device isn't already offline, try to offline it.
3837 */
3838 if (!vd->vdev_offline) {
3839 /*
3840 * If this device has the only valid copy of some data,
3841 * don't allow it to be offlined. Log devices are always
3842 * expendable.
3843 */
3844 if (!tvd->vdev_islog && vd->vdev_aux == NULL &&
3845 vdev_dtl_required(vd))
3846 return (spa_vdev_state_exit(spa, NULL,
3847 SET_ERROR(EBUSY)));
3848
3849 /*
3850 * If the top-level is a slog and it has had allocations
3851 * then proceed. We check that the vdev's metaslab group
3852 * is not NULL since it's possible that we may have just
3853 * added this vdev but not yet initialized its metaslabs.
3854 */
3855 if (tvd->vdev_islog && mg != NULL) {
3856 /*
3857 * Prevent any future allocations.
3858 */
3859 metaslab_group_passivate(mg);
3860 (void) spa_vdev_state_exit(spa, vd, 0);
3861
3862 error = spa_reset_logs(spa);
3863
3864 /*
3865 * If the log device was successfully reset but has
3866 * checkpointed data, do not offline it.
3867 */
3868 if (error == 0 &&

Callers 1

vdev_offlineFunction · 0.85

Calls 10

spa_vdev_state_enterFunction · 0.85
spa_lookup_by_guidFunction · 0.85
spa_vdev_state_exitFunction · 0.85
vdev_dtl_requiredFunction · 0.85
metaslab_group_passivateFunction · 0.85
spa_reset_logsFunction · 0.85
space_map_allocatedFunction · 0.85
metaslab_group_activateFunction · 0.85
vdev_reopenFunction · 0.85
vdev_is_deadFunction · 0.85

Tested by

no test coverage detected