diff options
author | Tony Hutter <[email protected]> | 2017-05-19 12:30:16 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-05-19 12:30:16 -0700 |
commit | 4a283c7f77eb5065e9f03b122bf8ead4f4a1e2be (patch) | |
tree | 2a4daf72ae62343aa7f24305a592fc2f31bb2eeb /lib | |
parent | a32df59e187a6187eb96c52b93cf02e8af51f327 (diff) |
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 <[email protected]>
Signed-off-by: Tony Hutter <[email protected]>
Closes #6094
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/libzfs_pool.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index e64d0365a..28ccf8f4d 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -2371,6 +2371,43 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *path, const char *msg) } /* + * Convert a vdev path to a GUID. Returns GUID or 0 on error. + * + * If is_spare, is_l2cache, or is_log is non-NULL, then store within it + * if the VDEV is a spare, l2cache, or log device. If they're NULL then + * ignore them. + */ +static uint64_t +zpool_vdev_path_to_guid_impl(zpool_handle_t *zhp, const char *path, + boolean_t *is_spare, boolean_t *is_l2cache, boolean_t *is_log) +{ + uint64_t guid; + boolean_t spare = B_FALSE, l2cache = B_FALSE, log = B_FALSE; + nvlist_t *tgt; + + if ((tgt = zpool_find_vdev(zhp, path, &spare, &l2cache, + &log)) == NULL) + return (0); + + verify(nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_GUID, &guid) == 0); + if (is_spare != NULL) + *is_spare = spare; + if (is_l2cache != NULL) + *is_l2cache = l2cache; + if (is_log != NULL) + *is_log = log; + + return (guid); +} + +/* Convert a vdev path to a GUID. Returns GUID or 0 on error. */ +uint64_t +zpool_vdev_path_to_guid(zpool_handle_t *zhp, const char *path) +{ + return (zpool_vdev_path_to_guid_impl(zhp, path, NULL, NULL, NULL)); +} + +/* * Bring the specified vdev online. The 'flags' parameter is a set of the * ZFS_ONLINE_* flags. */ |