diff options
author | Don Brady <[email protected]> | 2016-08-31 15:46:58 -0600 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-09-01 11:39:45 -0700 |
commit | d02ca379795a37b8541da5a1b37528f7130de1e6 (patch) | |
tree | 67167cfd23f15abeccefe553400bf37dd1032399 /module/zfs/zfs_fm.c | |
parent | 0b284702b75aa712a7d1353b93e19d5b2c783f27 (diff) |
Bring over illumos ZFS FMA logic -- phase 1
This first phase brings over the ZFS SLM module, zfs_mod.c, to handle
auto operations in response to disk events. Disk event monitoring is
provided from libudev and generates the expected payload schema for
zfs_mod. This work leverages the recently added devid and phys_path
strings in the vdev label.
Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Don Brady <[email protected]>
Signed-off-by: Tony Hutter <[email protected]>
Closes #4673
Diffstat (limited to 'module/zfs/zfs_fm.c')
-rw-r--r-- | module/zfs/zfs_fm.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/module/zfs/zfs_fm.c b/module/zfs/zfs_fm.c index 0871fa95b..0d508c0b8 100644 --- a/module/zfs/zfs_fm.c +++ b/module/zfs/zfs_fm.c @@ -848,7 +848,8 @@ zfs_ereport_post_checksum(spa_t *spa, vdev_t *vd, } static void -zfs_post_common(spa_t *spa, vdev_t *vd, const char *type, const char *name) +zfs_post_common(spa_t *spa, vdev_t *vd, const char *type, const char *name, + nvlist_t *aux) { #ifdef _KERNEL nvlist_t *resource; @@ -883,6 +884,13 @@ zfs_post_common(spa_t *spa, vdev_t *vd, const char *type, const char *name) if (vd->vdev_fru != NULL) VERIFY0(nvlist_add_string(resource, FM_EREPORT_PAYLOAD_ZFS_VDEV_FRU, vd->vdev_fru)); + /* also copy any optional payload data */ + if (aux) { + nvpair_t *elem = NULL; + + while ((elem = nvlist_next_nvpair(aux, elem)) != NULL) + (void) nvlist_add_nvpair(resource, elem); + } } zfs_zevent_post(resource, NULL, zfs_zevent_post_cb); @@ -898,7 +906,7 @@ zfs_post_common(spa_t *spa, vdev_t *vd, const char *type, const char *name) void zfs_post_remove(spa_t *spa, vdev_t *vd) { - zfs_post_common(spa, vd, FM_RSRC_CLASS, FM_RESOURCE_REMOVED); + zfs_post_common(spa, vd, FM_RSRC_CLASS, FM_RESOURCE_REMOVED, NULL); } /* @@ -909,7 +917,7 @@ zfs_post_remove(spa_t *spa, vdev_t *vd) void zfs_post_autoreplace(spa_t *spa, vdev_t *vd) { - zfs_post_common(spa, vd, FM_RSRC_CLASS, FM_RESOURCE_AUTOREPLACE); + zfs_post_common(spa, vd, FM_RSRC_CLASS, FM_RESOURCE_AUTOREPLACE, NULL); } /* @@ -919,9 +927,31 @@ zfs_post_autoreplace(spa_t *spa, vdev_t *vd) * open because the device was not found (fault.fs.zfs.device). */ void -zfs_post_state_change(spa_t *spa, vdev_t *vd) +zfs_post_state_change(spa_t *spa, vdev_t *vd, uint64_t laststate) { - zfs_post_common(spa, vd, FM_RSRC_CLASS, FM_RESOURCE_STATECHANGE); +#ifdef _KERNEL + nvlist_t *aux; + + /* + * Add optional supplemental keys to payload + */ + aux = fm_nvlist_create(NULL); + if (vd && aux) { + if (vd->vdev_physpath) { + (void) nvlist_add_string(aux, + FM_EREPORT_PAYLOAD_ZFS_VDEV_PHYSPATH, + vd->vdev_physpath); + } + (void) nvlist_add_uint64(aux, + FM_EREPORT_PAYLOAD_ZFS_VDEV_LASTSTATE, laststate); + } + + zfs_post_common(spa, vd, FM_RSRC_CLASS, FM_RESOURCE_STATECHANGE, + aux); + + if (aux) + fm_nvlist_destroy(aux, FM_NVA_FREE); +#endif } /* @@ -933,7 +963,7 @@ zfs_post_state_change(spa_t *spa, vdev_t *vd) void zfs_post_sysevent(spa_t *spa, vdev_t *vd, const char *name) { - zfs_post_common(spa, vd, FM_SYSEVENT_CLASS, name); + zfs_post_common(spa, vd, FM_SYSEVENT_CLASS, name, NULL); } #if defined(_KERNEL) && defined(HAVE_SPL) |