aboutsummaryrefslogtreecommitdiff
path: root/sys/cddl
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2007-11-05 21:30:48 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2007-11-05 21:30:48 +0000
commita33b7a8f5fcecf6023e970e0b5c1ca6307308a4f (patch)
tree4a4754aeb070f65222eabbb0d12e4a9438801a0b /sys/cddl
parent907aa905189abde933efd20815498b236833c68e (diff)
downloadsrc-a33b7a8f5fcecf6023e970e0b5c1ca6307308a4f.tar.gz
src-a33b7a8f5fcecf6023e970e0b5c1ca6307308a4f.zip
If setting a state to anything but open state, close access to vdev.
This fixes replacing drive in place, eg. zpool replace tank da1 da1. Before it complained that device is already open. MFC after: 1 week
Notes
Notes: svn path=/head/; revision=173373
Diffstat (limited to 'sys/cddl')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
index e6077444694a..b966099f4640 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
@@ -1846,6 +1846,17 @@ vdev_set_state(vdev_t *vd, boolean_t isopen, vdev_state_t state, vdev_aux_t aux)
vd->vdev_state = state;
vd->vdev_stat.vs_aux = aux;
+ /*
+ * If we are setting the vdev state to anything but an open state, then
+ * always close the underlying device. Otherwise, we keep accessible
+ * but invalid devices open forever. We don't call vdev_close() itself,
+ * because that implies some extra checks (offline, etc) that we don't
+ * want here. This is limited to leaf devices, because otherwise
+ * closing the device will affect other children.
+ */
+ if (vdev_is_dead(vd) && vd->vdev_ops->vdev_op_leaf)
+ vd->vdev_ops->vdev_op_close(vd);
+
if (state == VDEV_STATE_CANT_OPEN) {
/*
* If we fail to open a vdev during an import, we mark it as