Blame SOURCES/0027-Revert-pvcreate-overwrite-partition-header-with-f.patch

ab86b0
From 9375aebad1db72267dd67e3ed768aa3b0e698d52 Mon Sep 17 00:00:00 2001
ab86b0
From: David Teigland <teigland@redhat.com>
ab86b0
Date: Tue, 18 Jan 2022 12:16:52 -0600
ab86b0
Subject: [PATCH 27/54] Revert "pvcreate: overwrite partition header with -f"
ab86b0
ab86b0
This reverts commit a5c37afdca97d6565ea02bc4bc7d52f360823cd3.
ab86b0
ab86b0
This commit did not properly recognize GPT cases.
ab86b0
---
ab86b0
 lib/commands/toolcontext.h       |  1 -
ab86b0
 lib/filters/filter-partitioned.c |  3 ---
ab86b0
 man/pvcreate.8_des               |  7 +++----
ab86b0
 test/shell/test-partition.sh     | 12 ++----------
ab86b0
 tools/toollib.c                  | 10 ----------
ab86b0
 5 files changed, 5 insertions(+), 28 deletions(-)
ab86b0
ab86b0
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
ab86b0
index b83883fb8..356c79f8a 100644
ab86b0
--- a/lib/commands/toolcontext.h
ab86b0
+++ b/lib/commands/toolcontext.h
ab86b0
@@ -201,7 +201,6 @@ struct cmd_context {
ab86b0
 	unsigned ignore_device_name_mismatch:1; /* skip updating devices file names */
ab86b0
 	unsigned backup_disabled:1;		/* skip repeated debug message */
ab86b0
 	unsigned event_activation:1;		/* whether event_activation is set */
ab86b0
-	unsigned filter_partitioned_skip:1;	/* don't use filter-partitioned */
ab86b0
 
ab86b0
 	/*
ab86b0
 	 * Devices and filtering.
ab86b0
diff --git a/lib/filters/filter-partitioned.c b/lib/filters/filter-partitioned.c
ab86b0
index 8f468a567..642553ef2 100644
ab86b0
--- a/lib/filters/filter-partitioned.c
ab86b0
+++ b/lib/filters/filter-partitioned.c
ab86b0
@@ -27,9 +27,6 @@ static int _passes_partitioned_filter(struct cmd_context *cmd, struct dev_filter
ab86b0
 	if (cmd->filter_nodata_only)
ab86b0
 		return 1;
ab86b0
 
ab86b0
-	if (cmd->filter_partitioned_skip)
ab86b0
-		return 1;
ab86b0
-
ab86b0
 	dev->filtered_flags &= ~DEV_FILTERED_PARTITIONED;
ab86b0
 
ab86b0
 	ret = dev_is_partitioned(cmd, dev);
ab86b0
diff --git a/man/pvcreate.8_des b/man/pvcreate.8_des
ab86b0
index 4048eb71c..69bd133aa 100644
ab86b0
--- a/man/pvcreate.8_des
ab86b0
+++ b/man/pvcreate.8_des
ab86b0
@@ -7,10 +7,9 @@ Use \fBvgcreate\fP(8) to create a new VG on the PV, or \fBvgextend\fP(8)
ab86b0
 to add the PV to an existing VG.  Use \fBpvremove\fP(8) to remove the LVM
ab86b0
 disk label from the device.
ab86b0
 .P
ab86b0
-The force option will create a PV without confirmation, and will overwrite
ab86b0
-partition headers.  Repeating the force option (\fB-ff\fP) will override other
ab86b0
-checks that would normally prevent a pvcreate, e.g. if the PV is already in a
ab86b0
-VG.
ab86b0
+The force option will create a PV without confirmation.  Repeating the
ab86b0
+force option (\fB-ff\fP) will forcibly create a PV, overriding checks that
ab86b0
+normally prevent it, e.g. if the PV is already in a VG.
ab86b0
 .P
ab86b0
 .B Metadata location, size, and alignment
ab86b0
 .P
ab86b0
diff --git a/test/shell/test-partition.sh b/test/shell/test-partition.sh
ab86b0
index 3a45f9089..0e92f00db 100644
ab86b0
--- a/test/shell/test-partition.sh
ab86b0
+++ b/test/shell/test-partition.sh
ab86b0
@@ -16,6 +16,7 @@
ab86b0
 #
ab86b0
 
ab86b0
 
ab86b0
+
ab86b0
 SKIP_WITH_LVMPOLLD=1
ab86b0
 
ab86b0
 LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]"
ab86b0
@@ -24,7 +25,7 @@ LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]"
ab86b0
 
ab86b0
 which sfdisk || skip
ab86b0
 
ab86b0
-aux prepare_pvs 2 30
ab86b0
+aux prepare_pvs 1 30
ab86b0
 
ab86b0
 pvs "$dev1"
ab86b0
 
ab86b0
@@ -32,12 +33,3 @@ pvs "$dev1"
ab86b0
 echo "1 2" | sfdisk --force "$dev1"
ab86b0
 
ab86b0
 not pvs "$dev1"
ab86b0
-
ab86b0
-wipefs -a "$dev2"
ab86b0
-echo "1 2" | sfdisk --force "$dev2"
ab86b0
-partprobe
ab86b0
-not pvcreate "$dev2"
ab86b0
-pvcreate -f "$dev2"
ab86b0
-pvs "$dev2"
ab86b0
-pvremove "$dev2"
ab86b0
-
ab86b0
diff --git a/tools/toollib.c b/tools/toollib.c
ab86b0
index 80d3de57c..d6f48aad2 100644
ab86b0
--- a/tools/toollib.c
ab86b0
+++ b/tools/toollib.c
ab86b0
@@ -5243,10 +5243,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
ab86b0
 	if (cmd->enable_devices_file && !pp->is_remove)
ab86b0
 		cmd->filter_deviceid_skip = 1;
ab86b0
 
ab86b0
-	/* pvcreate -f overwrites partitions */
ab86b0
-	if (pp->force && !pp->is_remove)
ab86b0
-		cmd->filter_partitioned_skip = 1;
ab86b0
-
ab86b0
 	log_debug("Scanning and filtering device args (%u).", dm_list_size(&scan_devs));
ab86b0
 	label_scan_devs(cmd, cmd->filter, &scan_devs);
ab86b0
 
ab86b0
@@ -5261,7 +5257,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
ab86b0
 		}
