summaryrefslogtreecommitdiffstats
path: root/module/zfs/fm.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2013-11-22 11:20:41 -0800
committerBrian Behlendorf <[email protected]>2014-03-31 16:10:41 -0700
commita2f1945ee3ce8eba02ef54168c72f3be8f2cebdc (patch)
tree2aea8350c3afc4faa00f7de5037f848f8cdf4a20 /module/zfs/fm.c
parent4d8c78c84445c099873c77c9fa20287dca982ed5 (diff)
Add a unique "eid" value to all zevents
Tagging each zevent with a unique monotonically increasing EID (Event IDentifier) provides the required infrastructure for a user space daemon to reliably process zevents. By writing the EID to persistent storage the daemon can safely resume where it left off in the event stream when it's restarted. Signed-off-by: Brian Behlendorf <[email protected]> Signed-off-by: Chris Dunlap <[email protected]> Issue #2
Diffstat (limited to 'module/zfs/fm.c')
-rw-r--r--module/zfs/fm.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/module/zfs/fm.c b/module/zfs/fm.c
index 002827b52..fe9223ff8 100644
--- a/module/zfs/fm.c
+++ b/module/zfs/fm.c
@@ -84,6 +84,14 @@ static int zevent_len_cur = 0;
static int zevent_waiters = 0;
static int zevent_flags = 0;
+/*
+ * The EID (Event IDentifier) is used to uniquely tag a zevent when it is
+ * posted. The posted EIDs are monotonically increasing but not persistent.
+ * They will be reset to the initial value (1) each time the kernel module is
+ * loaded.
+ */
+static uint64_t zevent_eid = 0;
+
static kmutex_t zevent_lock;
static list_t zevent_list;
static kcondvar_t zevent_cv;
@@ -498,6 +506,7 @@ zfs_zevent_post(nvlist_t *nvl, nvlist_t *detector, zevent_cb_t *cb)
{
int64_t tv_array[2];
timestruc_t tv;
+ uint64_t eid;
size_t nvl_size = 0;
zevent_t *ev;
@@ -509,6 +518,12 @@ zfs_zevent_post(nvlist_t *nvl, nvlist_t *detector, zevent_cb_t *cb)
return;
}
+ eid = atomic_inc_64_nv(&zevent_eid);
+ if (nvlist_add_uint64(nvl, FM_EREPORT_EID, eid)) {
+ 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);
@@ -527,6 +542,7 @@ zfs_zevent_post(nvlist_t *nvl, nvlist_t *detector, zevent_cb_t *cb)
ev->ev_nvl = nvl;
ev->ev_detector = detector;
ev->ev_cb = cb;
+ ev->ev_eid = eid;
mutex_enter(&zevent_lock);
zfs_zevent_insert(ev);