summaryrefslogtreecommitdiff
path: root/tools/pvchange.c
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2016-02-11 12:37:36 -0600
committerDavid Teigland <teigland@redhat.com>2016-05-06 09:00:00 -0500
commitd3d13e134af15611c3f12107aa1627b12110a974 (patch)
tree2091603a65b29199adfdc835c5c6a5865ce1e3a7 /tools/pvchange.c
parent8b7a78c728be3b9af698dae9344d01752c4cf615 (diff)
downloadlvm2-d3d13e134af15611c3f12107aa1627b12110a974.tar.gz
lvmcache: process duplicate PVs directly
Previously, duplicate PVs were processed as a side effect of processing the "chosen" PV in lvmcache. The duplicate PV would be hacked into lvmcache temporarily in place of the chosen PV. In the old way, we had to always process the "chosen" PV device, even if a duplicate of it was named on the command line. This meant we were processing a different device than was asked for. This could be worked around by naming multiple duplicate devs on the command line in which case they were swapped in and out of lvmcache for processing. Now, the duplicate devs are processed directly in their own processing loop. This means we can remove the old hacks related to processing dups as a side effect of processing the chosen device. We can now simply process the device that was named on the command line. When the same PVID exists on two or more devices, one device is preferred and used in the VG, and the others are duplicates and are not used in the VG. The preferred device exists in lvmcache as usual. The duplicates exist in a specical list of unused duplicate devices. The duplicate devs have the "d" attribute and the "duplicate" reporting field displays "duplicate" for them. 'pvs' warns about duplicates, but the formal output only includes the single preferred PV. 'pvs -a' has the same warnings, and the duplicate devs are included in the output. 'pvs <path>' has the same warnings, and displays the named device, whether it is preferred or a duplicate.
Diffstat (limited to 'tools/pvchange.c')
-rw-r--r--tools/pvchange.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/pvchange.c b/tools/pvchange.c
index e103ebe66..e100b80c5 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -40,6 +40,23 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
goto bad;
}
+ /*
+ * The primary location of this check is in vg_write(), but it needs
+ * to be copied here to prevent the pv_write() which is called before
+ * the vg_write().
+ */
+ if (vg && lvmcache_found_duplicate_pvs() && vg_has_duplicate_pvs(vg)) {
+ if (!find_config_tree_bool(vg->cmd, devices_allow_changes_with_duplicate_pvs_CFG, NULL)) {
+ log_error("Cannot update volume group %s with duplicate PV devices.",
+ vg->name);
+ goto bad;
+ }
+ if (arg_count(cmd, uuid_ARG)) {
+ log_error("Resolve duplicate PV UUIDs with vgimportclone (or filters).");
+ goto bad;
+ }
+ }
+
/* If in a VG, must change using volume group. */
if (!is_orphan(pv)) {
if (tagargs && !(vg->fid->fmt->features & FMT_TAGS)) {