All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Brassow <jbrassow@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH - v2] Fix circular dependency when attempting vgimport on VG with missing PVs
Date: Tue, 05 Feb 2013 12:44:17 -0600	[thread overview]
Message-ID: <1360089857.2284.1.camel@f16> (raw)
In-Reply-To: <1360019061.27780.3.camel@f16>

This patch makes the user supply '--force' in order to import volume
groups with missing PVs.

 brassow

TOOLS: Fix inablility to vgimport VGs with missing PVs

When there are missing PVs in a volume group, most operations that alter
the LVM metadata are disallowed.  It turns out that 'vgimport' is one of
those disallowed operations.  This is bad because it creates a circular
dependency.  'vgimport' will complain that the VG is inconsistent and that
'vgreduce --removemissing' must be run.  However, 'vgreduce' cannot be run
because it has not been imported.  Therefore, 'vgimport' must be one of
the operations allowed to change the metadata when PVs are missing.

Index: lvm2/tools/vgimport.c
===================================================================
--- lvm2.orig/tools/vgimport.c
+++ lvm2/tools/vgimport.c
@@ -68,6 +68,23 @@ int vgimport(struct cmd_context *cmd, in
 		return ECMD_FAILED;
 	}
 
+	if (arg_count(cmd, force_ARG)) {
+		/*
+		 * The volume group cannot be repaired unless it is first
+		 * imported.  If we don't allow the user a way to import the
+		 * VG while it is 'partial', then we will have created a
+		 * circular dependency.
+		 *
+		 * The reason we don't just simply set 'handles_missing_pvs'
+		 * by default is that we want to guard against the case
+		 * where the user simply forgot to move one or more disks in
+		 * the VG before running 'vgimport'.
+		 */
+		log_print("'--force' supplied.  Volume groups with missing PVs"
+			  " will be imported.");
+		cmd->handles_missing_pvs = 1;
+	}
+
 	return process_each_vg(cmd, argc, argv,
 			       READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
 			       NULL,
Index: lvm2/man/vgimport.8.in
===================================================================
--- lvm2.orig/man/vgimport.8.in
+++ lvm2/man/vgimport.8.in
@@ -20,6 +20,9 @@ See \fBlvm\fP(8) for common options.
 .TP
 .BR \-a ", " \-\-all
 Import all exported Volume Groups.
+.TP
+.BR \-\-force
+Import exported Volume Groups even if there are missing Physical Volumes.
 .SH SEE ALSO
 .BR lvm (8),
 .BR pvscan (8),




      reply	other threads:[~2013-02-05 18:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-04 23:04 [PATCH] Fix circular dependency when attempting vgimport on VG with missing PVs Jonathan Brassow
2013-02-05 18:44 ` Jonathan Brassow [this message]

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=1360089857.2284.1.camel@f16 \
    --to=jbrassow@redhat.com \
    --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.