diff --git a/cmd/zed/agents/zfs_agents.c b/cmd/zed/agents/zfs_agents.c index 35dd818ff80d..ddaf622e3b97 100644 --- a/cmd/zed/agents/zfs_agents.c +++ b/cmd/zed/agents/zfs_agents.c @@ -327,6 +327,9 @@ zfs_agent_dispatch(const char *class, const char *subclass, nvlist_t *nvl) static void * zfs_agent_consumer_thread(void *arg) { +#ifdef __APPLE__ + pthread_setname_np("agents"); +#endif for (;;) { agent_event_t *event; @@ -392,7 +395,9 @@ zfs_agent_init(libzfs_handle_t *zfs_hdl) list_destroy(&agent_events); zed_log_die("Failed to initialize agents"); } +#ifndef __APPLE__ pthread_setname_np(g_agents_tid, "agents"); +#endif } void diff --git a/cmd/zed/agents/zfs_mod.c b/cmd/zed/agents/zfs_mod.c index 3bcdf6e1d718..149e56fdc338 100644 --- a/cmd/zed/agents/zfs_mod.c +++ b/cmd/zed/agents/zfs_mod.c @@ -910,6 +910,9 @@ zfs_slm_deliver_event(const char *class, const char *subclass, nvlist_t *nvl) static void * zfs_enum_pools(void *arg) { +#ifdef __APPLE__ + pthread_setname_np("enum-pools"); +#endif (void) zpool_iter(g_zfshdl, zfs_unavail_pool, (void *)&g_pool_list); /* * Linux - instead of using a thread pool, each list entry @@ -946,7 +949,9 @@ zfs_slm_init() return (-1); } +#ifndef __APPLE__ pthread_setname_np(g_zfs_tid, "enum-pools"); +#endif list_create(&g_device_list, sizeof (struct pendingdev), offsetof(struct pendingdev, pd_node)); diff --git a/cmd/zed/agents/zfs_retire.c b/cmd/zed/agents/zfs_retire.c index 1563f5d2792c..c48527c29ffe 100644 --- a/cmd/zed/agents/zfs_retire.c +++ b/cmd/zed/agents/zfs_retire.c @@ -41,6 +41,9 @@ #include #include #include +#ifdef __APPLE__ +#include +#endif #include "zfs_agents.h" #include "fmd_api.h" diff --git a/cmd/zed/zed.c b/cmd/zed/zed.c index 0aa03fded468..e45176c00bf2 100644 --- a/cmd/zed/zed.c +++ b/cmd/zed/zed.c @@ -291,7 +291,7 @@ main(int argc, char *argv[]) rv = zed_event_service(&zcp); /* ENODEV: When kernel module is unloaded (osx) */ - if (rv == ENODEV) + if (rv != 0) break; } diff --git a/cmd/zed/zed_conf.c b/cmd/zed/zed_conf.c index 2cf2311dbb42..67abcd5e3330 100644 --- a/cmd/zed/zed_conf.c +++ b/cmd/zed/zed_conf.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,12 @@ #include "zed_log.h" #include "zed_strings.h" +#ifdef __APPLE__ +ssize_t readv(int, const struct iovec *, int); +ssize_t writev(int, const struct iovec *, int); +#endif + + /* * Initialise the configuration with default values. */ diff --git a/cmd/zed/zed_disk_event.c b/cmd/zed/zed_disk_event.c index 94e24236063c..4fa5320583be 100644 --- a/cmd/zed/zed_disk_event.c +++ b/cmd/zed/zed_disk_event.c @@ -164,6 +164,10 @@ zed_udev_monitor(void *arg) struct udev_monitor *mon = arg; char *tmp, *tmp2; +#ifdef __APPLE__ + pthread_setname_np("udev monitor"); +#endif + zed_log_msg(LOG_INFO, "Waiting for new udev disk events..."); while (1) { @@ -381,7 +385,9 @@ zed_disk_event_init() return (-1); } +#ifndef __APPLE__ pthread_setname_np(g_mon_tid, "udev monitor"); +#endif zed_log_msg(LOG_INFO, "zed_disk_event_init"); return (0); diff --git a/cmd/zed/zed_exec.c b/cmd/zed/zed_exec.c index 1eecfa0a92c4..69af977db3b0 100644 --- a/cmd/zed/zed_exec.c +++ b/cmd/zed/zed_exec.c @@ -26,6 +26,8 @@ #include #include #include +#include + #include "zed_exec.h" #include "zed_log.h" #include "zed_strings.h" @@ -196,6 +198,9 @@ _reap_children(void *arg) struct rusage usage; struct sigaction sa = {}; +#ifdef __APPLE__ + pthread_setname_np("reap ZEDLETs"); +#endif (void) sigfillset(&sa.sa_mask); (void) sigdelset(&sa.sa_mask, SIGCHLD); (void) pthread_sigmask(SIG_SETMASK, &sa.sa_mask, NULL); @@ -332,8 +337,9 @@ zed_exec_process(uint64_t eid, const char *class, const char *subclass, if (pthread_create(&_reap_children_tid, NULL, _reap_children, NULL) != 0) return (-1); +#ifndef __APPLE__ pthread_setname_np(_reap_children_tid, "reap ZEDLETs"); - +#endif avl_create(&_launched_processes, _launched_process_node_compare, sizeof (struct launched_process_node), offsetof(struct launched_process_node, node)); diff --git a/include/sys/fm/fs/zfs.h b/include/sys/fm/fs/zfs.h index 6491606d328b..e472173ff361 100644 --- a/include/sys/fm/fs/zfs.h +++ b/include/sys/fm/fs/zfs.h @@ -119,6 +119,11 @@ extern "C" { #define FM_RESOURCE_AUTOREPLACE "autoreplace" #define FM_RESOURCE_STATECHANGE "statechange" +#define FM_RESOURCE_ZFS_SNAPSHOT_MOUNT "snapshot_mount" +#define FM_RESOURCE_ZFS_SNAPSHOT_UNMOUNT "snapshot_unmount" +#define FM_RESOURCE_ZVOL_CREATE_SYMLINK "zvol.create" +#define FM_RESOURCE_ZVOL_REMOVE_SYMLINK "zvol.remove" + #ifdef __cplusplus } #endif diff --git a/include/sys/spa.h b/include/sys/spa.h index 08eba250d3a3..547d17e0769f 100644 --- a/include/sys/spa.h +++ b/include/sys/spa.h @@ -1168,6 +1168,8 @@ extern void spa_configfile_set(spa_t *, nvlist_t *, boolean_t); /* asynchronous event notification */ extern void spa_event_notify(spa_t *spa, vdev_t *vdev, nvlist_t *hist_nvl, const char *name); +extern void zfs_ereport_zvol_post(const char *subclass, const char *name, + const char *bsd, const char *rbsd); /* waiting for pool activities to complete */ extern int spa_wait(const char *pool, zpool_wait_activity_t activity, diff --git a/include/sys/zio.h b/include/sys/zio.h index 2d34481f6be6..5b606eaf8d50 100644 --- a/include/sys/zio.h +++ b/include/sys/zio.h @@ -673,6 +673,8 @@ extern int zfs_ereport_post_checksum(spa_t *spa, vdev_t *vd, struct zio_bad_cksum *info); void zio_vsd_default_cksum_report(zio_t *zio, zio_cksum_report_t *zcr); +extern void zfs_ereport_snapshot_post(const char *subclass, spa_t *spa, + const char *name); /* Called from spa_sync(), but primarily an injection handler */ extern void spa_handle_ignored_writes(spa_t *spa); diff --git a/module/zfs/zfs_fm.c b/module/zfs/zfs_fm.c index 60e631567a89..5fa56b941f70 100644 --- a/module/zfs/zfs_fm.c +++ b/module/zfs/zfs_fm.c @@ -1444,6 +1444,47 @@ zfs_ereport_fini(void) mutex_destroy(&recent_events_lock); } +void +zfs_ereport_snapshot_post(const char *subclass, spa_t *spa, const char *name) +{ + nvlist_t *aux; + + aux = fm_nvlist_create(NULL); + nvlist_add_string(aux, "snapshot_name", name); + + zfs_post_common(spa, NULL, FM_RSRC_CLASS, subclass, aux); + fm_nvlist_destroy(aux, FM_NVA_FREE); +} + +void +zfs_ereport_zvol_post(const char *subclass, const char *name, const char *bsd, + const char *rbsd) +{ + nvlist_t *aux; + char *r; + spa_t *spa; + boolean_t has_lock = B_FALSE; + + has_lock = mutex_owned(&spa_namespace_lock); + if (!has_lock) mutex_enter(&spa_namespace_lock); + spa = spa_lookup(name); + if (!has_lock) mutex_exit(&spa_namespace_lock); + if (!spa) + return; + + aux = fm_nvlist_create(NULL); + nvlist_add_string(aux, "BSD_disk", bsd); + nvlist_add_string(aux, "BSD_rdisk", rbsd); + r = strchr(name, '/'); + if (r && r[1]) + nvlist_add_string(aux, "DATASET", &r[1]); + + zfs_post_common(spa, NULL, FM_RSRC_CLASS, subclass, aux); + fm_nvlist_destroy(aux, FM_NVA_FREE); +} +#endif + +#if defined(_KERNEL) EXPORT_SYMBOL(zfs_ereport_post); EXPORT_SYMBOL(zfs_ereport_is_valid); EXPORT_SYMBOL(zfs_ereport_post_checksum);