diff options
author | Brian Behlendorf <[email protected]> | 2012-10-15 13:36:26 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-10-15 16:01:54 -0700 |
commit | 99db9bfde70440475a37c0e1b985efbec4850a8c (patch) | |
tree | 6aca9c8eeb29a07a36eb155a5aba8626c50f8a75 | |
parent | 6cb7ab069d9079a5b4b955da883d5ab804c91319 (diff) |
Condition variable usage, zevent_cv
The following incorrect usage of cv_broadcast() was caught by
code inspection. The cv_broadcast() function must be called
under the associated mutex to preventing racing with cv_wait().
Signed-off-by: Brian Behlendorf <[email protected]>
-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); |