diff options
-rw-r--r-- | module/zfs/fm.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/module/zfs/fm.c b/module/zfs/fm.c index ce0ebe0c1..c004032f8 100644 --- a/module/zfs/fm.c +++ b/module/zfs/fm.c @@ -481,14 +481,13 @@ zfs_zevent_drain_all(int *count) static void zfs_zevent_insert(zevent_t *ev) { - mutex_enter(&zevent_lock); + ASSERT(MUTEX_HELD(&zevent_lock)); list_insert_head(&zevent_list, ev); + if (zevent_len_cur >= zfs_zevent_len_max) zfs_zevent_drain(list_tail(&zevent_list)); else zevent_len_cur++; - - mutex_exit(&zevent_lock); } /* @@ -528,8 +527,11 @@ 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; + + mutex_enter(&zevent_lock); zfs_zevent_insert(ev); cv_broadcast(&zevent_cv); + mutex_exit(&zevent_lock); } static int @@ -1520,9 +1522,10 @@ fm_fini(void) int count; zfs_zevent_drain_all(&count); - cv_broadcast(&zevent_cv); mutex_enter(&zevent_lock); + cv_broadcast(&zevent_cv); + zevent_flags |= ZEVENT_SHUTDOWN; while (zevent_waiters > 0) { mutex_exit(&zevent_lock); |