From 5951864035be8df13afc1b7629073572fa5f6200 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 21 Jul 2010 11:37:24 -0700 Subject: [PATCH 1/3] Minor formatting fix to align columns $ sudo ./cmd/zpool/zpool events TIME CLASS Jul 21 2010 11:36:14.682122000 resource.fs.zfs.statechange Jul 21 2010 11:36:14.705809000 resource.fs.zfs.statechange --- cmd/zpool/zpool_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 667556937b..d4a4fb9f8b 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -4423,7 +4423,7 @@ zpool_do_events_next(ev_opts_t *opts) nvlist_t *nvl; int ret, dropped; - (void) printf(gettext("%-27s %s\n"), "TIME", "CLASS"); + (void) printf(gettext("%-30s %s\n"), "TIME", "CLASS"); while (1) { ret = zpool_events_next(g_zfs, &nvl, &dropped, !!opts->follow); From f275e82de94e56e425d0bfa86c24069da2b72c29 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 21 Jul 2010 12:45:53 -0700 Subject: [PATCH 2/3] Add FM_EREPORT_TIME when event is posted Previously I was adding the FM_EREPORT_TIME time when the nvlist was constructed. However, with the update to onnv_141 these ereport nvlists are now constructed in several places and it doesn't make sense for each of them to have to add this common bit of info. To handle this the FM_EREPORT_TIME is now only added once when the event is posted. --- module/zfs/fm.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/module/zfs/fm.c b/module/zfs/fm.c index 0c94ade288..62ab7b58f8 100644 --- a/module/zfs/fm.c +++ b/module/zfs/fm.c @@ -496,9 +496,19 @@ fm_zevent_insert(zevent_t *ev) void fm_zevent_post(nvlist_t *nvl, nvlist_t *detector, zevent_cb_t *cb) { + int64_t tv_array[2]; + timestruc_t tv; size_t nvl_size = 0; zevent_t *ev; + gethrestime(&tv); + tv_array[0] = tv.tv_sec; + tv_array[1] = tv.tv_nsec; + if (nvlist_add_int64_array(nvl, FM_EREPORT_TIME, tv_array, 2)) { + atomic_add_64(&erpt_kstat_data.erpt_set_failed.value.ui64, 1); + return; + } + (void) nvlist_size(nvl, &nvl_size, NV_ENCODE_NATIVE); if (nvl_size > ERPT_DATA_SZ || nvl_size == 0) { atomic_add_64(&erpt_kstat_data.erpt_dropped.value.ui64, 1); @@ -892,8 +902,6 @@ fm_ereport_set(nvlist_t *ereport, int version, const char *erpt_class, { char ereport_class[FM_MAX_CLASS]; const char *name; - timestruc_t tv; - int64_t tv_array[2]; va_list ap; int ret; @@ -925,13 +933,6 @@ fm_ereport_set(nvlist_t *ereport, int version, const char *erpt_class, if (ret) atomic_add_64(&erpt_kstat_data.erpt_set_failed.value.ui64, 1); - - gethrestime(&tv); - tv_array[0] = tv.tv_sec; - tv_array[1] = tv.tv_nsec; - if (nvlist_add_int64_array(ereport, FM_EREPORT_TIME, tv_array, 2)) { - atomic_add_64(&erpt_kstat_data.erpt_set_failed.value.ui64, 1); - } } /* From 1a493a955530e408310cb1008faacef987ba8a6d Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 21 Jul 2010 12:49:09 -0700 Subject: [PATCH 3/3] Add vdev_state to common post info This was done because there are now lots of resource.fs.zfs.statechange events being posted but they do not include the state. For the moment the state must always be healthy but there's no harm in making this explicit. --- module/zfs/include/sys/fm/fs/zfs.h | 1 + module/zfs/zfs_fm.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/module/zfs/include/sys/fm/fs/zfs.h b/module/zfs/include/sys/fm/fs/zfs.h index 70f0843faf..ba542d8220 100644 --- a/module/zfs/include/sys/fm/fs/zfs.h +++ b/module/zfs/include/sys/fm/fs/zfs.h @@ -67,6 +67,7 @@ extern "C" { #define FM_EREPORT_PAYLOAD_ZFS_VDEV_PATH "vdev_path" #define FM_EREPORT_PAYLOAD_ZFS_VDEV_DEVID "vdev_devid" #define FM_EREPORT_PAYLOAD_ZFS_VDEV_FRU "vdev_fru" +#define FM_EREPORT_PAYLOAD_ZFS_VDEV_STATE "vdev_state" #define FM_EREPORT_PAYLOAD_ZFS_PARENT_GUID "parent_guid" #define FM_EREPORT_PAYLOAD_ZFS_PARENT_TYPE "parent_type" #define FM_EREPORT_PAYLOAD_ZFS_PARENT_PATH "parent_path" diff --git a/module/zfs/zfs_fm.c b/module/zfs/zfs_fm.c index 409f4f99fb..a74f195778 100644 --- a/module/zfs/zfs_fm.c +++ b/module/zfs/zfs_fm.c @@ -820,9 +820,12 @@ zfs_post_common(spa_t *spa, vdev_t *vd, const char *name) VERIFY(nvlist_add_string(resource, FM_CLASS, class) == 0); VERIFY(nvlist_add_uint64(resource, FM_EREPORT_PAYLOAD_ZFS_POOL_GUID, spa_guid(spa)) == 0); - if (vd) + if (vd) { VERIFY(nvlist_add_uint64(resource, FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID, vd->vdev_guid) == 0); + VERIFY(nvlist_add_uint64(resource, + FM_EREPORT_PAYLOAD_ZFS_VDEV_STATE, vd->vdev_state) == 0); + } fm_zevent_post(resource, NULL, zfs_zevent_post_cb); #endif