Skip to contentSkip to conversation

LVM2 ./WHATS_NEW tools/lvconvert.c

PATCH [email protected] 1 participant 1 message Jan 5, 2011

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: jbrassow at sourceware.org 2011-01-05 20:02:45

Modified files:
. : WHATS_NEW
tools : lvconvert.c

Log message:
Prevent the user from simultaneously adding a mirror log while removing a mirror image (or removing a log while adding a mirror). Advise the user to use two separate commands instead.

This issue become especially problematic when PVs are specified, as they tend to mean different things when adding vs removing. In a command that mixes adding and removing, it is impossible to decern exactly what the user wants.

This change prevents bug 603912.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1860&r2=1.1861
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.152&r2=1.153

WHATS_NEW +1 -0
@@ -1,5 +1,6 @@
 Version 2.02.80 - 
 ====================================
+  Prevent adding/removing mirror log while removing/adding an image.
   Add missing tests in _setup_task().
   Fail poll daemon creation when lvmcache_init() fails.
   Return defined value for errors in _copy_percent() and _snap_percent().
tools/lvconvert.c +19 -0
@@ -927,6 +927,25 @@
 	}
 
 	/*
+	 * Disallow adding logs while removing images or
+	 *          adding images while removing logs
+	 */
+	if ((*old_log_count < *new_log_count) &&
+	    (*old_mimage_count > *new_mimage_count)) {
+		log_error("Mirror logs cannot be added while images are"
+			  " being removed.");
+		log_error("Try two separate commands.");
+		return 0;
+	}
+	if ((*old_log_count > *new_log_count) &&
+	    (*old_mimage_count < *new_mimage_count)) {
+		log_error("Mirror images cannot be added while logs are"
+			  " being removed.");
+		log_error("Try two separate commands.");
+		return 0;
+	}
+
+	/*
 	 * No mirrored logs for cluster mirrors until
 	 * log daemon is multi-threaded.
 	 */