Skip to contentSkip to conversation

master - move the setting of use_full_md_check flag

PATCH David Teigland 1 participant 1 message May 21, 2019

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6422b9ddc5c46968e2bef6ced12cd38e0b44c49d
Commit:        6422b9ddc5c46968e2bef6ced12cd38e0b44c49d
Parent:        19ef399ea781c2c74d0bc8de92f673648d190016
Author:        David Teigland <[email protected]>
AuthorDate:    Tue May 21 11:51:58 2019 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Tue May 21 11:51:58 2019 -0500

move the setting of use_full_md_check flag

from each command to one location in command init. No functional change.

---
 tools/lvmcmdline.c |   18 ++++++++++++++++++
 tools/pvcreate.c   |    3 ---
 tools/vgcreate.c   |    3 ---
 tools/vgextend.c   |    3 ---
 4 files changed, 18 insertions(+), 9 deletions(-)
tools/lvmcmdline.c +18 -0
index 0422613..79de85b 100644
@@ -2766,6 +2766,22 @@ static int _init_lvmlockd(struct cmd_context *cmd)
 	return 1;
 }
 
+static void _init_md_checks(struct cmd_context *cmd)
+{
+	/*
+	 * use_full_md_check can also be set later.
+	 * These commands are chosen to always perform
+	 * a full md component check because they initialize
+	 * a new device that could be an md component,
+	 * and they are not run frequently during normal
+	 * operation.
+	 */
+	if (!strcmp(cmd->name, "pvcreate") ||
+	    !strcmp(cmd->name, "vgcreate") ||
+	    !strcmp(cmd->name, "vgextend"))
+		cmd->use_full_md_check = 1;
+}
+
 static int _cmd_no_meta_proc(struct cmd_context *cmd)
 {
 	return cmd->cname->flags & NO_METADATA_PROCESSING;
@@ -2979,6 +2995,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
 		}
 	}
 
+	_init_md_checks(cmd);
+
 	if (!_cmd_no_meta_proc(cmd) && !_init_lvmlockd(cmd)) {
 		ret = ECMD_FAILED;
 		goto_out;
tools/pvcreate.c +0 -3
index 5b59a79..29ae0fa 100644
@@ -136,9 +136,6 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
 	pp.pv_count = argc;
 	pp.pv_names = argv;
 
-	/* Check for old md signatures at the end of devices. */
-	cmd->use_full_md_check = 1;
-
 	/* Needed to change the set of orphan PVs. */
 	if (!lock_global(cmd, "ex"))
 		return_ECMD_FAILED;
tools/vgcreate.c +0 -3
index 626cf15..6640b8e 100644
@@ -63,9 +63,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
 
 	clear_hint_file(cmd);
 
-	/* Check for old md signatures at the end of devices. */
-	cmd->use_full_md_check = 1;
-
 	/*
 	 * Check if the VG name already exists.  This should be done before
 	 * creating PVs on any of the devices.
tools/vgextend.c +0 -3
index 785be3f..e50a818 100644
@@ -154,9 +154,6 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
 	/* pvcreate within vgextend cannot be forced. */
 	pp->force = 0;
 
-	/* Check for old md signatures at the end of devices. */
-	cmd->use_full_md_check = 1;
-
 	if (!lock_global(cmd, "ex"))
 		return_ECMD_FAILED;