All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marian Csontos <mcsontos@sourceware.org>
To: lvm-devel@redhat.com
Subject: rhel-9.2.0 - vgimportclone: fix importing PV without metadata
Date: Thu, 26 Jan 2023 16:52:49 +0000 (GMT)	[thread overview]
Message-ID: <20230126165249.7A7443858D28@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8f7b4456ad93c3907a82fd03d0feceb9785e3bfc
Commit:        8f7b4456ad93c3907a82fd03d0feceb9785e3bfc
Parent:        db067b9054d87ada6aa133394e65e3af9d75fc08
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Thu Jan 5 14:28:31 2023 -0600
Committer:     Marian Csontos <mcsontos@redhat.com>
CommitterDate: Thu Jan 26 16:51:12 2023 +0100

vgimportclone: fix importing PV without metadata

If one of the PVs in the VG does not hold metadata, then the
command would fail, thinking that PV was from a different VG.
Also add missing free on that error path.

(cherry picked from commit c4b898a53eec39bc28b5451e7fde87945303a644)
---
 tools/vgimportclone.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c
index 60ef20762..93fa3b18d 100644
--- a/tools/vgimportclone.c
+++ b/tools/vgimportclone.c
@@ -203,7 +203,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
 	struct device *dev;
 	struct device_list *devl;
 	struct dm_list other_devs;
-	struct volume_group *vg, *error_vg;
+	struct volume_group *vg, *error_vg = NULL;
 	const char *vgname;
 	char base_vgname[NAME_LEN] = { 0 };
 	char tmp_vgname[NAME_LEN] = { 0 };
@@ -322,7 +322,7 @@ int vgimportclone(struct cmd_context *cmd, int argc, char **argv)
 			goto out;
 		}
 
-		if (!(vgname = lvmcache_vgname_from_info(info))) {
+		if (!(vgname = lvmcache_vgname_from_info(info)) || is_orphan_vg(vgname)) {
 			/* The PV may not have metadata, this will be resolved in
 			   the process_each_vg/vg_read at the end. */
 			continue;
@@ -503,6 +503,8 @@ retry_name:
 	}
 	ret = ECMD_PROCESSED;
 out:
+	if (error_vg)
+		release_vg(error_vg);
 	unlock_devices_file(cmd);
 	return ret;
 }


                 reply	other threads:[~2023-01-26 16:52 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=20230126165249.7A7443858D28@sourceware.org \
    --to=mcsontos@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.