mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_02_106-fix-timeout-for-initial-lvmetad-scan-when-done-in-parallel.patch

4c7ee1
commit a7864d8f81e29dd7228c16f35314843e2f0c7b86
4c7ee1
Author: Peter Rajnoha <prajnoha@redhat.com>
4c7ee1
Date:   Wed Mar 26 09:09:33 2014 +0100
4c7ee1
4c7ee1
    0
4c7ee1
---
4c7ee1
 lib/cache/lvmetad.c              | 16 +++++++++++-----
4c7ee1
 libdaemon/client/daemon-client.h |  2 +-
4c7ee1
 2 files changed, 12 insertions(+), 6 deletions(-)
4c7ee1
4c7ee1
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
4c7ee1
index 38d9042..c019250 100644
4c7ee1
--- a/lib/cache/lvmetad.c
4c7ee1
+++ b/lib/cache/lvmetad.c
4c7ee1
@@ -143,6 +143,7 @@ static daemon_reply _lvmetad_send(const char *id, ...)
4c7ee1
 	daemon_reply repl;
4c7ee1
 	daemon_request req;
4c7ee1
 	int try = 0;
4c7ee1
+	int time = 0, wait, sleep = 1;
4c7ee1
 
4c7ee1
 retry:
4c7ee1
 	req = daemon_request_make(id);
4c7ee1
@@ -159,7 +160,7 @@ retry:
4c7ee1
 	daemon_request_destroy(req);
4c7ee1
 
4c7ee1
 	if (!repl.error && !strcmp(daemon_reply_str(repl, "response", ""), "token_mismatch") &&
4c7ee1
-	    try < 60 && !test_mode()) {
4c7ee1
+	    try < 10 && time < 80000000 && !test_mode()) {
4c7ee1
 		/*
4c7ee1
 		 * If another process is trying to scan, they might have the
4c7ee1
 		 * same future token id and it's better to wait and avoid doing
4c7ee1
@@ -172,12 +173,17 @@ retry:
4c7ee1
 		 * the update, we back off for a short while (0.2-2 seconds) and
4c7ee1
 		 * try again.
4c7ee1
 		 */
4c7ee1
-		if (!strcmp(daemon_reply_str(repl, "expected", ""), "update in progress") || try % 5)
4c7ee1
-			usleep( 50000 + random() % 450000 ); /* 0.05 - 0.5s */
4c7ee1
-		else
4c7ee1
+		if (!strcmp(daemon_reply_str(repl, "expected", ""), "update in progress") || sleep) {
4c7ee1
+			wait = 50000 + random() % 450000; /* 0.05 - 0.5s */
4c7ee1
+			time += wait;
4c7ee1
+			usleep( wait );
4c7ee1
+			-- sleep;
4c7ee1
+		} else {
4c7ee1
 			/* If the re-scan fails here, we try again later. */
4c7ee1
 			lvmetad_pvscan_all_devs(_lvmetad_cmd, NULL);
4c7ee1
-		++ try;
4c7ee1
+			++ try;
4c7ee1
+			sleep = 5;
4c7ee1
+		}
4c7ee1
 		daemon_reply_destroy(repl);
4c7ee1
 		goto retry;
4c7ee1
 	}
4c7ee1
diff --git a/libdaemon/client/daemon-client.h b/libdaemon/client/daemon-client.h
4c7ee1
index 6ba65e6..8a44f8b 100644
4c7ee1
--- a/libdaemon/client/daemon-client.h
4c7ee1
+++ b/libdaemon/client/daemon-client.h
4c7ee1
@@ -102,7 +102,7 @@ static inline int64_t daemon_reply_int(daemon_reply r, const char *path, int64_t
4c7ee1
 }
4c7ee1
 
4c7ee1
 static inline const char *daemon_reply_str(daemon_reply r, const char *path, const char *def) {
4c7ee1
-	return dm_config_find_str(r.cft->root, path, def);
4c7ee1
+	return dm_config_find_str_allow_empty(r.cft->root, path, def);
4c7ee1
 }
4c7ee1
 
4c7ee1