1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Revert "pvcreate: overwrite partition header with -f"

This reverts commit d5a950ca67.

This commit did not properly recognize GPT cases.
This commit is contained in:
David Teigland 2022-01-18 12:15:03 -06:00
parent a972d63c54
commit de7892f0af
5 changed files with 5 additions and 28 deletions

View File

@ -204,7 +204,6 @@ struct cmd_context {
unsigned udevoutput:1; unsigned udevoutput:1;
unsigned online_vg_file_removed:1; unsigned online_vg_file_removed:1;
unsigned disable_dm_devs:1; /* temporarily disable use of dm devs cache */ unsigned disable_dm_devs:1; /* temporarily disable use of dm devs cache */
unsigned filter_partitioned_skip:1; /* don't use filter-partitioned */
/* /*
* Devices and filtering. * Devices and filtering.

View File

@ -27,9 +27,6 @@ static int _passes_partitioned_filter(struct cmd_context *cmd, struct dev_filter
if (cmd->filter_nodata_only) if (cmd->filter_nodata_only)
return 1; return 1;
if (cmd->filter_partitioned_skip)
return 1;
dev->filtered_flags &= ~DEV_FILTERED_PARTITIONED; dev->filtered_flags &= ~DEV_FILTERED_PARTITIONED;
ret = dev_is_partitioned(cmd, dev); ret = dev_is_partitioned(cmd, dev);

View File

@ -7,10 +7,9 @@ Use \fBvgcreate\fP(8) to create a new VG on the PV, or \fBvgextend\fP(8)
to add the PV to an existing VG. Use \fBpvremove\fP(8) to remove the LVM to add the PV to an existing VG. Use \fBpvremove\fP(8) to remove the LVM
disk label from the device. disk label from the device.
.P .P
The force option will create a PV without confirmation, and will overwrite The force option will create a PV without confirmation. Repeating the
partition headers. Repeating the force option (\fB-ff\fP) will override other force option (\fB-ff\fP) will forcibly create a PV, overriding checks that
checks that would normally prevent a pvcreate, e.g. if the PV is already in a normally prevent it, e.g. if the PV is already in a VG.
VG.
.P .P
.B Metadata location, size, and alignment .B Metadata location, size, and alignment
.P .P

View File

@ -16,6 +16,7 @@
# #
SKIP_WITH_LVMPOLLD=1 SKIP_WITH_LVMPOLLD=1
LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]" LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]"
@ -24,7 +25,7 @@ LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]"
which sfdisk || skip which sfdisk || skip
aux prepare_pvs 2 30 aux prepare_pvs 1 30
pvs "$dev1" pvs "$dev1"
@ -32,12 +33,3 @@ pvs "$dev1"
echo "1 2" | sfdisk --force "$dev1" echo "1 2" | sfdisk --force "$dev1"
not pvs "$dev1" not pvs "$dev1"
wipefs -a "$dev2"
echo "1 2" | sfdisk --force "$dev2"
partprobe
not pvcreate "$dev2"
pvcreate -f "$dev2"
pvs "$dev2"
pvremove "$dev2"

View File

@ -5248,10 +5248,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
if (cmd->enable_devices_file && !pp->is_remove) if (cmd->enable_devices_file && !pp->is_remove)
cmd->filter_deviceid_skip = 1; cmd->filter_deviceid_skip = 1;
/* pvcreate -f overwrites partitions */
if (pp->force && !pp->is_remove)
cmd->filter_partitioned_skip = 1;
log_debug("Scanning and filtering device args (%u).", dm_list_size(&scan_devs)); log_debug("Scanning and filtering device args (%u).", dm_list_size(&scan_devs));
label_scan_devs(cmd, cmd->filter, &scan_devs); label_scan_devs(cmd, cmd->filter, &scan_devs);
@ -5266,7 +5262,6 @@ int pvcreate_each_device(struct cmd_context *cmd,
} }
} }
cmd->filter_deviceid_skip = 0; cmd->filter_deviceid_skip = 0;
cmd->filter_partitioned_skip = 0;
/* /*
* Can the command continue if some specified devices were not found? * Can the command continue if some specified devices were not found?
@ -5479,9 +5474,6 @@ do_command:
if (cmd->enable_devices_file && !pp->is_remove) if (cmd->enable_devices_file && !pp->is_remove)
cmd->filter_deviceid_skip = 1; cmd->filter_deviceid_skip = 1;
if (pp->force && !pp->is_remove)
cmd->filter_partitioned_skip = 1;
log_debug("Rescanning and filtering device args with exclusive open"); log_debug("Rescanning and filtering device args with exclusive open");
if (!label_scan_devs_excl(cmd, cmd->filter, &rescan_devs)) { if (!label_scan_devs_excl(cmd, cmd->filter, &rescan_devs)) {
log_debug("Failed to rescan devs excl"); log_debug("Failed to rescan devs excl");
@ -5495,9 +5487,7 @@ do_command:
dm_list_add(&pp->arg_fail, &pd->list); dm_list_add(&pp->arg_fail, &pd->list);
} }
} }
cmd->filter_deviceid_skip = 0; cmd->filter_deviceid_skip = 0;
cmd->filter_partitioned_skip = 0;
if (dm_list_empty(&pp->arg_process) && dm_list_empty(&remove_duplicates)) { if (dm_list_empty(&pp->arg_process) && dm_list_empty(&remove_duplicates)) {
log_debug("No devices to process."); log_debug("No devices to process.");