ab86b0
 	}
ab86b0
 	cmd->filter_deviceid_skip = 0;
ab86b0
-	cmd->filter_partitioned_skip = 0;
ab86b0
 
ab86b0
 	/*
ab86b0
 	 * Can the command continue if some specified devices were not found?
ab86b0
@@ -5474,9 +5469,6 @@ do_command:
ab86b0
 	if (cmd->enable_devices_file && !pp->is_remove)
ab86b0
 		cmd->filter_deviceid_skip = 1;
ab86b0
 
ab86b0
-	if (pp->force && !pp->is_remove)
ab86b0
-		cmd->filter_partitioned_skip = 1;
ab86b0
-
ab86b0
 	log_debug("Rescanning and filtering device args with exclusive open");
ab86b0
 	if (!label_scan_devs_excl(cmd, cmd->filter, &rescan_devs)) {
ab86b0
 		log_debug("Failed to rescan devs excl");
ab86b0
@@ -5490,9 +5482,7 @@ do_command:
ab86b0
 			dm_list_add(&pp->arg_fail, &pd->list);
ab86b0
 		}
ab86b0
 	}
ab86b0
-
ab86b0
 	cmd->filter_deviceid_skip = 0;
ab86b0
-	cmd->filter_partitioned_skip = 0;
ab86b0
 
ab86b0
 	if (dm_list_empty(&pp->arg_process) && dm_list_empty(&remove_duplicates)) {
ab86b0
 		log_debug("No devices to process.");
ab86b0
-- 
ab86b0
2.34.3
ab86b0