aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/spa_misc.c
diff options
context:
space:
mode:
authorTony Hutter <[email protected]>2018-06-06 09:33:54 -0700
committerBrian Behlendorf <[email protected]>2018-06-06 09:33:54 -0700
commitf0ed6c744872ec6dc4838947ffc597f4d141864a (patch)
treec82a6cc535f94c2a1f7656b2224195d9c2b81eda /module/zfs/spa_misc.c
parent2d9142c9d4c9db4edcef4777fecfafa4832610cb (diff)
Add pool state /proc entry, "SUSPENDED" pools
1. Add a proc entry to display the pool's state: $ cat /proc/spl/kstat/zfs/tank/state ONLINE This is done without using the spa config locks, so it will never hang. 2. Fix 'zpool status' and 'zpool list -o health' output to print "SUSPENDED" instead of "ONLINE" for suspended pools. Reviewed-by: Olaf Faaland <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed by: Richard Elling <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #7331 Closes #7563
Diffstat (limited to 'module/zfs/spa_misc.c')
-rw-r--r--module/zfs/spa_misc.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c
index 288e5378b..6c7e2f55c 100644
--- a/module/zfs/spa_misc.c
+++ b/module/zfs/spa_misc.c
@@ -2254,6 +2254,45 @@ spa_set_missing_tvds(spa_t *spa, uint64_t missing)
spa->spa_missing_tvds = missing;
}
+/*
+ * Return the pool state string ("ONLINE", "DEGRADED", "SUSPENDED", etc).
+ */
+const char *
+spa_state_to_name(spa_t *spa)
+{
+ vdev_state_t state = spa->spa_root_vdev->vdev_state;
+ vdev_aux_t aux = spa->spa_root_vdev->vdev_stat.vs_aux;
+
+ if (spa_suspended(spa) &&
+ (spa_get_failmode(spa) != ZIO_FAILURE_MODE_CONTINUE))
+ return ("SUSPENDED");
+
+ switch (state) {
+ case VDEV_STATE_CLOSED:
+ case VDEV_STATE_OFFLINE:
+ return ("OFFLINE");
+ case VDEV_STATE_REMOVED:
+ return ("REMOVED");
+ case VDEV_STATE_CANT_OPEN:
+ if (aux == VDEV_AUX_CORRUPT_DATA || aux == VDEV_AUX_BAD_LOG)
+ return ("FAULTED");
+ else if (aux == VDEV_AUX_SPLIT_POOL)
+ return ("SPLIT");
+ else
+ return ("UNAVAIL");
+ case VDEV_STATE_FAULTED:
+ return ("FAULTED");
+ case VDEV_STATE_DEGRADED:
+ return ("DEGRADED");
+ case VDEV_STATE_HEALTHY:
+ return ("ONLINE");
+ default:
+ break;
+ }
+
+ return ("UNKNOWN");
+}
+
#if defined(_KERNEL)
#include <linux/mod_compat.h>
@@ -2406,6 +2445,7 @@ EXPORT_SYMBOL(spa_namespace_lock);
EXPORT_SYMBOL(spa_trust_config);
EXPORT_SYMBOL(spa_missing_tvds_allowed);
EXPORT_SYMBOL(spa_set_missing_tvds);
+EXPORT_SYMBOL(spa_state_to_name);
/* BEGIN CSTYLED */
module_param(zfs_flags, uint, 0644);