Blame SOURCES/lvm2-2_02_106-fix-dmeventd-logging-with-parallel-wait-processing.patch

4c7ee1
commit 6281d212fa5e70e400c70677dfc20e99553e60d1
4c7ee1
Author: Peter Rajnoha <prajnoha@redhat.com>
4c7ee1
Date:   Wed Mar 12 14:36:55 2014 +0100
4c7ee1
4c7ee1
    dmeventd parallel processing
4c7ee1
---
4c7ee1
 WHATS_NEW_DM                |  1 +
4c7ee1
 daemons/dmeventd/dmeventd.c | 16 ++++++++++++++--
4c7ee1
 2 files changed, 15 insertions(+), 2 deletions(-)
4c7ee1
4c7ee1
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
4c7ee1
index 32c2265..e470cd2 100644
4c7ee1
--- a/WHATS_NEW_DM
4c7ee1
+++ b/WHATS_NEW_DM
4c7ee1
@@ -1,5 +1,6 @@
4c7ee1
 Version 1.02.85 - 
4c7ee1
 ===================================
4c7ee1
+  Fix dmeventd logging with parallel wait event processing.
4c7ee1
   Reuse _node_send_messages() for validation of transaction_id in preload.
4c7ee1
   Transaction_id could be lower by one only when messages are prepared.
4c7ee1
   Do not call callback when preload fails.
4c7ee1
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
4c7ee1
index 4a17fb2..f27444c 100644
4c7ee1
--- a/daemons/dmeventd/dmeventd.c
4c7ee1
+++ b/daemons/dmeventd/dmeventd.c
4c7ee1
@@ -661,6 +661,7 @@ static sigset_t _unblock_sigalrm(void)
4c7ee1
 /* Wait on a device until an event occurs. */
4c7ee1
 static int _event_wait(struct thread_status *thread, struct dm_task **task)
4c7ee1
 {
4c7ee1
+	static unsigned _in_event_counter = 0;
4c7ee1
 	sigset_t set;
4c7ee1
 	int ret = DM_WAIT_RETRY;
4c7ee1
 	struct dm_task *dmt;
4c7ee1
@@ -677,12 +678,20 @@ static int _event_wait(struct thread_status *thread, struct dm_task **task)
4c7ee1
 	    !dm_task_set_event_nr(dmt, thread->event_nr))
4c7ee1
 		goto out;
4c7ee1
 
4c7ee1
+	_lock_mutex();
4c7ee1
+	/*
4c7ee1
+	 * Check if there are already some waiting events,
4c7ee1
+	 * in this case the logging is unmodified.
4c7ee1
+	 * TODO: audit libdm thread usage
4c7ee1
+	 */
4c7ee1
+	if (!_in_event_counter++)
4c7ee1
+		dm_log_init(_no_intr_log);
4c7ee1
+	_unlock_mutex();
4c7ee1
 	/*
4c7ee1
 	 * This is so that you can break out of waiting on an event,
4c7ee1
 	 * either for a timeout event, or to cancel the thread.
4c7ee1
 	 */
4c7ee1
 	set = _unblock_sigalrm();
4c7ee1
-	dm_log_init(_no_intr_log);
4c7ee1
 	errno = 0;
4c7ee1
 	if (dm_task_run(dmt)) {
4c7ee1
 		thread->current_events |= DM_EVENT_DEVICE_ERROR;
4c7ee1
@@ -706,7 +715,10 @@ static int _event_wait(struct thread_status *thread, struct dm_task **task)
4c7ee1
 	}
4c7ee1
 
4c7ee1
 	pthread_sigmask(SIG_SETMASK, &set, NULL);
4c7ee1
-	dm_log_init(NULL);
4c7ee1
+	_lock_mutex();
4c7ee1
+	if (--_in_event_counter == 0)
4c7ee1
+		dm_log_init(NULL);
4c7ee1
+	_unlock_mutex();
4c7ee1
 
4c7ee1
       out:
4c7ee1
 	if (ret == DM_WAIT_FATAL || ret == DM_WAIT_RETRY) {