Skip to content

Commit

Permalink
Upstream: Add snapshot events
Browse files Browse the repository at this point in the history
For kernel to send snapshot mount/unmount events to zed.

Signed-off-by: Jorgen Lundman <lundman@lundman.net>
  • Loading branch information
lundman committed May 24, 2021
1 parent 3675537 commit 47ca292
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/sys/fm/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ extern "C" {
#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_SNAPSHOT_MOUNT "snapshot_mount"
#define FM_EREPORT_ZFS_SNAPSHOT_UNMOUNT "snapshot_unmount"

#define FM_EREPORT_PAYLOAD_ZFS_POOL "pool"
#define FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE "pool_failmode"
Expand Down
22 changes: 22 additions & 0 deletions module/zfs/zfs_fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,29 @@ zfs_ereport_fini(void)
list_destroy(&recent_events_list);
mutex_destroy(&recent_events_lock);
}
#endif

void
zfs_ereport_snapshot_post(const char *subclass, spa_t *spa, const char *name)
{
#ifdef _KERNEL
nvlist_t *ereport = NULL;
nvlist_t *detector = NULL;

zfs_ereport_start(&ereport, &detector,
subclass,
spa, NULL, NULL, NULL, 0, 0);

if (ereport == NULL) return;

VERIFY0(nvlist_add_string(ereport, "snapshot_name", name));

/* Cleanup is handled by the callback function */
zfs_zevent_post(ereport, detector, zfs_zevent_post_cb);
#endif
}

#if defined(_KERNEL)
EXPORT_SYMBOL(zfs_ereport_post);
EXPORT_SYMBOL(zfs_ereport_is_valid);
EXPORT_SYMBOL(zfs_ereport_post_checksum);
Expand Down

0 comments on commit 47ca292

Please sign in to comment.