From: David Teigland <teigland@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - vgimportclone: fix when duplicates are both in the devices file
Date: Fri, 20 Aug 2021 20:08:26 +0000 (GMT) [thread overview]
Message-ID: <20210820200826.83FBF3857C65@sourceware.org> (raw)
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=72af1cb0857afffd56f71847fcb9504d491c13e4
Commit: 72af1cb0857afffd56f71847fcb9504d491c13e4
Parent: 8b723139363a6b55e57ba4e9d599ff2efbae7d23
Author: David Teigland <teigland@redhat.com>
AuthorDate: Fri Aug 20 15:06:33 2021 -0500
Committer: David Teigland <teigland@redhat.com>
CommitterDate: Fri Aug 20 15:06:33 2021 -0500
vgimportclone: fix when duplicates are both in the devices file
Fix case where duplicate PVs are created (e.g. with dd) from
devices that are both already in the devices file.
---
test/shell/vgimportclone.sh | 21 +++++++++++++++++++++
tools/vgimportclone.c | 4 ++--
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/test/shell/vgimportclone.sh b/test/shell/vgimportclone.sh
index 2245d65eb..97d146b9e 100644
--- a/test/shell/vgimportclone.sh
+++ b/test/shell/vgimportclone.sh
@@ -43,9 +43,23 @@ vgimport $vg1
fail vgimport $vg1
vgchange -ay $vg1
+# Since the devices file is using devnames as ids,
+# it will not automatically know that dev2 is a
+# duplicate after the dd, so we need to remove dev2
+# from df, then add it again after the dd.
+if lvmdevices; then
+ lvmdevices --deldev "$dev2"
+fi
+
# Clone the LUN
dd if="$dev1" of="$dev2" bs=256K count=1
+# Requires -y to confirm prompt about adding
+# a duplicate pvid.
+if lvmdevices; then
+ lvmdevices -y --adddev "$dev2"
+fi
+
# Verify pvs works on each device to give us vgname
aux hide_dev "$dev2"
check pv_field "$dev1" vg_name $vg1
@@ -55,9 +69,16 @@ aux hide_dev "$dev1"
check pv_field "$dev2" vg_name $vg1
aux unhide_dev "$dev1"
+lvmdevices || true
+pvs -a -o+uuid
+
# Import the cloned PV to a new VG
vgimportclone --basevgname $vg2 "$dev2"
+lvmdevices || true
+pvs -a -o+uuid
+vgs
+
# Verify we can activate / deactivate the LV from both VGs
lvchange -ay $vg1/$lv1 $vg2/$lv1
vgchange -an $vg1 $vg2
diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c
index 55a2deb4d..8aa0dbba9 100644
--- a/tools/vgimportclone.c
+++ b/tools/vgimportclone.c
@@ -160,7 +160,7 @@ static int _update_vg(struct cmd_context *cmd, struct volume_group *vg,
* will be included in the metadata. The device file is written
* (with these additions) at the end of the command.
*/
- if (vp->import_devices) {
+ if (vp->import_devices || cmd->enable_devices_file) {
dm_list_iterate_items(devl, &vp->new_devs) {
if (!device_id_add(cmd, devl->dev, devl->dev->pvid, NULL, NULL)) {
log_error("Failed to add device id for %s.", dev_name(devl->dev));
@@ -506,7 +506,7 @@ retry_name:
* Should we be using device_ids_validate to check/fix other
* devs in the devices file?
*/
- if (vp.import_devices) {
+ if (vp.import_devices || cmd->enable_devices_file) {
if (!device_ids_write(cmd)) {
log_error("Failed to write devices file.");
goto out;
reply other threads:[~2021-08-20 20:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210820200826.83FBF3857C65@sourceware.org \
--to=teigland@sourceware.org \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.