From 4a283c7f77eb5065e9f03b122bf8ead4f4a1e2be Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Fri, 19 May 2017 12:30:16 -0700 Subject: Force fault a vdev with 'zpool offline -f' This patch adds a '-f' option to 'zpool offline' to fault a vdev instead of bringing it offline. Unlike the OFFLINE state, the FAULTED state will trigger the FMA code, allowing for things like autoreplace and triggering the slot fault LED. The -f faults persist across imports, unless they were set with the temporary (-t) flag. Both persistent and temporary faults can be cleared with zpool clear. Reviewed-by: Brian Behlendorf Signed-off-by: Tony Hutter Closes #6094 --- module/zfs/vdev_label.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'module/zfs/vdev_label.c') diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 20c0ac86a..021f4774b 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -519,6 +519,7 @@ vdev_config_generate(spa_t *spa, vdev_t *vd, boolean_t getstats, if (vd->vdev_ishole) fnvlist_add_uint64(nv, ZPOOL_CONFIG_IS_HOLE, B_TRUE); + /* Set the reason why we're FAULTED/DEGRADED. */ switch (vd->vdev_stat.vs_aux) { case VDEV_AUX_ERR_EXCEEDED: aux = "err_exceeded"; @@ -529,8 +530,15 @@ vdev_config_generate(spa_t *spa, vdev_t *vd, boolean_t getstats, break; } - if (aux != NULL) + if (aux != NULL && !vd->vdev_tmpoffline) { fnvlist_add_string(nv, ZPOOL_CONFIG_AUX_STATE, aux); + } else { + /* + * We're healthy - clear any previous AUX_STATE values. + */ + if (nvlist_exists(nv, ZPOOL_CONFIG_AUX_STATE)) + nvlist_remove_all(nv, ZPOOL_CONFIG_AUX_STATE); + } if (vd->vdev_splitting && vd->vdev_orig_guid != 0LL) { fnvlist_add_uint64(nv, ZPOOL_CONFIG_ORIG_GUID, -- cgit v1.2.3