]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Add a unique "eid" value to all zevents
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 22 Nov 2013 19:20:41 +0000 (11:20 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 31 Mar 2014 23:10:41 +0000 (16:10 -0700)
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 <behlendorf1@llnl.gov>
Signed-off-by: Chris Dunlap <cdunlap@llnl.gov>
Issue #2

include/sys/fm/protocol.h
include/sys/fm/util.h
module/zfs/fm.c

index 1ee221286cefaf363dfdcea9cd84533fdd71d366..de05bb296741d396587b7626f21d96ff505d3e84 100644 (file)
@@ -70,6 +70,7 @@ extern "C" {
 #define        FM_EREPORT_DETECTOR             "detector"
 #define        FM_EREPORT_ENA                  "ena"
 #define        FM_EREPORT_TIME                 "time"
+#define        FM_EREPORT_EID                  "eid"
 
 /* list.* event payload member names */
 #define        FM_LIST_EVENT_SIZE              "list-sz"
index 2f03d1011a22c330e404413db0e2d71ff54b6f25..9dfd436c1b43149aaf031f417163bc4404faf0cb 100644 (file)
@@ -81,6 +81,7 @@ typedef struct zevent_s {
        list_t          ev_ze_list;     /* " */
        list_node_t     ev_node;        /* " */
        zevent_cb_t     *ev_cb;         /* " */
+       uint64_t        ev_eid;
 } zevent_t;
 
 typedef struct zfs_zevent {
index 002827b520cfe96826c079746fa73d9133f4d237..fe9223ff81869cf3d85acf522cf088d9e9b76041 100644 (file)
@@ -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);