Skip to contentSkip to conversation

LVM2 ./WHATS_NEW tools/vgremove.c

PATCH [email protected] 1 participant 1 message Jan 8, 2010

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall at sourceware.org 2010-01-08 14:03:55

Modified files:
. : WHATS_NEW
tools : vgremove.c

Log message:
Allow vgremove of a VG with PVs missing.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1373&r2=1.1374
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgremove.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59

WHATS_NEW +1 -0
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Allow vgremove of a VG with PVs missing.
   Keep log type consistent when changing mirror image count.
   Always set environment variables for an LVM2 device in 11-dm-lvm.rules.
   Add activation/udev_rules config option in lvm.conf.
tools/vgremove.c +13 -8
@@ -19,7 +19,7 @@
 			   struct volume_group *vg,
 			   void *handle __attribute((unused)))
 {
-	unsigned lv_count;
+	unsigned lv_count, missing;
 	force_t force;
 
 	if (!vg_check_status(vg, EXPORTED_VG)) {
@@ -31,13 +31,17 @@
 
 	force = arg_count(cmd, force_ARG);
 	if (lv_count) {
-		if ((force == PROMPT) &&
-		    (yes_no_prompt("Do you really want to remove volume "
-				   "group \"%s\" containing %u "
-				   "logical volumes? [y/n]: ",
-				   vg_name, lv_count) == 'n')) {
-			log_error("Volume group \"%s\" not removed", vg_name);
-			return ECMD_FAILED;
+		if (force == PROMPT) {
+			if ((missing = vg_missing_pv_count(vg)))
+				log_warn("WARNING: %d physical volumes are currently missing "
+					 "from the system.", missing);
+			if (yes_no_prompt("Do you really want to remove volume "
+					  "group \"%s\" containing %u "
+					  "logical volumes? [y/n]: ",
+					  vg_name, lv_count) == 'n') {
+				log_error("Volume group \"%s\" not removed", vg_name);
+				return ECMD_FAILED;
+			}
 		}
 		if (!remove_lvs_in_vg(cmd, vg, force)) {
 			stack;
@@ -67,6 +71,7 @@
 		return EINVALID_CMD_LINE;
 	}
 
+	cmd->handles_missing_pvs = 1;
 	ret = process_each_vg(cmd, argc, argv,
 			      READ_FOR_UPDATE,
 			      NULL, &vgremove_single);