Skip to contentSkip to conversation

master - clvmd: separate saved_vg from vginfo

PATCH David Teigland 1 participant 1 message May 3, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c016b573ee32ff836f1d427d5cf58eb6480cf7b8
Commit:        c016b573ee32ff836f1d427d5cf58eb6480cf7b8
Parent:        a5e13f2eef5314666e19923a03ae01f479a74fd8
Author:        David Teigland <[email protected]>
AuthorDate:    Wed May 2 16:58:49 2018 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Thu May 3 14:54:48 2018 -0500

clvmd: separate saved_vg from vginfo

The clvmd saved_vg data is independent from the normal lvm lvmcache vginfo data, so separate saved_vg from vginfo. Normal lvm doesn't need to use save_vg at all, and in clvmd, lvmcache changes on vginfo can be made without worrying about unwanted effects on saved_vg.

---
 daemons/clvmd/lvm-functions.c |    1 -
 lib/cache/lvmcache.c          |  399 +++++++++++++++++++++-------------------
 lib/cache/lvmcache.h          |   10 +-
 lib/commands/toolcontext.c    |   12 +-
 lib/commands/toolcontext.h    |    2 +-
 lib/metadata/metadata.c       |    4 +-
 tools/toollib.c               |    4 +-
 7 files changed, 231 insertions(+), 201 deletions(-)
daemons/clvmd/lvm-functions.c +0 -1
index 3bb00d3..34da66d 100644
@@ -903,7 +903,6 @@ int init_clvm(struct dm_hash_table *excl_uuid)
 		return 0;
 	}
 
-	cmd->is_clvmd = 1;
 	cmd->cmd_line = "clvmd";
 
 	/* Check lvm.conf is setup for cluster-LVM */
lib/cache/lvmcache.c +209 -190

704 lines not on this page · raw message

lib/cache/lvmcache.h +7 -3
index 20ce74b..797ff21 100644
@@ -63,7 +63,7 @@ struct lvmcache_vgsummary {
 	int seqno;
 };
 
-int lvmcache_init(void);
+int lvmcache_init(struct cmd_context *cmd);
 void lvmcache_allow_reads_with_lvmetad(void);
 
 void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans, int reset);
@@ -213,11 +213,15 @@ int lvmcache_get_vg_devs(struct cmd_context *cmd,
 			 struct dm_list *devs);
 void lvmcache_set_independent_location(const char *vgname);
 
+int lvmcache_scan_mismatch(struct cmd_context *cmd, const char *vgname, const char *vgid);
+
+/*
+ * These are clvmd-specific functions and are not related to lvmcache.
+ * FIXME: rename these with a clvm_ prefix in place of lvmcache_
+ */
 void lvmcache_save_vg(struct volume_group *vg, int precommitted);
 struct volume_group *lvmcache_get_saved_vg(const char *vgid, int precommitted);
 struct volume_group *lvmcache_get_saved_vg_latest(const char *vgid);
 void lvmcache_drop_saved_vgid(const char *vgid);
 
-int lvmcache_scan_mismatch(struct cmd_context *cmd, const char *vgname, const char *vgid);
-
 #endif
lib/commands/toolcontext.c +10 -2
index 76e15e0..4fdd62f 100644
@@ -1814,7 +1814,7 @@ out:
 }
 
 /* Entry point */
-struct cmd_context *create_toolcontext(unsigned is_long_lived,
+struct cmd_context *create_toolcontext(unsigned is_clvmd,
 				       const char *system_dir,
 				       unsigned set_buffering,
 				       unsigned threaded,
@@ -1841,7 +1841,8 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
 		log_error("Failed to allocate command context");
 		return NULL;
 	}
-	cmd->is_long_lived = is_long_lived;
+	cmd->is_long_lived = is_clvmd;
+	cmd->is_clvmd = is_clvmd;
 	cmd->threaded = threaded ? 1 : 0;
 	cmd->handles_missing_pvs = 0;
 	cmd->handles_unknown_segments = 0;
@@ -1970,6 +1971,10 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
 	if (!_init_formats(cmd))
 		goto_out;
 
+	if (!lvmcache_init(cmd))
+		goto_out;
+
+	/* FIXME: move into lvmcache_init */
 	if (!init_lvmcache_orphans(cmd))
 		goto_out;
 
@@ -2191,6 +2196,9 @@ int refresh_toolcontext(struct cmd_context *cmd)
 	if (!_init_formats(cmd))
 		return_0;
 
+	if (!lvmcache_init(cmd))
+		return_0;
+
 	if (!init_lvmcache_orphans(cmd))
 		return_0;
 
lib/commands/toolcontext.h +1 -1
index 1d9de0a..34222ee 100644
@@ -236,7 +236,7 @@ struct cmd_context {
  * system_dir may be NULL to use the default value.
  * The environment variable LVM_SYSTEM_DIR always takes precedence.
  */
-struct cmd_context *create_toolcontext(unsigned is_long_lived,
+struct cmd_context *create_toolcontext(unsigned is_clvmd,
 				       const char *system_dir,
 				       unsigned set_buffering,
 				       unsigned threaded,
lib/metadata/metadata.c +2 -2
index d65daaf..16fd6fa 100644
@@ -4599,7 +4599,7 @@ struct volume_group *vg_read_by_vgid(struct cmd_context *cmd,
 
 	if (!(vgname = lvmcache_vgname_from_vgid(cmd->mem, vgid))) {
 		log_debug_metadata("Reading VG by vgid %.8s no VG name found, retrying.", vgid);
-		lvmcache_destroy(cmd, 0, 0);
+		lvmcache_destroy(cmd, 1, 0);
 		label_scan_destroy(cmd);
 		lvmcache_label_scan(cmd);
 		warn_flags |= SKIP_RESCAN;
@@ -4630,7 +4630,7 @@ struct volume_group *vg_read_by_vgid(struct cmd_context *cmd,
 	return vg;
 
  scan:
-	lvmcache_destroy(cmd, 0, 0);
+	lvmcache_destroy(cmd, 1, 0);
 	label_scan_destroy(cmd);
 	lvmcache_label_scan(cmd);
 	warn_flags |= SKIP_RESCAN;
tools/toollib.c +2 -2
index 53e7f9a..e633cdd 100644
@@ -111,7 +111,7 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm)
 	if (!skip_lvm) {
 		reset_locking();
 		lvmcache_destroy(cmd, 1, 1);
-		if (!lvmcache_init())
+		if (!lvmcache_init(cmd))
 			/* FIXME Clean up properly here */
 			_exit(ECMD_FAILED);
 	}
@@ -4622,7 +4622,7 @@ int process_each_pv(struct cmd_context *cmd,
 		log_verbose("Some PVs were not found in first search, retrying.");
 
 		lvmcache_destroy(cmd, 0, 0);
-		if (!lvmcache_init()) {
+		if (!lvmcache_init(cmd)) {
 			log_error("Failed to initalize lvm cache.");
 			ret_max = ECMD_FAILED;
 			goto out;