diff --git a/cmd/zed/Makefile.am b/cmd/zed/Makefile.am index 70e4f7f69..20e8bf1dc 100644 --- a/cmd/zed/Makefile.am +++ b/cmd/zed/Makefile.am @@ -49,8 +49,8 @@ dist_zedexec_SCRIPTS = \ zed.d/generic-notify.sh \ zed.d/io-notify.sh \ zed.d/io-spare.sh \ - zed.d/resilver.finish-notify.sh \ - zed.d/scrub.finish-notify.sh + zed.d/resilver_finish-notify.sh \ + zed.d/scrub_finish-notify.sh zedconfdefaults = \ all-syslog.sh \ @@ -59,8 +59,8 @@ zedconfdefaults = \ data-notify.sh \ io-notify.sh \ io-spare.sh \ - resilver.finish-notify.sh \ - scrub.finish-notify.sh + resilver_finish-notify.sh \ + scrub_finish-notify.sh install-data-hook: $(MKDIR_P) "$(DESTDIR)$(zedconfdir)" diff --git a/cmd/zed/zed.d/resilver.finish-notify.sh b/cmd/zed/zed.d/resilver.finish-notify.sh deleted file mode 120000 index 2635dcce1..000000000 --- a/cmd/zed/zed.d/resilver.finish-notify.sh +++ /dev/null @@ -1 +0,0 @@ -scrub.finish-notify.sh \ No newline at end of file diff --git a/cmd/zed/zed.d/resilver_finish-notify.sh b/cmd/zed/zed.d/resilver_finish-notify.sh new file mode 120000 index 000000000..e4c56bc5f --- /dev/null +++ b/cmd/zed/zed.d/resilver_finish-notify.sh @@ -0,0 +1 @@ +scrub_finish-notify.sh \ No newline at end of file diff --git a/cmd/zed/zed.d/scrub.finish-notify.sh b/cmd/zed/zed.d/scrub_finish-notify.sh similarity index 86% rename from cmd/zed/zed.d/scrub.finish-notify.sh rename to cmd/zed/zed.d/scrub_finish-notify.sh index b4dd1dd43..2145a100a 100755 --- a/cmd/zed/zed.d/scrub.finish-notify.sh +++ b/cmd/zed/zed.d/scrub_finish-notify.sh @@ -1,8 +1,8 @@ #!/bin/sh # -# Send notification in response to a RESILVER.FINISH or SCRUB.FINISH. +# Send notification in response to a RESILVER_FINISH or SCRUB_FINISH. # -# By default, "zpool status" output will only be included for a scrub.finish +# By default, "zpool status" output will only be included for a scrub_finish # zevent if the pool is not healthy; to always include its output, set # ZED_NOTIFY_VERBOSE=1. # @@ -19,9 +19,9 @@ [ -n "${ZEVENT_POOL}" ] || exit 9 [ -n "${ZEVENT_SUBCLASS}" ] || exit 9 -if [ "${ZEVENT_SUBCLASS}" = "resilver.finish" ]; then +if [ "${ZEVENT_SUBCLASS}" = "resilver_finish" ]; then action="resilver" -elif [ "${ZEVENT_SUBCLASS}" = "scrub.finish" ]; then +elif [ "${ZEVENT_SUBCLASS}" = "scrub_finish" ]; then action="scrub" else zed_log_err "unsupported event class \"${ZEVENT_SUBCLASS}\"" @@ -33,7 +33,7 @@ zed_check_cmd "${ZPOOL}" || exit 9 # For scrub, suppress notification if the pool is healthy # and verbosity is not enabled. # -if [ "${ZEVENT_SUBCLASS}" = "scrub.finish" ]; then +if [ "${ZEVENT_SUBCLASS}" = "scrub_finish" ]; then healthy="$("${ZPOOL}" status -x "${ZEVENT_POOL}" \ | grep "'${ZEVENT_POOL}' is healthy")" [ -n "${healthy}" ] && [ "${ZED_NOTIFY_VERBOSE}" -eq 0 ] && exit 3 diff --git a/cmd/zed/zed_event.c b/cmd/zed/zed_event.c index bd298dc41..7d819b803 100644 --- a/cmd/zed/zed_event.c +++ b/cmd/zed/zed_event.c @@ -748,9 +748,8 @@ _zed_event_add_env_preserve(uint64_t eid, zed_strings_t *zsp) /* * Compute the "subclass" by removing the first 3 components of [class] - * (which seem to always be either "ereport.fs.zfs" or "resource.fs.zfs"). - * Return a pointer inside the string [class], or NULL if insufficient - * components exist. + * (which will always be of the form "*.fs.zfs"). Return a pointer inside + * the string [class], or NULL if insufficient components exist. */ static const char * _zed_event_get_subclass(const char *class) diff --git a/configure.ac b/configure.ac index 9a8d6d24b..3a23b011f 100644 --- a/configure.ac +++ b/configure.ac @@ -80,7 +80,6 @@ AC_CONFIG_FILES([ lib/libspl/include/ia32/sys/Makefile lib/libspl/include/rpc/Makefile lib/libspl/include/sys/Makefile - lib/libspl/include/sys/sysevent/Makefile lib/libspl/include/sys/dktp/Makefile lib/libspl/include/util/Makefile lib/libavl/Makefile @@ -134,6 +133,7 @@ AC_CONFIG_FILES([ include/sys/fm/Makefile include/sys/fm/fs/Makefile include/sys/crypto/Makefile + include/sys/sysevent/Makefile scripts/Makefile scripts/zpios-profile/Makefile scripts/zpios-test/Makefile diff --git a/include/sys/Makefile.am b/include/sys/Makefile.am index 9054597d1..40cd0597c 100644 --- a/include/sys/Makefile.am +++ b/include/sys/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = fm fs crypto +SUBDIRS = fm fs crypto sysevent COMMON_H = \ $(top_srcdir)/include/sys/arc.h \ @@ -52,6 +52,7 @@ COMMON_H = \ $(top_srcdir)/include/sys/spa.h \ $(top_srcdir)/include/sys/spa_impl.h \ $(top_srcdir)/include/sys/spa_checksum.h \ + $(top_srcdir)/include/sys/sysevent.h \ $(top_srcdir)/include/sys/trace.h \ $(top_srcdir)/include/sys/trace_acl.h \ $(top_srcdir)/include/sys/trace_arc.h \ diff --git a/include/sys/fm/fs/zfs.h b/include/sys/fm/fs/zfs.h index 26f400303..ad3f4a79e 100644 --- a/include/sys/fm/fs/zfs.h +++ b/include/sys/fm/fs/zfs.h @@ -36,10 +36,7 @@ extern "C" { #define FM_EREPORT_ZFS_IO "io" #define FM_EREPORT_ZFS_DATA "data" #define FM_EREPORT_ZFS_DELAY "delay" -#define FM_EREPORT_ZFS_CONFIG_SYNC "config.sync" #define FM_EREPORT_ZFS_POOL "zpool" -#define FM_EREPORT_ZFS_POOL_DESTROY "zpool.destroy" -#define FM_EREPORT_ZFS_POOL_REGUID "zpool.reguid" #define FM_EREPORT_ZFS_DEVICE_UNKNOWN "vdev.unknown" #define FM_EREPORT_ZFS_DEVICE_OPEN_FAILED "vdev.open_failed" #define FM_EREPORT_ZFS_DEVICE_CORRUPT_DATA "vdev.corrupt_data" @@ -48,20 +45,10 @@ extern "C" { #define FM_EREPORT_ZFS_DEVICE_TOO_SMALL "vdev.too_small" #define FM_EREPORT_ZFS_DEVICE_BAD_LABEL "vdev.bad_label" #define FM_EREPORT_ZFS_DEVICE_BAD_ASHIFT "vdev.bad_ashift" -#define FM_EREPORT_ZFS_DEVICE_REMOVE "vdev.remove" -#define FM_EREPORT_ZFS_DEVICE_CLEAR "vdev.clear" -#define FM_EREPORT_ZFS_DEVICE_CHECK "vdev.check" -#define FM_EREPORT_ZFS_DEVICE_SPARE "vdev.spare" -#define FM_EREPORT_ZFS_DEVICE_AUTOEXPAND "vdev.autoexpand" #define FM_EREPORT_ZFS_IO_FAILURE "io_failure" #define FM_EREPORT_ZFS_PROBE_FAILURE "probe_failure" #define FM_EREPORT_ZFS_LOG_REPLAY "log_replay" #define FM_EREPORT_ZFS_CONFIG_CACHE_WRITE "config_cache_write" -#define FM_EREPORT_ZFS_RESILVER_START "resilver.start" -#define FM_EREPORT_ZFS_RESILVER_FINISH "resilver.finish" -#define FM_EREPORT_ZFS_SCRUB_START "scrub.start" -#define FM_EREPORT_ZFS_SCRUB_FINISH "scrub.finish" -#define FM_EREPORT_ZFS_BOOTFS_VDEV_ATTACH "bootfs.vdev.attach" #define FM_EREPORT_PAYLOAD_ZFS_POOL "pool" #define FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE "pool_failmode" @@ -116,9 +103,9 @@ extern "C" { #define FM_EREPORT_FAILMODE_CONTINUE "continue" #define FM_EREPORT_FAILMODE_PANIC "panic" -#define FM_EREPORT_RESOURCE_REMOVED "removed" -#define FM_EREPORT_RESOURCE_AUTOREPLACE "autoreplace" -#define FM_EREPORT_RESOURCE_STATECHANGE "statechange" +#define FM_RESOURCE_REMOVED "removed" +#define FM_RESOURCE_AUTOREPLACE "autoreplace" +#define FM_RESOURCE_STATECHANGE "statechange" #ifdef __cplusplus } diff --git a/include/sys/fm/protocol.h b/include/sys/fm/protocol.h index de05bb296..33fccdf67 100644 --- a/include/sys/fm/protocol.h +++ b/include/sys/fm/protocol.h @@ -50,6 +50,7 @@ extern "C" { #define FM_RSRC_CLASS "resource" #define FM_LIST_EVENT "list" #define FM_IREPORT_CLASS "ireport" +#define FM_SYSEVENT_CLASS "sysevent" /* FM list.* event class values */ #define FM_LIST_SUSPECT_CLASS FM_LIST_EVENT ".suspect" diff --git a/include/sys/spa.h b/include/sys/spa.h index 17bf76de8..51d4619f4 100644 --- a/include/sys/spa.h +++ b/include/sys/spa.h @@ -851,6 +851,7 @@ extern void zfs_ereport_post(const char *class, spa_t *spa, vdev_t *vd, extern void zfs_post_remove(spa_t *spa, vdev_t *vd); extern void zfs_post_state_change(spa_t *spa, vdev_t *vd); extern void zfs_post_autoreplace(spa_t *spa, vdev_t *vd); +extern void zfs_post_sysevent(spa_t *spa, vdev_t *vd, const char *name); extern uint64_t spa_get_errlog_size(spa_t *spa); extern int spa_get_errlog(spa_t *spa, void *uaddr, size_t *count); extern void spa_errlog_rotate(spa_t *spa); diff --git a/lib/libspl/include/sys/sysevent.h b/include/sys/sysevent.h similarity index 93% rename from lib/libspl/include/sys/sysevent.h rename to include/sys/sysevent.h index 074d8419c..2922e3072 100644 --- a/lib/libspl/include/sys/sysevent.h +++ b/include/sys/sysevent.h @@ -24,7 +24,7 @@ * Use is subject to license terms. */ -#ifndef _LIBSPL_SYS_SYSEVENT_H -#define _LIBSPL_SYS_SYSEVENT_H +#ifndef _SYS_SYSEVENT_H +#define _SYS_SYSEVENT_H #endif diff --git a/include/sys/sysevent/Makefile.am b/include/sys/sysevent/Makefile.am new file mode 100644 index 000000000..0d29eeb80 --- /dev/null +++ b/include/sys/sysevent/Makefile.am @@ -0,0 +1,18 @@ +COMMON_H = \ + $(top_srcdir)/include/sys/sysevent/eventdefs.h + +KERNEL_H = + +USER_H = + +EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H) + +if CONFIG_USER +libzfsdir = $(includedir)/libzfs/sys/sysevent +libzfs_HEADERS = $(COMMON_H) $(USER_H) +endif + +if CONFIG_KERNEL +kerneldir = @prefix@/src/zfs-$(VERSION)/include/sys/sysevent +kernel_HEADERS = $(COMMON_H) $(KERNEL_H) +endif diff --git a/include/sys/sysevent/eventdefs.h b/include/sys/sysevent/eventdefs.h new file mode 100644 index 000000000..eadaaef58 --- /dev/null +++ b/include/sys/sysevent/eventdefs.h @@ -0,0 +1,125 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + */ + +#ifndef _SYS_SYSEVENT_EVENTDEFS_H +#define _SYS_SYSEVENT_EVENTDEFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * eventdefs.h contains public definitions for sysevent types (classes + * and subclasses). All additions/removal/changes are subject + * to PSARC approval. + */ + +/* Sysevent Class definitions */ +#define EC_NONE "EC_none" +#define EC_PRIV "EC_priv" +#define EC_PLATFORM "EC_platform" /* events private to platform */ +#define EC_DR "EC_dr" /* Dynamic reconfiguration event class */ +#define EC_ENV "EC_env" /* Environmental monitor event class */ +#define EC_DOMAIN "EC_domain" /* Domain event class */ +#define EC_AP_DRIVER "EC_ap_driver" /* Alternate Pathing event class */ +#define EC_IPMP "EC_ipmp" /* IP Multipathing event class */ +#define EC_DEV_ADD "EC_dev_add" /* device add event class */ +#define EC_DEV_REMOVE "EC_dev_remove" /* device remove event class */ +#define EC_DEV_BRANCH "EC_dev_branch" /* device tree branch event class */ +#define EC_DEV_STATUS "EC_dev_status" /* device status event class */ +#define EC_FM "EC_fm" /* FMA error report event */ +#define EC_ZFS "EC_zfs" /* ZFS event */ +#define EC_DATALINK "EC_datalink" /* datalink event */ +#define EC_VRRP "EC_vrrp" /* VRRP event */ + +/* + * EC_DEV_ADD and EC_DEV_REMOVE subclass definitions - supporting attributes + * (name/value pairs) are found in sys/sysevent/dev.h + */ +#define ESC_DISK "disk" /* disk device */ +#define ESC_NETWORK "network" /* network interface */ +#define ESC_PRINTER "printer" /* printer device */ +#define ESC_LOFI "lofi" /* lofi device */ + +/* + * EC_DEV_BRANCH subclass definitions - supporting attributes (name/value pairs) + * are found in sys/sysevent/dev.h + */ + +/* device tree branch added */ +#define ESC_DEV_BRANCH_ADD "dev_branch_add" + +/* device tree branch removed */ +#define ESC_DEV_BRANCH_REMOVE "dev_branch_remove" + +/* + * EC_DEV_STATUS subclass definitions + * + * device capacity dynamically changed + */ +#define ESC_DEV_DLE "dev_dle" + +/* LUN has received an eject request from the user */ +#define ESC_DEV_EJECT_REQUEST "dev_eject_request" + +/* FMA Fault and Error event protocol subclass */ +#define ESC_FM_ERROR "error" +#define ESC_FM_ERROR_REPLAY "error_replay" + +/* + * ZFS subclass definitions. supporting attributes (name/value paris) are found + * in sys/fs/zfs.h + */ +#define ESC_ZFS_RESILVER_START "resilver_start" +#define ESC_ZFS_RESILVER_FINISH "resilver_finish" +#define ESC_ZFS_VDEV_REMOVE "vdev_remove" +#define ESC_ZFS_VDEV_REMOVE_AUX "vdev_remove_aux" +#define ESC_ZFS_VDEV_REMOVE_DEV "vdev_remove_dev" +#define ESC_ZFS_POOL_CREATE "pool_create" +#define ESC_ZFS_POOL_DESTROY "pool_destroy" +#define ESC_ZFS_POOL_IMPORT "pool_import" +#define ESC_ZFS_VDEV_ADD "vdev_add" +#define ESC_ZFS_VDEV_ATTACH "vdev_attach" +#define ESC_ZFS_VDEV_CLEAR "vdev_clear" +#define ESC_ZFS_VDEV_CHECK "vdev_check" +#define ESC_ZFS_VDEV_ONLINE "vdev_online" +#define ESC_ZFS_CONFIG_SYNC "config_sync" +#define ESC_ZFS_SCRUB_START "scrub_start" +#define ESC_ZFS_SCRUB_FINISH "scrub_finish" +#define ESC_ZFS_VDEV_SPARE "vdev_spare" +#define ESC_ZFS_VDEV_AUTOEXPAND "vdev_autoexpand" +#define ESC_ZFS_BOOTFS_VDEV_ATTACH "bootfs_vdev_attach" +#define ESC_ZFS_POOL_REGUID "pool_reguid" + +/* + * datalink subclass definitions. + */ +#define ESC_DATALINK_PHYS_ADD "datalink_phys_add" /* new physical link */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSEVENT_EVENTDEFS_H */ diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 7224294c7..4a65600c1 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -64,8 +64,9 @@ #include #include #include +#include +#include #include -#include #include #include #include @@ -119,7 +120,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/lib/libspl/include/sys/Makefile.am b/lib/libspl/include/sys/Makefile.am index 6aad8450f..ca2963499 100644 --- a/lib/libspl/include/sys/Makefile.am +++ b/lib/libspl/include/sys/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = dktp sysevent +SUBDIRS = dktp libspldir = $(includedir)/libspl/sys libspl_HEADERS = \ @@ -37,7 +37,6 @@ libspl_HEADERS = \ $(top_srcdir)/lib/libspl/include/sys/stat.h \ $(top_srcdir)/lib/libspl/include/sys/stropts.h \ $(top_srcdir)/lib/libspl/include/sys/sunddi.h \ - $(top_srcdir)/lib/libspl/include/sys/sysevent.h \ $(top_srcdir)/lib/libspl/include/sys/sysmacros.h \ $(top_srcdir)/lib/libspl/include/sys/systeminfo.h \ $(top_srcdir)/lib/libspl/include/sys/systm.h \ diff --git a/lib/libspl/include/sys/sysevent/Makefile.am b/lib/libspl/include/sys/sysevent/Makefile.am deleted file mode 100644 index b8495836d..000000000 --- a/lib/libspl/include/sys/sysevent/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -libspldir = $(includedir)/libspl/sys/sysevent -libspl_HEADERS = \ - $(top_srcdir)/lib/libspl/include/sys/sysevent/eventdefs.h diff --git a/lib/libspl/include/sys/sysevent/eventdefs.h b/lib/libspl/include/sys/sysevent/eventdefs.h deleted file mode 100644 index 50ab0ca4d..000000000 --- a/lib/libspl/include/sys/sysevent/eventdefs.h +++ /dev/null @@ -1,236 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - */ - -#ifndef _SYS_SYSEVENT_EVENTDEFS_H -#define _SYS_SYSEVENT_EVENTDEFS_H - - - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * eventdefs.h contains public definitions for sysevent types (classes - * and subclasses). All additions/removal/changes are subject - * to PSARC approval. - */ - -/* Sysevent Class definitions */ -#define EC_NONE "EC_none" -#define EC_PRIV "EC_priv" -#define EC_PLATFORM "EC_platform" /* events private to platform */ -#define EC_DR "EC_dr" /* Dynamic reconfiguration event class */ -#define EC_ENV "EC_env" /* Environmental monitor event class */ -#define EC_DOMAIN "EC_domain" /* Domain event class */ -#define EC_AP_DRIVER "EC_ap_driver" /* Alternate Pathing event class */ -#define EC_IPMP "EC_ipmp" /* IP Multipathing event class */ -#define EC_DEV_ADD "EC_dev_add" /* device add event class */ -#define EC_DEV_REMOVE "EC_dev_remove" /* device remove event class */ -#define EC_DEV_BRANCH "EC_dev_branch" /* device tree branch event class */ -#define EC_FM "EC_fm" /* FMA error report event */ -#define EC_ZFS "EC_zfs" /* ZFS event */ - -/* - * The following event class is reserved for exclusive use - * by Sun Cluster software. - */ -#define EC_CLUSTER "EC_Cluster" - -/* - * The following classes are exclusively reserved for use by the - * Solaris Volume Manager (SVM) - */ -#define EC_SVM_CONFIG "EC_SVM_Config" -#define EC_SVM_STATE "EC_SVM_State" - -/* - * EC_SVM_CONFIG subclass definitions - supporting attributes (name/value pairs) - * are found in sys/sysevent/svm.h - */ -#define ESC_SVM_CREATE "ESC_SVM_Create" -#define ESC_SVM_DELETE "ESC_SVM_Delete" -#define ESC_SVM_ADD "ESC_SVM_Add" -#define ESC_SVM_REMOVE "ESC_SVM_Remove" -#define ESC_SVM_REPLACE "ESC_SVM_Replace" -#define ESC_SVM_GROW "ESC_SVM_Grow" -#define ESC_SVM_RENAME_SRC "ESC_SVM_Rename_Src" -#define ESC_SVM_RENAME_DST "ESC_SVM_Rename_Dst" -#define ESC_SVM_MEDIATOR_ADD "ESC_SVM_Mediator_Add" -#define ESC_SVM_MEDIATOR_DELETE "ESC_SVM_Mediator_Delete" -#define ESC_SVM_HOST_ADD "ESC_SVM_Host_Add" -#define ESC_SVM_HOST_DELETE "ESC_SVM_Host_Delete" -#define ESC_SVM_DRIVE_ADD "ESC_SVM_Drive_Add" -#define ESC_SVM_DRIVE_DELETE "ESC_SVM_Drive_Delete" -#define ESC_SVM_DETACH "ESC_SVM_Detach" -#define ESC_SVM_DETACHING "ESC_SVM_Detaching" -#define ESC_SVM_ATTACH "ESC_SVM_Attach" -#define ESC_SVM_ATTACHING "ESC_SVM_Attaching" - -/* - * EC_SVM_STATE subclass definitions - supporting attributes (name/value pairs) - * are found in sys/sysevent/svm.h - */ -#define ESC_SVM_INIT_START "ESC_SVM_Init_Start" -#define ESC_SVM_INIT_FAILED "ESC_SVM_Init_Failed" -#define ESC_SVM_INIT_FATAL "ESC_SVM_Init_Fatal" -#define ESC_SVM_INIT_SUCCESS "ESC_SVM_Init_Success" -#define ESC_SVM_IOERR "ESC_SVM_Ioerr" -#define ESC_SVM_ERRED "ESC_SVM_Erred" -#define ESC_SVM_LASTERRED "ESC_SVM_Lasterred" -#define ESC_SVM_OK "ESC_SVM_Ok" -#define ESC_SVM_ENABLE "ESC_SVM_Enable" -#define ESC_SVM_RESYNC_START "ESC_SVM_Resync_Start" -#define ESC_SVM_RESYNC_FAILED "ESC_SVM_Resync_Failed" -#define ESC_SVM_RESYNC_SUCCESS "ESC_SVM_Resync_Success" -#define ESC_SVM_RESYNC_DONE "ESC_SVM_Resync_Done" -#define ESC_SVM_HOTSPARED "ESC_SVM_Hotspared" -#define ESC_SVM_HS_FREED "ESC_SVM_HS_Freed" -#define ESC_SVM_HS_CHANGED "ESC_SVM_HS_Changed" -#define ESC_SVM_TAKEOVER "ESC_SVM_Takeover" -#define ESC_SVM_RELEASE "ESC_SVM_Release" -#define ESC_SVM_OPEN_FAIL "ESC_SVM_Open_Fail" -#define ESC_SVM_OFFLINE "ESC_SVM_Offline" -#define ESC_SVM_ONLINE "ESC_SVM_Online" -#define ESC_SVM_CHANGE "ESC_SVM_Change" -#define ESC_SVM_EXCHANGE "ESC_SVM_Exchange" -#define ESC_SVM_REGEN_START "ESC_SVM_Regen_Start" -#define ESC_SVM_REGEN_DONE "ESC_SVM_Regen_Done" -#define ESC_SVM_REGEN_FAILED "ESC_SVM_Regen_Failed" - -/* - * EC_DR subclass definitions - supporting attributes (name/value pairs) - * are found in sys/sysevent/dr.h - */ - -/* Attachment point state change */ -#define ESC_DR_AP_STATE_CHANGE "ESC_dr_ap_state_change" -#define ESC_DR_REQ "ESC_dr_req" /* Request DR */ -#define ESC_DR_TARGET_STATE_CHANGE "ESC_dr_target_state_change" - -/* - * EC_ENV subclass definitions - supporting attributes (name/value pairs) - * are found in sys/sysevent/env.h - */ -#define ESC_ENV_TEMP "ESC_env_temp" /* Temperature change event subclass */ -#define ESC_ENV_FAN "ESC_env_fan" /* Fan status change event subclass */ -#define ESC_ENV_POWER "ESC_env_power" /* Power supply change event subclass */ -#define ESC_ENV_LED "ESC_env_led" /* LED change event subclass */ - -/* - * EC_DOMAIN subclass definitions - supporting attributes (name/value pairs) - * are found in sys/sysevent/domain.h - */ - -/* Domain state change */ -#define ESC_DOMAIN_STATE_CHANGE "ESC_domain_state_change" -/* Domain loghost name change */ -#define ESC_DOMAIN_LOGHOST_CHANGE "ESC_domain_loghost_change" - -/* - * EC_AP_DRIVER subclass definitions - supporting attributes (name/value pairs) - * are found in sys/sysevent/ap_driver.h - */ - -/* Alternate Pathing path switch */ -#define ESC_AP_DRIVER_PATHSWITCH "ESC_ap_driver_pathswitch" -/* Alternate Pathing database commit */ -#define ESC_AP_DRIVER_COMMIT "ESC_ap_driver_commit" -/* Alternate Pathing physical path status change */ -#define ESC_AP_DRIVER_PHYS_PATH_STATUS_CHANGE \ - "ESC_ap_driver_phys_path_status_change" - -/* - * EC_IPMP subclass definitions - supporting attributes (name/value pairs) - * are found in sys/sysevent/ipmp.h - */ - -/* IPMP group has changed state */ -#define ESC_IPMP_GROUP_STATE "ESC_ipmp_group_state" - -/* IPMP group has been created or removed */ -#define ESC_IPMP_GROUP_CHANGE "ESC_ipmp_group_change" - -/* IPMP group has had an interface added or removed */ -#define ESC_IPMP_GROUP_MEMBER_CHANGE "ESC_ipmp_group_member_change" - -/* Interface within an IPMP group has changed state or type */ -#define ESC_IPMP_IF_CHANGE "ESC_ipmp_if_change" - - -/* - * EC_DEV_ADD and EC_DEV_REMOVE subclass definitions - supporting attributes - * (name/value pairs) are found in sys/sysevent/dev.h - */ -#define ESC_DISK "disk" /* disk device */ -#define ESC_NETWORK "network" /* network interface */ -#define ESC_PRINTER "printer" /* printer device */ -#define ESC_LOFI "lofi" /* lofi device */ - -/* - * EC_DEV_BRANCH subclass definitions - supporting attributes (name/value pairs) - * are found in sys/sysevent/dev.h - */ - -/* device tree branch added */ -#define ESC_DEV_BRANCH_ADD "ESC_dev_branch_add" - -/* device tree branch removed */ -#define ESC_DEV_BRANCH_REMOVE "ESC_dev_branch_remove" - -/* FMA Fault and Error event protocol subclass */ -#define ESC_FM_ERROR "ESC_FM_error" -#define ESC_FM_ERROR_REPLAY "ESC_FM_error_replay" - -/* Service processor subclass definitions */ -#define ESC_PLATFORM_SP_RESET "ESC_platform_sp_reset" - -/* - * EC_ACPIEV subclass definitions - */ -#define EC_ACPIEV "EC_acpiev" -#define ESC_ACPIEV_ADD "ESC_acpiev_add" -#define ESC_ACPIEV_REMOVE "ESC_acpiev_remove" -#define ESC_ACPIEV_WARN "ESC_acpiev_warn" -#define ESC_ACPIEV_LOW "ESC_acpiev_low" -#define ESC_ACPIEV_STATE_CHANGE "ESC_acpiev_state_change" - -/* - * ZFS subclass definitions. supporting attributes (name/value paris) are found - * in sys/fs/zfs.h - */ -#define ESC_ZFS_RESILVER_START "ESC_ZFS_resilver_start" -#define ESC_ZFS_RESILVER_FINISH "ESC_ZFS_resilver_finish" -#define ESC_ZFS_VDEV_REMOVE "ESC_ZFS_vdev_remove" -#define ESC_ZFS_POOL_DESTROY "ESC_ZFS_pool_destroy" -#define ESC_ZFS_VDEV_CLEAR "ESC_ZFS_vdev_clear" -#define ESC_ZFS_VDEV_CHECK "ESC_ZFS_vdev_check" - -#ifdef __cplusplus -} -#endif - -#endif /* _SYS_SYSEVENT_EVENTDEFS_H */ diff --git a/module/zfs/dsl_scan.c b/module/zfs/dsl_scan.c index 6c5f1f0b5..7389b4b1d 100644 --- a/module/zfs/dsl_scan.c +++ b/module/zfs/dsl_scan.c @@ -247,11 +247,9 @@ dsl_scan_setup_sync(void *arg, dmu_tx_t *tx) if (vdev_resilver_needed(spa->spa_root_vdev, &scn->scn_phys.scn_min_txg, &scn->scn_phys.scn_max_txg)) { - spa_event_notify(spa, NULL, - FM_EREPORT_ZFS_RESILVER_START); + spa_event_notify(spa, NULL, ESC_ZFS_RESILVER_START); } else { - spa_event_notify(spa, NULL, - FM_EREPORT_ZFS_SCRUB_START); + spa_event_notify(spa, NULL, ESC_ZFS_SCRUB_START); } spa->spa_scrub_started = B_TRUE; @@ -359,8 +357,7 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx) complete ? scn->scn_phys.scn_max_txg : 0, B_TRUE); if (complete) { spa_event_notify(spa, NULL, scn->scn_phys.scn_min_txg ? - FM_EREPORT_ZFS_RESILVER_FINISH : - FM_EREPORT_ZFS_SCRUB_FINISH); + ESC_ZFS_RESILVER_FINISH : ESC_ZFS_SCRUB_FINISH); } spa_errlog_rotate(spa); diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 2f1ebe517..da238a398 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -22,6 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013 by Delphix. All rights reserved. + * Copyright (c) 2015, Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2013, 2014, Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. * Copyright (c) 2016 Actifio, Inc. All rights reserved. @@ -801,7 +802,7 @@ spa_change_guid(spa_t *spa) if (error == 0) { spa_config_sync(spa, B_FALSE, B_TRUE); - spa_event_notify(spa, NULL, FM_EREPORT_ZFS_POOL_REGUID); + spa_event_notify(spa, NULL, ESC_ZFS_POOL_REGUID); } mutex_exit(&spa_namespace_lock); @@ -1681,9 +1682,8 @@ spa_check_removed(vdev_t *vd) if (vd->vdev_ops->vdev_op_leaf && vdev_is_dead(vd) && !vd->vdev_ishole) { - zfs_ereport_post(FM_EREPORT_RESOURCE_AUTOREPLACE, - vd->vdev_spa, vd, NULL, 0, 0); - spa_event_notify(vd->vdev_spa, vd, FM_EREPORT_ZFS_DEVICE_CHECK); + zfs_post_autoreplace(vd->vdev_spa, vd); + spa_event_notify(vd->vdev_spa, vd, ESC_ZFS_VDEV_CHECK); } } @@ -3956,6 +3956,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props, txg_wait_synced(spa->spa_dsl_pool, txg); spa_config_sync(spa, B_FALSE, B_TRUE); + spa_event_notify(spa, NULL, ESC_ZFS_POOL_CREATE); spa_history_log_version(spa, "create"); @@ -4018,6 +4019,7 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags) spa_configfile_set(spa, props, B_FALSE); spa_config_sync(spa, B_FALSE, B_TRUE); + spa_event_notify(spa, NULL, ESC_ZFS_POOL_IMPORT); mutex_exit(&spa_namespace_lock); return (0); @@ -4148,10 +4150,14 @@ spa_import(char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags) */ spa_async_request(spa, SPA_ASYNC_AUTOEXPAND); - mutex_exit(&spa_namespace_lock); spa_history_log_version(spa, "import"); + + spa_event_notify(spa, NULL, ESC_ZFS_POOL_IMPORT); + zvol_create_minors(spa, pool, B_TRUE); + mutex_exit(&spa_namespace_lock); + return (0); } @@ -4347,7 +4353,7 @@ spa_export_common(char *pool, int new_state, nvlist_t **oldconfig, } export_spa: - spa_event_notify(spa, NULL, FM_EREPORT_ZFS_POOL_DESTROY); + spa_event_notify(spa, NULL, ESC_ZFS_POOL_DESTROY); if (spa->spa_state != POOL_STATE_UNINITIALIZED) { spa_unload(spa); @@ -4503,6 +4509,7 @@ spa_vdev_add(spa_t *spa, nvlist_t *nvroot) mutex_enter(&spa_namespace_lock); spa_config_update(spa, SPA_CONFIG_UPDATE_POOL); + spa_event_notify(spa, NULL, ESC_ZFS_VDEV_ADD); mutex_exit(&spa_namespace_lock); return (0); @@ -4678,7 +4685,7 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing) if (newvd->vdev_isspare) { spa_spare_activate(newvd); - spa_event_notify(spa, newvd, FM_EREPORT_ZFS_DEVICE_SPARE); + spa_event_notify(spa, newvd, ESC_ZFS_VDEV_SPARE); } oldvdpath = spa_strdup(oldvd->vdev_path); @@ -4697,6 +4704,11 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing) */ dsl_resilver_restart(spa->spa_dsl_pool, dtl_max_txg); + if (spa->spa_bootfs) + spa_event_notify(spa, newvd, ESC_ZFS_BOOTFS_VDEV_ATTACH); + + spa_event_notify(spa, newvd, ESC_ZFS_VDEV_ATTACH); + /* * Commit the config */ @@ -4711,9 +4723,6 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing) spa_strfree(oldvdpath); spa_strfree(newvdpath); - if (spa->spa_bootfs) - spa_event_notify(spa, newvd, FM_EREPORT_ZFS_BOOTFS_VDEV_ATTACH); - return (0); } @@ -4912,7 +4921,7 @@ spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done) vd->vdev_detached = B_TRUE; vdev_dirty(tvd, VDD_DTL, vd, txg); - spa_event_notify(spa, vd, FM_EREPORT_ZFS_DEVICE_REMOVE); + spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE); /* hang on to the spa before we release the lock */ spa_open_ref(spa, FTAG); @@ -5428,6 +5437,7 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare) } else { error = SET_ERROR(EBUSY); } + spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); } else if (spa->spa_l2cache.sav_vdevs != NULL && nvlist_lookup_nvlist_array(spa->spa_l2cache.sav_config, ZPOOL_CONFIG_L2CACHE, &l2cache, &nl2cache) == 0 && @@ -5439,6 +5449,7 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare) ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache, nv); spa_load_l2cache(spa); spa->spa_l2cache.sav_sync = B_TRUE; + spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX); } else if (vd != NULL && vd->vdev_islog) { ASSERT(!locked); ASSERT(vd == vd->vdev_top); @@ -5477,6 +5488,7 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare) */ spa_vdev_remove_from_namespace(spa, vd); + spa_event_notify(spa, vd, ESC_ZFS_VDEV_REMOVE_DEV); } else if (vd != NULL) { /* * Normal vdevs cannot be removed (yet). @@ -5764,7 +5776,7 @@ spa_async_autoexpand(spa_t *spa, vdev_t *vd) if (!vd->vdev_ops->vdev_op_leaf || vd->vdev_physpath == NULL) return; - spa_event_notify(vd->vdev_spa, vd, FM_EREPORT_ZFS_DEVICE_AUTOEXPAND); + spa_event_notify(vd->vdev_spa, vd, ESC_ZFS_VDEV_AUTOEXPAND); } static void @@ -6814,7 +6826,8 @@ spa_has_active_shared_spare(spa_t *spa) } /* - * Post a FM_EREPORT_ZFS_* event from sys/fm/fs/zfs.h. The payload will be + * Post a zevent corresponding to the given sysevent. The 'name' must be one + * of the event definitions in sys/sysevent/eventdefs.h. The payload will be * filled in from the spa and (optionally) the vdev. This doesn't do anything * in the userland libzpool, as we don't want consumers to misinterpret ztest * or zdb as real changes. @@ -6822,9 +6835,7 @@ spa_has_active_shared_spare(spa_t *spa) void spa_event_notify(spa_t *spa, vdev_t *vd, const char *name) { -#ifdef _KERNEL - zfs_ereport_post(name, spa, vd, NULL, 0, 0); -#endif + zfs_post_sysevent(spa, vd, name); } #if defined(_KERNEL) && defined(HAVE_SPL) diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c index 943eca0bb..f31daf9ed 100644 --- a/module/zfs/spa_config.c +++ b/module/zfs/spa_config.c @@ -329,7 +329,7 @@ spa_config_sync(spa_t *target, boolean_t removing, boolean_t postsysevent) spa_config_generation++; if (postsysevent) - spa_event_notify(target, NULL, FM_EREPORT_ZFS_CONFIG_SYNC); + spa_event_notify(target, NULL, ESC_ZFS_CONFIG_SYNC); } /* diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 0178bfdec..d0b458642 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -2488,6 +2488,7 @@ int vdev_online(spa_t *spa, uint64_t guid, uint64_t flags, vdev_state_t *newstate) { vdev_t *vd, *tvd, *pvd, *rvd = spa->spa_root_vdev; + boolean_t postevent = B_FALSE; spa_vdev_state_enter(spa, SCL_NONE); @@ -2497,6 +2498,10 @@ vdev_online(spa_t *spa, uint64_t guid, uint64_t flags, vdev_state_t *newstate) if (!vd->vdev_ops->vdev_op_leaf) return (spa_vdev_state_exit(spa, NULL, ENOTSUP)); + postevent = + (vd->vdev_offline == B_TRUE || vd->vdev_tmpoffline == B_TRUE) ? + B_TRUE : B_FALSE; + tvd = vd->vdev_top; vd->vdev_offline = B_FALSE; vd->vdev_tmpoffline = B_FALSE; @@ -2532,6 +2537,10 @@ vdev_online(spa_t *spa, uint64_t guid, uint64_t flags, vdev_state_t *newstate) return (spa_vdev_state_exit(spa, vd, ENOTSUP)); spa_async_request(spa, SPA_ASYNC_CONFIG_UPDATE); } + + if (postevent) + spa_event_notify(spa, vd, ESC_ZFS_VDEV_ONLINE); + return (spa_vdev_state_exit(spa, vd, 0)); } @@ -2694,7 +2703,7 @@ vdev_clear(spa_t *spa, vdev_t *vd) if (vd->vdev_aux == NULL && !vdev_is_dead(vd)) spa_async_request(spa, SPA_ASYNC_RESILVER); - spa_event_notify(spa, vd, FM_EREPORT_ZFS_DEVICE_CLEAR); + spa_event_notify(spa, vd, ESC_ZFS_VDEV_CLEAR); } /* diff --git a/module/zfs/zfs_fm.c b/module/zfs/zfs_fm.c index c7b718000..a75997bd8 100644 --- a/module/zfs/zfs_fm.c +++ b/module/zfs/zfs_fm.c @@ -860,7 +860,7 @@ zfs_ereport_post_checksum(spa_t *spa, vdev_t *vd, } static void -zfs_post_common(spa_t *spa, vdev_t *vd, const char *name) +zfs_post_common(spa_t *spa, vdev_t *vd, const char *type, const char *name) { #ifdef _KERNEL nvlist_t *resource; @@ -872,7 +872,7 @@ zfs_post_common(spa_t *spa, vdev_t *vd, const char *name) if ((resource = fm_nvlist_create(NULL)) == NULL) return; - (void) snprintf(class, sizeof (class), "%s.%s.%s", FM_RSRC_RESOURCE, + (void) snprintf(class, sizeof (class), "%s.%s.%s", type, ZFS_ERROR_CLASS, name); VERIFY0(nvlist_add_uint8(resource, FM_VERSION, FM_RSRC_VERSION)); VERIFY0(nvlist_add_string(resource, FM_CLASS, class)); @@ -886,6 +886,15 @@ zfs_post_common(spa_t *spa, vdev_t *vd, const char *name) FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID, vd->vdev_guid)); VERIFY0(nvlist_add_uint64(resource, FM_EREPORT_PAYLOAD_ZFS_VDEV_STATE, vd->vdev_state)); + if (vd->vdev_path != NULL) + VERIFY0(nvlist_add_string(resource, + FM_EREPORT_PAYLOAD_ZFS_VDEV_PATH, vd->vdev_path)); + if (vd->vdev_devid != NULL) + VERIFY0(nvlist_add_string(resource, + FM_EREPORT_PAYLOAD_ZFS_VDEV_DEVID, vd->vdev_devid)); + if (vd->vdev_fru != NULL) + VERIFY0(nvlist_add_string(resource, + FM_EREPORT_PAYLOAD_ZFS_VDEV_FRU, vd->vdev_fru)); } zfs_zevent_post(resource, NULL, zfs_zevent_post_cb); @@ -901,7 +910,7 @@ zfs_post_common(spa_t *spa, vdev_t *vd, const char *name) void zfs_post_remove(spa_t *spa, vdev_t *vd) { - zfs_post_common(spa, vd, FM_EREPORT_RESOURCE_REMOVED); + zfs_post_common(spa, vd, FM_RSRC_CLASS, FM_RESOURCE_REMOVED); } /* @@ -912,7 +921,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_EREPORT_RESOURCE_AUTOREPLACE); + zfs_post_common(spa, vd, FM_RSRC_CLASS, FM_RESOURCE_AUTOREPLACE); } /* @@ -924,7 +933,19 @@ zfs_post_autoreplace(spa_t *spa, vdev_t *vd) void zfs_post_state_change(spa_t *spa, vdev_t *vd) { - zfs_post_common(spa, vd, FM_EREPORT_RESOURCE_STATECHANGE); + zfs_post_common(spa, vd, FM_RSRC_CLASS, FM_RESOURCE_STATECHANGE); +} + +/* + * The 'sysevent.fs.zfs.*' events are signals posted to notify user space of + * change in the pool. All sysevents are listed in sys/sysevent/eventdefs.h + * and are designed to be consumed by the ZFS Event Daemon (ZED). For + * additional details refer to the zed(8) man page. + */ +void +zfs_post_sysevent(spa_t *spa, vdev_t *vd, const char *name) +{ + zfs_post_common(spa, vd, FM_SYSEVENT_CLASS, name); } #if defined(_KERNEL) && defined(HAVE_SPL) @@ -933,4 +954,5 @@ EXPORT_SYMBOL(zfs_ereport_post_checksum); EXPORT_SYMBOL(zfs_post_remove); EXPORT_SYMBOL(zfs_post_autoreplace); EXPORT_SYMBOL(zfs_post_state_change); +EXPORT_SYMBOL(zfs_post_sysevent); #endif /* _KERNEL */