Condition variable usage, zilog->zl_cv_batch

The following incorrect usage of cv_signal and cv_broadcast()
was caught by code inspection.  The cv_signal and cv_broadcast()
functions must be called under the associated mutex to preventing
racing with cv_wait().

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2012-10-15 13:40:07 -07:00
parent 99db9bfde7
commit 8c0712fd88

View File

@ -1560,13 +1560,14 @@ zil_commit(zilog_t *zilog, uint64_t foid)
zil_commit_writer(zilog); zil_commit_writer(zilog);
zilog->zl_com_batch = mybatch; zilog->zl_com_batch = mybatch;
zilog->zl_writer = B_FALSE; zilog->zl_writer = B_FALSE;
mutex_exit(&zilog->zl_lock);
/* wake up one thread to become the next writer */ /* wake up one thread to become the next writer */
cv_signal(&zilog->zl_cv_batch[(mybatch+1) & 1]); cv_signal(&zilog->zl_cv_batch[(mybatch+1) & 1]);
/* wake up all threads waiting for this batch to be committed */ /* wake up all threads waiting for this batch to be committed */
cv_broadcast(&zilog->zl_cv_batch[mybatch & 1]); cv_broadcast(&zilog->zl_cv_batch[mybatch & 1]);
mutex_exit(&zilog->zl_lock);
} }
/* /*