From bcdb96a3e197ebe64048464c19f505637b8bb7ba Mon Sep 17 00:00:00 2001 From: N Clark Date: Mon, 3 Apr 2017 17:23:02 -0400 Subject: [PATCH] Additional Information for Zedlets * Add ZPOOL pool state to zfs_post_common to allow differentiation between export and destroy by zedlets. * Add pool name as standard export This ensures pool name is exported to zedlets. Reviewed-by: Tony Hutter Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Signed-off-by: Nathaniel Clark Closes #5942 --- cmd/zed/zed_event.c | 10 ++++++++++ include/sys/fm/fs/zfs.h | 1 + module/zfs/zfs_fm.c | 11 ++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cmd/zed/zed_event.c b/cmd/zed/zed_event.c index b289ebf22dcd..aecdb5146bc8 100644 --- a/cmd/zed/zed_event.c +++ b/cmd/zed/zed_event.c @@ -653,6 +653,16 @@ _zed_event_add_nvpair(uint64_t eid, zed_strings_t *zsp, nvpair_t *nvp) (void) snprintf(alt, sizeof (alt), "%s_str", name); _zed_event_add_var(eid, zsp, prefix, alt, "%s", zpool_state_to_name(i64, VDEV_AUX_NONE)); + } else + /* + * shadow readable strings for pool state + */ + if (strcmp(name, FM_EREPORT_PAYLOAD_ZFS_POOL_STATE) == 0) { + char alt[32]; + + (void) snprintf(alt, sizeof (alt), "%s_str", name); + _zed_event_add_var(eid, zsp, prefix, alt, "%s", + zpool_pool_state_to_name(i32)); } break; case DATA_TYPE_DOUBLE: diff --git a/include/sys/fm/fs/zfs.h b/include/sys/fm/fs/zfs.h index 7a8c36ea274e..6bef8b4eeddd 100644 --- a/include/sys/fm/fs/zfs.h +++ b/include/sys/fm/fs/zfs.h @@ -54,6 +54,7 @@ extern "C" { #define FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE "pool_failmode" #define FM_EREPORT_PAYLOAD_ZFS_POOL_GUID "pool_guid" #define FM_EREPORT_PAYLOAD_ZFS_POOL_CONTEXT "pool_context" +#define FM_EREPORT_PAYLOAD_ZFS_POOL_STATE "pool_state" #define FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID "vdev_guid" #define FM_EREPORT_PAYLOAD_ZFS_VDEV_TYPE "vdev_type" #define FM_EREPORT_PAYLOAD_ZFS_VDEV_PATH "vdev_path" diff --git a/module/zfs/zfs_fm.c b/module/zfs/zfs_fm.c index 684e93d8e9b7..2451bfbc000e 100644 --- a/module/zfs/zfs_fm.c +++ b/module/zfs/zfs_fm.c @@ -266,9 +266,10 @@ zfs_ereport_start(nvlist_t **ereport_out, nvlist_t **detector_out, /* * Generic payload members common to all ereports. */ - fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_POOL, - DATA_TYPE_STRING, spa_name(spa), FM_EREPORT_PAYLOAD_ZFS_POOL_GUID, - DATA_TYPE_UINT64, spa_guid(spa), + fm_payload_set(ereport, + FM_EREPORT_PAYLOAD_ZFS_POOL, DATA_TYPE_STRING, spa_name(spa), + FM_EREPORT_PAYLOAD_ZFS_POOL_GUID, DATA_TYPE_UINT64, spa_guid(spa), + FM_EREPORT_PAYLOAD_ZFS_POOL_STATE, DATA_TYPE_UINT64, spa_state(spa), FM_EREPORT_PAYLOAD_ZFS_POOL_CONTEXT, DATA_TYPE_INT32, spa_load_state(spa), NULL); @@ -920,8 +921,12 @@ zfs_post_common(spa_t *spa, vdev_t *vd, const char *type, const char *name, ZFS_ERROR_CLASS, name); VERIFY0(nvlist_add_uint8(resource, FM_VERSION, FM_RSRC_VERSION)); VERIFY0(nvlist_add_string(resource, FM_CLASS, class)); + VERIFY0(nvlist_add_string(resource, + FM_EREPORT_PAYLOAD_ZFS_POOL, spa_name(spa))); VERIFY0(nvlist_add_uint64(resource, FM_EREPORT_PAYLOAD_ZFS_POOL_GUID, spa_guid(spa))); + VERIFY0(nvlist_add_uint64(resource, + FM_EREPORT_PAYLOAD_ZFS_POOL_STATE, spa_state(spa))); VERIFY0(nvlist_add_int32(resource, FM_EREPORT_PAYLOAD_ZFS_POOL_CONTEXT, spa_load_state(spa)));