Skip to contentSkip to conversation

master - vgcreate: improve checks for existing global lock

PATCH David Teigland 1 participant 1 message Jul 29, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=772b54a08bae19f59d93ca456691e3ce3cbb00da
Commit:        772b54a08bae19f59d93ca456691e3ce3cbb00da
Parent:        e593213b875e96a3de77594f7ce8dd1809a930a0
Author:        David Teigland <[email protected]>
AuthorDate:    Fri Jul 24 10:06:58 2015 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Wed Jul 29 14:27:32 2015 -0500

vgcreate: improve checks for existing global lock

This tries harder to avoid creating duplicate global locks in sanlock VGs by refusing to create a new sanlock VG with a global lock if other sanlock VGs exist that may have a gl.

---
 daemons/lvmlockd/lvmlockd-core.c |    6 -----
 lib/cache/lvmcache.c             |   13 +++++++++++
 lib/cache/lvmcache.h             |    2 +
 lib/locking/lvmlockd.c           |   45 +++++++++++++++++++++++++++++--------
 4 files changed, 50 insertions(+), 16 deletions(-)
daemons/lvmlockd/lvmlockd-core.c +0 -6
index 7375d9e..1361569 100644
@@ -3341,12 +3341,6 @@ static void client_send_result(struct client *cl, struct action *act)
 		 * or if lockspaces exist, but not one with the global lock.
 		 * Given this detail, it may be able to procede without
 		 * the lock.
-		 *
-		 * FIXME: it would also help the caller to know if there
-		 * are other sanlock VGs that have not been started.
-		 * If there are, then one of them might have a global
-		 * lock enabled.  In that case, vgcreate may not want
-		 * to create a new sanlock vg with gl enabled.
 		 */
 		pthread_mutex_lock(&lockspaces_mutex);
 		if (list_empty(&lockspaces))
lib/cache/lvmcache.c +13 -0
index 36926f2..cfa1d5f 100644
@@ -2345,3 +2345,16 @@ int lvmcache_lookup_mda(struct lvmcache_vgsummary *vgsummary)
 
 	return 0;
 }
+
+int lvmcache_contains_lock_type_sanlock(struct cmd_context *cmd)
+{
+	struct lvmcache_vginfo *vginfo;
+
+	dm_list_iterate_items(vginfo, &_vginfos) {
+		if (vginfo->lock_type && !strcmp(vginfo->lock_type, "sanlock"))
+			return 1;
+	}
+
+	return 0;
+}
+
lib/cache/lvmcache.h +2 -0
index 008b194..76b9b10 100644
@@ -188,4 +188,6 @@ int lvmcache_found_duplicate_pvs(void);
 
 void lvmcache_set_preferred_duplicates(const char *vgid);
 
+int lvmcache_contains_lock_type_sanlock(struct cmd_context *cmd);
+
 #endif
lib/locking/lvmlockd.c +35 -10

58 lines not on this page · raw message