public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/tools lvconvert.c
@ 2010-01-13  1:47 snitzer
  0 siblings, 0 replies; 38+ messages in thread
From: snitzer @ 2010-01-13  1:47 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2010-01-13 01:47:18

Modified files:
	tools          : lvconvert.c 

Log message:
	Do not allow merging over mounted logical volumes.
	When preserving origin, check that the snapshot is not mounted.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111

--- LVM2/tools/lvconvert.c	2010/01/13 01:45:16	1.110
+++ LVM2/tools/lvconvert.c	2010/01/13 01:47:18	1.111
@@ -1058,6 +1058,7 @@
 	int r = 0;
 	struct logical_volume *origin = origin_from_cow(lv);
 	struct lv_segment *cow_seg = find_cow(lv);
+	struct lvinfo info;
 
 	/* Check if merge is possible */
 	if (cow_seg->status & SNAPSHOT_MERGE) {
@@ -1070,6 +1071,27 @@
 		return 0;
 	}
 
+	/*
+	 * Prevent merge with open device(s) as it would likely lead
+	 * to application/filesystem failure.
+	 *
+	 * FIXME testing open_count is racey; snapshot-merge target's
+	 * constructor and DM should prevent appropriate devices from
+	 * being open.
+	 */
+	if (lv_info(cmd, origin, &info, 1, 0)) {
+		if (info.open_count) {
+			log_error("Can't merge over open origin volume");
+			return 0;
+		}
+	}
+	if (lv_info(cmd, lv, &info, 1, 0)) {
+		if (info.open_count) {
+			log_error("Can't merge when snapshot is open");
+			return 0;
+		}
+	}
+
 	init_snapshot_merge(cow_seg, origin);
 
 	/* store vg on disk(s) */


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2012-04-19 21:50 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2012-04-19 21:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2012-04-19 21:50:37

Modified files:
	tools          : lvconvert.c 

Log message:
	Fix for bug 807776: invalid lvconvert --merge output should mention raid1 now
	
	s/snapshot/mergeable volume/

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.189&r2=1.190

--- LVM2/tools/lvconvert.c	2012/03/30 08:58:02	1.189
+++ LVM2/tools/lvconvert.c	2012/04/19 21:50:37	1.190
@@ -1760,7 +1760,7 @@
 
 	if (lp->merge) {
 		if (!lv_is_cow(lv)) {
-			log_error("Logical volume \"%s\" is not a snapshot",
+			log_error("\"%s\" is not a mergeable logical volume",
 				  lv->name);
 			return ECMD_FAILED;
 		}


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2012-02-23 22:36 zkabelac
  0 siblings, 0 replies; 38+ messages in thread
From: zkabelac @ 2012-02-23 22:36 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-23 22:36:57

Modified files:
	tools          : lvconvert.c 

Log message:
	Keep same sign for 's' counter

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.185&r2=1.186

--- LVM2/tools/lvconvert.c	2012/02/22 17:18:49	1.185
+++ LVM2/tools/lvconvert.c	2012/02/23 22:36:56	1.186
@@ -596,7 +596,8 @@
 
 static int _failed_logs_count(struct logical_volume *lv)
 {
-	int ret = 0, s;
+	int ret = 0;
+	unsigned s;
 	struct logical_volume *log_lv = first_seg(lv)->log_lv;
 	if (log_lv && (log_lv->status & PARTIAL_LV)) {
 		if (log_lv->status & MIRRORED)


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2012-02-22 16:03 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2012-02-22 16:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2012-02-22 16:03:55

Modified files:
	tools          : lvconvert.c 

Log message:
	Add some messages that indicate completion of RAID device replacement.
	
	There were no messages printed upon completiion of RAID device replacement.
	This could cause confusion/concern during automated recovery, because the
	user sees the failure messages but no other messages indicating correction.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.183&r2=1.184

--- LVM2/tools/lvconvert.c	2012/02/22 15:20:50	1.183
+++ LVM2/tools/lvconvert.c	2012/02/22 16:03:55	1.184
@@ -1531,7 +1531,15 @@
 			if (!(failed_pvs = _failed_pv_list(lv->vg)))
 				return_0;
 
-			return lv_raid_replace(lv, failed_pvs, lp->pvh);
+			if (!lv_raid_replace(lv, failed_pvs, lp->pvh)) {
+				log_error("Failed to replace faulty devices in"
+					  " %s/%s.", lv->vg->name, lv->name);
+				return 0;
+			}
+
+			log_print("Faulty devices in %s/%s successfully"
+				  " replaced.", lv->vg->name, lv->name);
+			return 1;
 		}
 
 		/* "warn" if policy not set to replace */


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2012-02-22 15:20 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2012-02-22 15:20 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2012-02-22 15:20:51

Modified files:
	tools          : lvconvert.c 

Log message:
	Fix a bad return code in 'lvconvert_raid'
	
	Functions at this level do return 0 or 1, not ECMD_* values.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.182&r2=1.183

--- LVM2/tools/lvconvert.c	2012/02/13 18:38:36	1.182
+++ LVM2/tools/lvconvert.c	2012/02/22 15:20:50	1.183
@@ -1528,10 +1528,9 @@
 		_lvconvert_raid_repair_ask(cmd, &replace);
 
 		if (replace) {
-			if (!(failed_pvs = _failed_pv_list(lv->vg))) {
-				stack;
-				return ECMD_FAILED;
-			}
+			if (!(failed_pvs = _failed_pv_list(lv->vg)))
+				return_0;
+
 			return lv_raid_replace(lv, failed_pvs, lp->pvh);
 		}
 


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2012-02-13 18:38 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2012-02-13 18:38 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2012-02-13 18:38:37

Modified files:
	tools          : lvconvert.c 

Log message:
	Change confusing message that is printed when a RAID device fails.
	
	s/Issue/Use/, otherwise it is easy to misread "Issue" as "Issuing" - causing
	the user confusion as to whether the action was performed automatically or
	whether they need to issue the command.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.181&r2=1.182

--- LVM2/tools/lvconvert.c	2012/02/13 18:36:55	1.181
+++ LVM2/tools/lvconvert.c	2012/02/13 18:38:36	1.182
@@ -1537,7 +1537,7 @@
 
 		/* "warn" if policy not set to replace */
 		if (arg_count(cmd, use_policies_ARG))
-			log_error("Issue 'lvconvert --repair %s/%s' to "
+			log_error("Use 'lvconvert --repair %s/%s' to "
 				  "replace failed device",
 				  lv->vg->name, lv->name);
 		return 1;


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2012-02-13 18:36 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2012-02-13 18:36 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2012-02-13 18:36:56

Modified files:
	tools          : lvconvert.c 

Log message:
	Fix possible NULL pointer dereferences when updating mirror log.
	
	'_lv_update_log_type' takes a lvconvert_params argument so that it can pass
	down the user's preference of 'region_size' and allocation_policy.  When
	'mirror_remove_missing' was introduced (commit ID
	95986e42a18ca98c9b1d777346978b7297c85558) it didn't make sense to pass down
	user preferences - so NULL was given instead.  While it may never happen in
	practice, static analysis reveals that this argument could be dereferenced.
	So, if the user preferences were not passed in, glean the necessary fields
	from what is already set in the LV.
	
	Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
	Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
	
	(Not updating WHATSNEW for this simple clean-up.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.180&r2=1.181

--- LVM2/tools/lvconvert.c	2012/01/25 22:38:40	1.180
+++ LVM2/tools/lvconvert.c	2012/02/13 18:36:55	1.181
@@ -770,8 +770,10 @@
 			       struct dm_list *operable_pvs,
 			       int log_count)
 {
-	uint32_t region_size;
 	int old_log_count;
+	uint32_t region_size = (lp) ? lp->region_size :
+		first_seg(lv)->region_size;
+	alloc_policy_t alloc = (lp) ? lp->alloc : lv->alloc;
 	struct logical_volume *original_lv;
 	struct logical_volume *log_lv;
 
@@ -793,13 +795,12 @@
 
 	/* Adding redundancy to the log */
 	if (old_log_count < log_count) {
-
 		region_size = adjusted_mirror_region_size(lv->vg->extent_size,
 							  lv->le_count,
-							  lp->region_size);
+							  region_size);
 
 		if (!add_mirror_log(cmd, original_lv, log_count,
-				    region_size, operable_pvs, lp->alloc))
+				    region_size, operable_pvs, alloc))
 			return_0;
 		/*
 		 * FIXME: This simple approach won't work in cluster mirrors,
@@ -812,7 +813,8 @@
 	}
 
 	/* Reducing redundancy of the log */
-	return remove_mirror_images(log_lv, log_count, is_mirror_image_removable, operable_pvs, 1U);
+	return remove_mirror_images(log_lv, log_count,
+				    is_mirror_image_removable, operable_pvs, 1U);
 }
 
 /*


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2012-01-25 22:38 zkabelac
  0 siblings, 0 replies; 38+ messages in thread
From: zkabelac @ 2012-01-25 22:38 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-01-25 22:38:40

Modified files:
	tools          : lvconvert.c 

Log message:
	Cosmetic change use return macro with implicit stack

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.179&r2=1.180

--- LVM2/tools/lvconvert.c	2012/01/20 22:03:48	1.179
+++ LVM2/tools/lvconvert.c	2012/01/25 22:38:40	1.180
@@ -1084,10 +1084,9 @@
 		 */
 		if (!lv_add_mirrors(cmd, lv, new_mimage_count - 1, lp->stripes,
 				    lp->stripe_size, region_size, new_log_count, operable_pvs,
-				    lp->alloc, MIRROR_BY_LV)) {
-			stack;
-			return 0;
-		}
+				    lp->alloc, MIRROR_BY_LV))
+			return_0;
+
 		if (lp->wait_completion)
 			lp->need_polling = 1;
 


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2011-12-08 18:00 agk
  0 siblings, 0 replies; 38+ messages in thread
From: agk @ 2011-12-08 18:00 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-12-08 18:00:04

Modified files:
	tools          : lvconvert.c 

Log message:
	tag uninit var

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.176&r2=1.177

--- LVM2/tools/lvconvert.c	2011/12/06 19:30:17	1.176
+++ LVM2/tools/lvconvert.c	2011/12/08 18:00:03	1.177
@@ -1460,7 +1460,7 @@
 static int lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *lp)
 {
 	int replace = 0;
-	int image_count;
+	int uninitialized_var(image_count);
 	struct dm_list *failed_pvs;
 	struct cmd_context *cmd = lv->vg->cmd;
 	struct lv_segment *seg = first_seg(lv);


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2011-06-29  2:06 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2011-06-29  2:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-06-29 02:06:26

Modified files:
	tools          : lvconvert.c 

Log message:
	Fix error message - the parameter name is '--mirrorlog' not '--log'

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.164&r2=1.165

--- LVM2/tools/lvconvert.c	2011/06/28 21:28:35	1.164
+++ LVM2/tools/lvconvert.c	2011/06/29 02:06:26	1.165
@@ -131,7 +131,7 @@
 	    (arg_count(cmd, mirrorlog_ARG) || arg_count(cmd, mirrors_ARG) ||
 	     arg_count(cmd, repair_ARG))) {
 		log_error("--snapshot or --merge argument cannot be mixed "
-			  "with --mirrors, --repair or --log");
+			  "with --mirrors, --repair or --mirrorlog");
 		return 0;
 	}
 


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2011-06-28 21:28 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2011-06-28 21:28 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-06-28 21:28:35

Modified files:
	tools          : lvconvert.c 

Log message:
	Remove unnecesary conditional.
	
	The conditional is not just unnecessary, it would have been wrong.  The code
	is suppose to be checking if the 'splitmirrors_ARG' is negative, but it
	instead is checking 'mirrors_ARG'.  Rather than changing the argument being
	checked, I've pulled the check entirely because 'splitmirrors_ARG' is already
	guarenteed to not be negative by virtue of the fact that it is a 'int_arg'.
	Negative values will be caught in _process_command_line().

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.163&r2=1.164

--- LVM2/tools/lvconvert.c	2011/06/01 12:24:16	1.163
+++ LVM2/tools/lvconvert.c	2011/06/28 21:28:35	1.164
@@ -169,11 +169,6 @@
 			return_0;
 
 		lp->keep_mimages = 1;
-		if (arg_sign_value(cmd, mirrors_ARG, 0) == SIGN_MINUS) {
-			log_error("Argument to --splitmirrors"
-				  " cannot be negative");
-			return 0;
-		}
 		lp->mirrors = arg_uint_value(cmd, splitmirrors_ARG, 0);
 		lp->mirrors_sign = SIGN_MINUS;
 	} else if (arg_count(cmd, name_ARG)) {


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2011-01-19 19:24 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2011-01-19 19:24 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-01-19 19:24:07

Modified files:
	tools          : lvconvert.c 

Log message:
	Remove duplicate statement (pasted twice by patch at some point?)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.155&r2=1.156

--- LVM2/tools/lvconvert.c	2011/01/11 17:05:10	1.155
+++ LVM2/tools/lvconvert.c	2011/01/19 19:24:07	1.156
@@ -1081,16 +1081,6 @@
 		}
 
 		/*
-		 * Is there already a convert in progress?  We do not
-		 * currently allow more than one.
-		 */
-		if (find_temporary_mirror(lv) || (lv->status & CONVERTING)) {
-			log_error("%s is already being converted.  Unable to start another conversion.",
-				  lv->name);
-			return 0;
-		}
-
-		/*
 		 * Log addition/removal should be done before the layer
 		 * insertion to make the end result consistent with
 		 * linear-to-mirror conversion.


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-11-28 18:37 snitzer
  0 siblings, 0 replies; 38+ messages in thread
From: snitzer @ 2010-11-28 18:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2010-11-28 18:37:34

Modified files:
	tools          : lvconvert.c 

Log message:
	Fix "it's" typo to be "its" in lvconvert error message.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.149&r2=1.150

--- LVM2/tools/lvconvert.c	2010/11/25 17:15:47	1.149
+++ LVM2/tools/lvconvert.c	2010/11/28 18:37:33	1.150
@@ -1572,7 +1572,7 @@
 			return ECMD_FAILED;
 		}
 		if (!lvconvert_merge(cmd, lv, lp)) {
-			log_error("Unable to merge LV \"%s\" into it's origin.", lv->name);
+			log_error("Unable to merge LV \"%s\" into its origin.", lv->name);
 			return ECMD_FAILED;
 		}
 	} else if (lp->snapshot) {


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-07-13 22:04 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2010-07-13 22:04 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-07-13 22:04:36

Modified files:
	tools          : lvconvert.c 

Log message:
	Fix reversal of LV list before performing a split mirror.
	
	When splitting off mirror images from a mirror, we always take
	LVs from the end of a list.  For example, if the mirror sub-devices
	are lv_mimage_[012], we should select lv_mimage_2 if splitting off
	one image.  However, lv_mimage_0 was being selected instead.
	
	The problem came from calling '_move_removable_mimages_to_end'
	when it was unnecessary to do so.  When the user /does/ specify
	specific devices to be removed, this function properly moved the
	appropriate LVs to the end of the list for extraction.  However,
	if the user /doesn't/ give any specific PVs, the function should
	do nothing.  '_move_removable_mimages_to_end' was keying off of
	whether 'removable_pvs' was NULL or not and this value was
	improperly being populated with the set of all available PVs.
	This was causing '_move_removable_mimages_to_end' to completely
	reverse the list, which in turn caused us to extract the
	hithertofore front-of-the-list LVs.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.139&r2=1.140

--- LVM2/tools/lvconvert.c	2010/07/13 21:53:07	1.139
+++ LVM2/tools/lvconvert.c	2010/07/13 22:04:36	1.140
@@ -1002,7 +1002,7 @@
 						  lv->le_count,
 						  lp->region_size);
 
-	if (!operable_pvs)
+	if (!operable_pvs && !lp->keep_mimages)
 		operable_pvs = lp->pvh;
 
 	seg = first_seg(lv);


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-07-13 21:53 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2010-07-13 21:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-07-13 21:53:08

Modified files:
	tools          : lvconvert.c 

Log message:
	Fix for bug 612311: Split of linear provides no error msg
	
	An unhandled condition allowed the command to terminate
	cleanly without a warning.  Added a check for the
	'--splitmirrors' argument to allow execution to the lower
	level function that has the check to see if the user is
	trying to split a linear device.  You should now see a
	message if you try to use --splitmirrors on a linear device.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.138&r2=1.139

--- LVM2/tools/lvconvert.c	2010/07/09 15:34:48	1.138
+++ LVM2/tools/lvconvert.c	2010/07/13 21:53:07	1.139
@@ -861,7 +861,8 @@
 	else if (lp->mirrors_sign == SIGN_PLUS)
 		lp->mirrors = *old_mimage_count + lp->mirrors;
 	else if (lp->mirrors_sign == SIGN_MINUS)
-		lp->mirrors = *old_mimage_count - lp->mirrors;
+		lp->mirrors = (*old_mimage_count > lp->mirrors) ?
+			*old_mimage_count - lp->mirrors: 0;
 	else
 		lp->mirrors += 1;
 
@@ -876,8 +877,8 @@
 
 	/* Did the user try to subtract more legs than available? */
 	if (lp->mirrors < 1) {
-		log_error("Logical volume %s only has %" PRIu32 " mirrors.",
-			  lv->name, *old_mimage_count);
+		log_error("Unable to reduce images by specified amount - only %d in %s",
+			  *old_mimage_count, lv->name);
 		return 0;
 	}
 
@@ -1561,7 +1562,9 @@
 			stack;
 			return ECMD_FAILED;
 		}
-	} else if (arg_count(cmd, mirrors_ARG) || (lv->status & MIRRORED)) {
+	} else if (arg_count(cmd, mirrors_ARG) ||
+		   arg_count(cmd, splitmirrors_ARG) ||
+		   (lv->status & MIRRORED)) {
 		if (!archive(lv->vg)) {
 			stack;
 			return ECMD_FAILED;


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-07-01 10:10 mornfall
  0 siblings, 0 replies; 38+ messages in thread
From: mornfall @ 2010-07-01 10:10 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-07-01 10:10:52

Modified files:
	tools          : lvconvert.c 

Log message:
	Restore the "removemissing" behaviour of lvconvert --repair --use-policies.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.135&r2=1.136

--- LVM2/tools/lvconvert.c	2010/06/23 20:32:29	1.135
+++ LVM2/tools/lvconvert.c	2010/07/01 10:10:52	1.136
@@ -790,7 +790,6 @@
 			stack;
 			return;
 		}
-
 		log_warn("%d missing and now unallocated Physical Volumes removed from VG.", removed);
 	}
 }
@@ -1177,7 +1176,6 @@
 	int replace_log = 0;
 	int replace_mirrors = 0;
 	uint32_t new_log_count, log_count;
-	struct dm_list *failed_pvs = NULL;
 	struct logical_volume *log_lv;
 
 	cmd->handles_missing_pvs = 1;
@@ -1232,14 +1230,14 @@
 	/*
 	 * First phase - remove faulty devices
 	 */
-	if (!(failed_pvs = _failed_pv_list(lv->vg)))
+	if (!(lp->failed_pvs = _failed_pv_list(lv->vg)))
 		return_0;
 
 	/*
 	 * We must adjust the log first, or the entire mirror
 	 * will get stuck during a suspend.
 	 */
-	if (!_lv_update_mirrored_log(lv, failed_pvs, new_log_count))
+	if (!_lv_update_mirrored_log(lv, lp->failed_pvs, new_log_count))
 		return 0;
 
 	if (lp->mirrors == 1)
@@ -1252,7 +1250,7 @@
 			return 0;
 	}
 
-	if (!_lv_update_log_type(cmd, lp, lv, failed_pvs,
+	if (!_lv_update_log_type(cmd, lp, lv, lp->failed_pvs,
 				 new_log_count))
 		return 0;
 


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-06-23 20:32 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2010-06-23 20:32 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-06-23 20:32:29

Modified files:
	tools          : lvconvert.c 

Log message:
	Committing Taka's patch...  He found a problem during
	the failure of a device that contained both a image of
	a mirror and an image of the mirrored log.  The order
	of the handling of those faults was important (and
	wrong), this patch corrects that.
	
	Patch-From: Takahiro Yasui <tyasui@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.134&r2=1.135

--- LVM2/tools/lvconvert.c	2010/05/24 15:32:21	1.134
+++ LVM2/tools/lvconvert.c	2010/06/23 20:32:29	1.135
@@ -689,6 +689,27 @@
 	return lv_mirror_count(log_lv);
 }
 
+static int _lv_update_mirrored_log(struct logical_volume *lv,
+				   struct dm_list *operable_pvs,
+				   int log_count)
+{
+	int old_log_count;
+	struct logical_volume *log_lv;
+
+	log_lv = first_seg(_original_lv(lv))->log_lv;
+	if (!log_lv || !(log_lv->status & MIRRORED))
+		return 1;
+
+	old_log_count = _get_log_count(lv);
+	if (old_log_count == log_count)
+		return 1;
+
+	/* Reducing redundancy of the log */
+	return remove_mirror_images(log_lv, log_count,
+				    is_mirror_image_removable,
+				    operable_pvs, 0U);
+}
+
 static int _lv_update_log_type(struct cmd_context *cmd,
 			       struct lvconvert_params *lp,
 			       struct logical_volume *lv,
@@ -1218,15 +1239,23 @@
 	 * We must adjust the log first, or the entire mirror
 	 * will get stuck during a suspend.
 	 */
-	if (!_lv_update_log_type(cmd, lp, lv, failed_pvs, new_log_count))
+	if (!_lv_update_mirrored_log(lv, failed_pvs, new_log_count))
 		return 0;
 
+	if (lp->mirrors == 1)
+		new_log_count = 0;
+
 	if (failed_mirrors) {
-		if (!lv_remove_mirrors(cmd, lv, failed_mirrors, new_log_count,
+		if (!lv_remove_mirrors(cmd, lv, failed_mirrors,
+				       new_log_count ? 0U : 1U,
 				       _is_partial_lv, NULL, 0))
 			return 0;
 	}
 
+	if (!_lv_update_log_type(cmd, lp, lv, failed_pvs,
+				 new_log_count))
+		return 0;
+
 	if (!_reload_lv(cmd, lv))
 		return 0;
 


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-04-28 17:41 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2010-04-28 17:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-04-28 17:41:31

Modified files:
	tools          : lvconvert.c 

Log message:
	Don't attempt to convert the log type of an LV if the LV
	is not a mirror.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133

--- LVM2/tools/lvconvert.c	2010/04/26 18:31:58	1.132
+++ LVM2/tools/lvconvert.c	2010/04/28 17:41:30	1.133
@@ -1074,7 +1074,7 @@
 	/*
 	 * Converting the log type
 	 */
-	if (old_log_count != new_log_count) {
+	if ((lv->status & MIRRORED) && (old_log_count != new_log_count)) {
 		if (!_lv_update_log_type(cmd, lp, lv,
 					 operable_pvs, new_log_count)) {
 			stack;


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-04-26 18:12 agk
  0 siblings, 0 replies; 38+ messages in thread
From: agk @ 2010-04-26 18:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-04-26 18:12:44

Modified files:
	tools          : lvconvert.c 

Log message:
	add comments

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.130&r2=1.131

--- LVM2/tools/lvconvert.c	2010/04/21 14:04:26	1.130
+++ LVM2/tools/lvconvert.c	2010/04/26 18:12:40	1.131
@@ -1195,6 +1195,9 @@
 	if (!_lv_update_log_type(cmd, lp, lv, failed_pvs, new_log_count))
 		return 0;
 
+	/*
+	 * Remove all failed_pvs
+	 */
 	if (!_lvconvert_mirrors_aux(cmd, lv, lp, failed_pvs,
 				    lp->mirrors, new_log_count))
 		return 0;
@@ -1570,6 +1573,9 @@
 	if (!lv)
 		goto_out;
 
+	/*
+	 * lp->pvh holds the list of PVs available for allocation or removal
+	 */
 	if (lp->pv_count) {
 		if (!(lp->pvh = create_pv_list(cmd->mem, lv->vg, lp->pv_count,
 					      lp->pvs, 0)))


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-04-20 12:18 agk
  0 siblings, 0 replies; 38+ messages in thread
From: agk @ 2010-04-20 12:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-04-20 12:18:34

Modified files:
	tools          : lvconvert.c 

Log message:
	typo in comment

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.128&r2=1.129

--- LVM2/tools/lvconvert.c	2010/04/14 13:51:58	1.128
+++ LVM2/tools/lvconvert.c	2010/04/20 12:18:31	1.129
@@ -1046,7 +1046,7 @@
 		uint32_t nmc = old_mimage_count - new_mimage_count;
 		uint32_t nlc = (!new_log_count || lp->mirrors == 1) ? 1U : 0U;
 
-		/* FIXME: We did nlc used to be calculated that way? */
+		/* FIXME: Why did nlc used to be calculated that way? */
 
 		/* Reduce number of mirrors */
 		if (lp->keep_mimages) {


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-03-31 20:39 agk
  0 siblings, 0 replies; 38+ messages in thread
From: agk @ 2010-03-31 20:39 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-03-31 20:39:51

Modified files:
	tools          : lvconvert.c 

Log message:
	remove unused var

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.123&r2=1.124

--- LVM2/tools/lvconvert.c	2010/03/26 22:15:44	1.123
+++ LVM2/tools/lvconvert.c	2010/03/31 20:39:51	1.124
@@ -918,7 +918,6 @@
 				  int allocation_failures_ok)
 {
 	uint32_t region_size;
-	struct dm_list *tmp;
 	struct lv_segment *seg;
 	struct logical_volume *layer_lv;
 	uint32_t old_mimage_count = lv_mirror_count(lv);


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-02-05 22:47 snitzer
  0 siblings, 0 replies; 38+ messages in thread
From: snitzer @ 2010-02-05 22:47 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2010-02-05 22:47:22

Modified files:
	tools          : lvconvert.c 

Log message:
	Switch lvconvert_single() over to using get_vg_lock_and_logical_volume()
	
	This change was deferred to help ease the review of previous refactoring
	related to using process_each_lv() for lvconvert's merge support.  Not
	that doing so _really_ helped but...
	
	Signed-off-by: Mike Snitzer <snitzer@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119

--- LVM2/tools/lvconvert.c	2010/02/05 22:44:38	1.118
+++ LVM2/tools/lvconvert.c	2010/02/05 22:47:22	1.119
@@ -1342,8 +1342,7 @@
 
 static int lvconvert_single(struct cmd_context *cmd, struct lvconvert_params *lp)
 {
-	struct volume_group *vg;
-	struct lv_list *lvl;
+	struct logical_volume *lv = NULL;
 	int ret = ECMD_FAILED;
 	int saved_ignore_suspended_devices = ignore_suspended_devices();
 
@@ -1352,36 +1351,29 @@
 		cmd->handles_missing_pvs = 1;
 	}
 
-	log_verbose("Checking for existing volume group \"%s\"", lp->vg_name);
-
-	vg = vg_read_for_update(cmd, lp->vg_name, NULL, 0);
-	if (vg_read_error(vg))
-		goto out;
-
-	if (!(lvl = find_lv_in_vg(vg, lp->lv_name))) {
-		log_error("Logical volume \"%s\" not found in "
-			  "volume group \"%s\"", lp->lv_name, lp->vg_name);
-		goto bad;
-	}
+	lv = get_vg_lock_and_logical_volume(cmd, lp->vg_name, lp->lv_name);
+	if (!lv)
+		goto_out;
 
 	if (lp->pv_count) {
-		if (!(lp->pvh = create_pv_list(cmd->mem, vg, lp->pv_count,
+		if (!(lp->pvh = create_pv_list(cmd->mem, lv->vg, lp->pv_count,
 					      lp->pvs, 0)))
 			goto_bad;
 	} else
-		lp->pvh = &vg->pvs;
+		lp->pvh = &lv->vg->pvs;
 
-	lp->lv_to_poll = lvl->lv;
-	ret = _lvconvert_single(cmd, lvl->lv, lp);
+	lp->lv_to_poll = lv;
+	ret = _lvconvert_single(cmd, lv, lp);
 bad:
 	unlock_vg(cmd, lp->vg_name);
 
 	if (ret == ECMD_PROCESSED && lp->need_polling)
 		ret = poll_logical_volume(cmd, lp->lv_to_poll,
 					  lp->wait_completion);
+
+	vg_release(lv->vg);
 out:
 	init_ignore_suspended_devices(saved_ignore_suspended_devices);
-	vg_release(vg);
 	return ret;
 }
 


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-01-13  1:49 snitzer
  0 siblings, 0 replies; 38+ messages in thread
From: snitzer @ 2010-01-13  1:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2010-01-13 01:49:52

Modified files:
	tools          : lvconvert.c 

Log message:
	Background poll for lvconvert --merge command.
	The merging snapshot is removed when the merge finishes.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.111&r2=1.112

--- LVM2/tools/lvconvert.c	2010/01/13 01:47:18	1.111
+++ LVM2/tools/lvconvert.c	2010/01/13 01:49:52	1.112
@@ -44,6 +44,8 @@
 	char **pvs;
 	struct dm_list *pvh;
 	struct dm_list *failed_pvs;
+
+	struct logical_volume *lv_to_poll;
 };
 
 static int _lvconvert_name_params(struct lvconvert_params *lp,
@@ -370,6 +372,54 @@
 	return r;
 }
 
+static int _finish_lvconvert_merge(struct cmd_context *cmd,
+				   struct volume_group *vg,
+				   struct logical_volume *lv,
+				   struct dm_list *lvs_changed __attribute((unused)))
+{
+	struct lv_segment *snap_seg = lv->merging_snapshot;
+	if (!snap_seg) {
+		log_error("Logical volume %s has no merging snapshot.", lv->name);
+		return 0;
+	}
+
+	log_print("Merge of snapshot into logical volume %s has finished.", lv->name);
+	if (!lv_remove_single(cmd, snap_seg->cow, DONT_PROMPT)) {
+		log_error("Could not remove snapshot %s merged into %s.",
+			  snap_seg->cow->name, lv->name);
+		return 0;
+	}
+
+	return 1;
+}
+
+static progress_t _poll_merge_progress(struct cmd_context *cmd,
+				       struct logical_volume *lv,
+				       const char *name __attribute((unused)),
+				       struct daemon_parms *parms)
+{
+	float percent = 0.0;
+	percent_range_t percent_range;
+
+	if (!lv_snapshot_percent(lv, &percent, &percent_range)) {
+		log_error("%s: Failed query for merging percentage", lv->name);
+		return PROGRESS_CHECK_FAILED;
+	} else if (percent_range == PERCENT_INVALID) {
+		log_error("%s: Merging snapshot invalidated. Aborting merge.", lv->name);
+		return PROGRESS_CHECK_FAILED;
+	}
+
+	if (parms->progress_display)
+		log_print("%s: %s: %.1f%%", lv->name, parms->progress_title, percent);
+	else
+		log_verbose("%s: %s: %.1f%%", lv->name, parms->progress_title, percent);
+
+	if (percent_range == PERCENT_0)
+		return PROGRESS_FINISHED_ALL;
+
+	return PROGRESS_UNFINISHED;
+}
+
 static struct poll_functions _lvconvert_mirror_fns = {
 	.get_copy_vg = _get_lvconvert_vg,
 	.get_copy_lv = _get_lvconvert_lv,
@@ -377,6 +427,13 @@
 	.finish_copy = _finish_lvconvert_mirror,
 };
 
+static struct poll_functions _lvconvert_merge_fns = {
+	.get_copy_vg = _get_lvconvert_vg,
+	.get_copy_lv = _get_lvconvert_lv,
+	.poll_progress = _poll_merge_progress,
+	.finish_copy = _finish_lvconvert_merge,
+};
+
 int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv,
 		   unsigned background)
 {
@@ -393,8 +450,12 @@
 
 	memcpy(uuid, &lv->lvid, sizeof(lv->lvid));
 
-	return poll_daemon(cmd, lv_full_name, uuid, background, 0,
-			   &_lvconvert_mirror_fns, "Converted");
+	if (!lv->merging_snapshot)
+		return poll_daemon(cmd, lv_full_name, uuid, background, 0,
+				   &_lvconvert_mirror_fns, "Converted");
+	else
+		return poll_daemon(cmd, lv_full_name, uuid, background, 0,
+				   &_lvconvert_merge_fns, "Merged");
 }
 
 static int _insert_lvconvert_layer(struct cmd_context *cmd,
@@ -1121,6 +1182,9 @@
 		/* merge is running regardless of this deactivation failure */
 	}
 
+	lp->need_polling = 1;
+	lp->lv_to_poll = origin;
+
 	r = 1;
 	log_print("Merging of volume %s started.", lv->name);
 out:
@@ -1237,17 +1301,18 @@
 	} else
 		lp.pvh = &vg->pvs;
 
+	lp.lv_to_poll = lvl->lv;
 	ret = lvconvert_single(cmd, lvl->lv, &lp);
 
 bad:
 	unlock_vg(cmd, lp.vg_name);
 
 	if (ret == ECMD_PROCESSED && lp.need_polling) {
-		if (!lv_info(cmd, lvl->lv, &info, 1, 0) || !info.exists) {
+		if (!lv_info(cmd, lp.lv_to_poll, &info, 1, 0) || !info.exists) {
 			log_print("Conversion starts after activation");
 			goto out;
 		}
-		ret = lvconvert_poll(cmd, lvl->lv,
+		ret = lvconvert_poll(cmd, lp.lv_to_poll,
 				     lp.wait_completion ? 0 : 1U);
 	}
 out:


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-01-11 17:13 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2010-01-11 17:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-01-11 17:13:46

Modified files:
	tools          : lvconvert.c 

Log message:
	Found 2 problems with my previous check-in:
	
	date: 2010/01/07 20:42:55;  author: jbrassow;  state: Exp;  lines: +11 -0
	The patch fixes some lvconvert issues (WRT mirror <-> mirror).
	
	1) 'exisiting_mirrors' and 'lp->mirrors' where taken to be in 'n-1'
	notation (i.e a 2-way mirror is '1' and a linear is '0'), but the
	variables were in 'n' notation.
	2) After adding the redundant mirror log support, I was calculating
	log_count by looking at the mirror log LV, but didn't take into
	account the fact that there could be no mirror log!
	
	Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.106&r2=1.107

--- LVM2/tools/lvconvert.c	2010/01/08 22:32:35	1.106
+++ LVM2/tools/lvconvert.c	2010/01/11 17:13:45	1.107
@@ -668,10 +668,11 @@
 	 * the type of log wasn't specified, then let's keep the log type
 	 * the same.
 	 */
-	if (existing_mirrors && lp->mirrors &&
-	    (lp->mirrors != existing_mirrors) &&
+	if ((existing_mirrors > 1) && (lp->mirrors > 1) &&
+	    (lp->mirrors != existing_mirrors) && !(lv->status & CONVERTING) &&
 	    !arg_count(cmd, mirrorlog_ARG) && !arg_count(cmd, corelog_ARG)) {
-		log_count = lv_mirror_count(first_seg(lv)->log_lv);
+		log_count = (first_seg(lv)->log_lv) ?
+			lv_mirror_count(first_seg(lv)->log_lv) : 0;
 	}
 
 	if (repair) {


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2010-01-07 20:42 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2010-01-07 20:42 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-01-07 20:42:56

Modified files:
	tools          : lvconvert.c 

Log message:
	The patch fixes some lvconvert issues (WRT mirror <-> mirror).
	
	The default log option for a mirror is 'disk'.  If the log
	type is not explicitly stated on the command line when
	converting from an X-way mirror to a Y-way mirror, 'disk'
	is chosen.  So, if you have a 'core' log mirror and you
	convert, your result will contain a 'disk' log.
	
	This patch remembers what the old log type was.  If the
	user is merely trying to switch the number of mirror
	images, the log type is now kept the same.
	
	There is one historical behaviour I left in place...
	If you have a 2-way, core-log mirror and you use lvconvert to
	specify you want a 2-way mirror - without specifying the
	log type - you will get a 2-way, disk-log mirror.
	
	Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
	Informal-IRC-ACK-by: agk

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.101&r2=1.102

--- LVM2/tools/lvconvert.c	2010/01/06 13:27:07	1.101
+++ LVM2/tools/lvconvert.c	2010/01/07 20:42:55	1.102
@@ -628,6 +628,17 @@
 		return 0;
 	}
 
+	/*
+	 * If we are converting from one type of mirror to another, and
+	 * the type of log wasn't specified, then let's keep the log type
+	 * the same.
+	 */
+	if (existing_mirrors && lp->mirrors &&
+	    (lp->mirrors != existing_mirrors) &&
+	    !arg_count(cmd, mirrorlog_ARG) && !arg_count(cmd, corelog_ARG)) {
+		corelog = first_seg(lv)->log_lv ? 0 : 1;
+	}
+
 	if (repair) {
 		cmd->handles_missing_pvs = 1;
 		cmd->partial_activation = 1;


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2009-10-21 22:19 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2009-10-21 22:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2009-10-21 22:19:39

Modified files:
	tools          : lvconvert.c 

Log message:
	Clarify message:
	"  Mirror status: 1/2 images failed."
	
	Half of an image?  Half of the images?  No, 1 of 2 images.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.93&r2=1.94

--- LVM2/tools/lvconvert.c	2009/09/30 18:15:06	1.93
+++ LVM2/tools/lvconvert.c	2009/10/21 22:19:39	1.94
@@ -584,7 +584,7 @@
 		if ((failed_mirrors = _failed_mirrors_count(lv)) < 0)
 			return_0;
 		lp->mirrors -= failed_mirrors;
-		log_error("Mirror status: %d/%d images failed.",
+		log_error("Mirror status: %d of %d images failed.",
 			  failed_mirrors, existing_mirrors);
 		old_pvh = lp->pvh;
 		if (!(lp->pvh = _failed_pv_list(lv->vg)))


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2009-08-02 21:56 mornfall
  0 siblings, 0 replies; 38+ messages in thread
From: mornfall @ 2009-08-02 21:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2009-08-02 21:56:29

Modified files:
	tools          : lvconvert.c 

Log message:
	Slightly refactor mirror log conversions in lvconvert.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90

--- LVM2/tools/lvconvert.c	2009/07/15 05:47:55	1.89
+++ LVM2/tools/lvconvert.c	2009/08/02 21:56:29	1.90
@@ -496,6 +496,33 @@
 	}
 }
 
+static int _using_corelog(struct logical_volume *lv)
+{
+	return !first_seg(_original_lv(lv))->log_lv;
+}
+
+static int _lv_update_log_type(struct cmd_context *cmd,
+			       struct lvconvert_params *lp,
+			       struct logical_volume *lv,
+			       int corelog)
+{
+	struct logical_volume *original_lv = _original_lv(lv);
+	if (_using_corelog(lv) && !corelog) {
+		if (!add_mirror_log(cmd, original_lv, 1,
+				    adjusted_mirror_region_size(
+					lv->vg->extent_size,
+					lv->le_count,
+					lp->region_size),
+				    lp->pvh, lp->alloc))
+			return_0;
+	} else if (!_using_corelog(lv) && corelog) {
+		if (!remove_mirror_log(cmd, original_lv,
+				       lp->pv_count ? lp->pvh : NULL))
+			return_0;
+	}
+	return 1;
+}
+
 static int _lvconvert_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
 			      struct lvconvert_params *lp)
 {
@@ -503,7 +530,6 @@
 	uint32_t existing_mirrors;
 	const char *mirrorlog;
 	unsigned corelog = 0;
-	struct logical_volume *original_lv;
 	int r = 0;
 	struct logical_volume *log_lv;
 	int failed_mirrors = 0, failed_log = 0;
@@ -688,20 +714,8 @@
 		 * insertion to make the end result consistent with
 		 * linear-to-mirror conversion.
 		 */
-		original_lv = _original_lv(lv);
-		if (!first_seg(original_lv)->log_lv && !corelog) {
-			if (!add_mirror_log(cmd, original_lv, 1,
-					    adjusted_mirror_region_size(
-							lv->vg->extent_size,
-							lv->le_count,
-							lp->region_size),
-					    lp->pvh, lp->alloc))
-				return_0;
-		} else if (first_seg(original_lv)->log_lv && corelog) {
-			if (!remove_mirror_log(cmd, original_lv,
-					       lp->pv_count ? lp->pvh : NULL))
-				return_0;
-		}
+		if (!_lv_update_log_type(cmd, lp, lv, corelog))
+			return_0;
 		/* Insert a temporary layer for syncing,
 		 * only if the original lv is using disk log. */
 		if (seg->log_lv && !_insert_lvconvert_layer(cmd, lv)) {
@@ -722,24 +736,10 @@
 	}
 
 	if (lp->mirrors == existing_mirrors) {
-		/*
-		 * Convert Mirror log type
-		 */
-		original_lv = _original_lv(lv);
-		if (!first_seg(original_lv)->log_lv && !corelog) {
-			if (!add_mirror_log(cmd, original_lv, 1,
-					    adjusted_mirror_region_size(
-							lv->vg->extent_size,
-							lv->le_count,
-							lp->region_size),
-					    lp->pvh, lp->alloc))
-				return_0;
-		} else if (first_seg(original_lv)->log_lv && corelog) {
-			if (!remove_mirror_log(cmd, original_lv,
-					       lp->pv_count ? lp->pvh : NULL))
+		if (_using_corelog(lv) != corelog) {
+			if (!_lv_update_log_type(cmd, lp, lv, corelog))
 				return_0;
 		} else {
-			/* No change */
 			log_error("Logical volume %s already has %"
 				  PRIu32 " mirror(s).", lv->name,
 				  lp->mirrors - 1);


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2009-06-26 11:29 wysochanski
  0 siblings, 0 replies; 38+ messages in thread
From: wysochanski @ 2009-06-26 11:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-06-26 11:29:06

Modified files:
	tools          : lvconvert.c 

Log message:
	Fix incomplete revert for lvconvert.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.85&r2=1.86

--- LVM2/tools/lvconvert.c	2009/06/26 10:55:58	1.85
+++ LVM2/tools/lvconvert.c	2009/06/26 11:29:06	1.86
@@ -242,8 +242,10 @@
 	/*
 	 * uuid is here LV uuid, but vg_read will use only first part.
 	 */
-	return vg_read_for_update(cmd, extract_vgname(cmd, lv_name),
-				  NULL, 0);
+        return vg_lock_and_read(cmd, extract_vgname(cmd, lv_name),
+                               uuid, LCK_VG_WRITE,
+                               CLUSTERED | EXPORTED_VG | LVM_WRITE,
+                               CORRECT_INCONSISTENT | FAIL_INCONSISTENT);
 }
 
 static struct logical_volume *_get_lvconvert_lv(struct cmd_context *cmd __attribute((unused)),


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2009-06-10 15:27 mornfall
  0 siblings, 0 replies; 38+ messages in thread
From: mornfall @ 2009-06-10 15:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2009-06-10 15:27:57

Modified files:
	tools          : lvconvert.c 

Log message:
	Complain when lvconvert --repair is used on non-mirror LV.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79

--- LVM2/tools/lvconvert.c	2009/06/04 12:01:16	1.78
+++ LVM2/tools/lvconvert.c	2009/06/10 15:27:57	1.79
@@ -894,6 +894,11 @@
 		return ECMD_FAILED;
 	}
 
+	if (arg_count(cmd, repair_ARG) && !(lv->status & MIRRORED)) {
+		log_error("Can't repair non-mirrored LV \"%s\".", lv->name);
+		return ECMD_FAILED;
+	}
+
 	if (lp->snapshot) {
 		if (lv->status & MIRRORED) {
 			log_error("Unable to convert mirrored LV \"%s\" into a snapshot.", lv->name);


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2009-05-19 10:27 mbroz
  0 siblings, 0 replies; 38+ messages in thread
From: mbroz @ 2009-05-19 10:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-05-19 10:27:47

Modified files:
	tools          : lvconvert.c 

Log message:
	Fix lvconvert check for multiple-segment mirrors (mornfall)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75

--- LVM2/tools/lvconvert.c	2009/05/19 10:12:41	1.74
+++ LVM2/tools/lvconvert.c	2009/05/19 10:27:47	1.75
@@ -542,11 +542,10 @@
 	}
 
 	/*
-	 * FIXME This check used to precede mirror->mirror conversion
-	 * but didn't affect mirror->linear or linear->mirror. I do
-	 * not understand what is its intention, in fact.
+	 * For the most part, we cannot handle multi-segment mirrors. Bail out
+	 * early if we have encountered one.
 	 */
-	if (dm_list_size(&lv->segments) != 1) {
+	if ((lv->status & MIRRORED) && dm_list_size(&lv->segments) != 1) {
 		log_error("Logical volume %s has multiple "
 			  "mirror segments.", lv->name);
 		return 0;


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2009-05-19 10:12 mbroz
  0 siblings, 0 replies; 38+ messages in thread
From: mbroz @ 2009-05-19 10:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-05-19 10:12:41

Modified files:
	tools          : lvconvert.c 

Log message:
	Fix compilation warning.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74

--- LVM2/tools/lvconvert.c	2009/05/13 21:21:59	1.73
+++ LVM2/tools/lvconvert.c	2009/05/19 10:12:41	1.74
@@ -442,7 +442,7 @@
 	int r = 0;
 	struct logical_volume *log_lv;
 	int failed_mirrors = 0, failed_log = 0;
-	struct dm_list *old_pvh, *remove_pvs = NULL;
+	struct dm_list *old_pvh = NULL, *remove_pvs = NULL;
 
 	seg = first_seg(lv);
 	existing_mirrors = lv_mirror_count(lv);


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2008-01-16 22:54 agk
  0 siblings, 0 replies; 38+ messages in thread
From: agk @ 2008-01-16 22:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-01-16 22:54:50

Modified files:
	tools          : lvconvert.c 

Log message:
	another lvconvert fix

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57

--- LVM2/tools/lvconvert.c	2008/01/16 19:40:42	1.56
+++ LVM2/tools/lvconvert.c	2008/01/16 22:54:49	1.57
@@ -509,7 +509,7 @@
 
 	if (lp->mirrors == existing_mirrors) {
 		original_lv = _original_lv(lv);
-		if (!seg->log_lv && !corelog) {
+		if (!first_seg(original_lv)->log_lv && !corelog) {
 			if (!add_mirror_log(cmd, original_lv, 1,
 					    adjusted_mirror_region_size(
 							lv->vg->extent_size,
@@ -517,7 +517,7 @@
 							lp->region_size),
 					    lp->pvh, lp->alloc))
 				return_0;
-		} else if (seg->log_lv && corelog) {
+		} else if (first_seg(original_lv)->log_lv && corelog) {
 			if (!remove_mirror_log(cmd, original_lv,
 					       lp->pv_count ? lp->pvh : NULL))
 				return_0;


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2008-01-16 19:40 agk
  0 siblings, 0 replies; 38+ messages in thread
From: agk @ 2008-01-16 19:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-01-16 19:40:43

Modified files:
	tools          : lvconvert.c 

Log message:
	fix to earlier checkin

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56

--- LVM2/tools/lvconvert.c	2008/01/16 19:16:48	1.55
+++ LVM2/tools/lvconvert.c	2008/01/16 19:40:42	1.56
@@ -540,7 +540,7 @@
 		 * linear-to-mirror conversion.
 		 */
 		original_lv = _original_lv(lv);
-		if (!seg->log_lv && !corelog) {
+		if (!first_seg(original_lv)->log_lv && !corelog) {
 			if (!add_mirror_log(cmd, original_lv, 1,
 					    adjusted_mirror_region_size(
 							lv->vg->extent_size,
@@ -548,7 +548,7 @@
 							lp->region_size),
 					    lp->pvh, lp->alloc))
 				return_0;
-		} else if (seg->log_lv && corelog) {
+		} else if (first_seg(original_lv)->log_lv && corelog) {
 			if (!remove_mirror_log(cmd, original_lv,
 					       lp->pv_count ? lp->pvh : NULL))
 				return_0;


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2008-01-16 19:16 agk
  0 siblings, 0 replies; 38+ messages in thread
From: agk @ 2008-01-16 19:16 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-01-16 19:16:48

Modified files:
	tools          : lvconvert.c 

Log message:
	fix mirror log manipulation during lv convert

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55

--- LVM2/tools/lvconvert.c	2008/01/14 21:11:47	1.54
+++ LVM2/tools/lvconvert.c	2008/01/16 19:16:48	1.55
@@ -364,6 +364,17 @@
 	return 1;
 }
 
+/* walk down the stacked mirror LV to the original mirror LV */
+static struct logical_volume *_original_lv(struct logical_volume *lv)
+{
+	struct logical_volume *next_lv = lv, *tmp_lv;
+
+	while ((tmp_lv = find_temporary_mirror(next_lv)))
+		next_lv = tmp_lv;
+
+	return next_lv;
+}
+
 static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * lv,
 			     struct lvconvert_params *lp)
 {
@@ -371,6 +382,7 @@
 	uint32_t existing_mirrors;
 	const char *mirrorlog;
 	unsigned corelog = 0;
+	struct logical_volume *original_lv;
 
 	seg = first_seg(lv);
 	existing_mirrors = lv_mirror_count(lv);
@@ -496,8 +508,9 @@
 	}
 
 	if (lp->mirrors == existing_mirrors) {
+		original_lv = _original_lv(lv);
 		if (!seg->log_lv && !corelog) {
-			if (!add_mirror_log(cmd, lv, 1,
+			if (!add_mirror_log(cmd, original_lv, 1,
 					    adjusted_mirror_region_size(
 							lv->vg->extent_size,
 							lv->le_count,
@@ -505,7 +518,7 @@
 					    lp->pvh, lp->alloc))
 				return_0;
 		} else if (seg->log_lv && corelog) {
-			if (!remove_mirror_log(cmd, lv,
+			if (!remove_mirror_log(cmd, original_lv,
 					       lp->pv_count ? lp->pvh : NULL))
 				return_0;
 		} else {
@@ -526,8 +539,9 @@
 		 * insertion to make the end result consistent with
 		 * linear-to-mirror conversion.
 		 */
+		original_lv = _original_lv(lv);
 		if (!seg->log_lv && !corelog) {
-			if (!add_mirror_log(cmd, lv, 1,
+			if (!add_mirror_log(cmd, original_lv, 1,
 					    adjusted_mirror_region_size(
 							lv->vg->extent_size,
 							lv->le_count,
@@ -535,7 +549,7 @@
 					    lp->pvh, lp->alloc))
 				return_0;
 		} else if (seg->log_lv && corelog) {
-			if (!remove_mirror_log(cmd, lv,
+			if (!remove_mirror_log(cmd, original_lv,
 					       lp->pv_count ? lp->pvh : NULL))
 				return_0;
 		}


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2007-12-21  1:08 agk
  0 siblings, 0 replies; 38+ messages in thread
From: agk @ 2007-12-21  1:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-12-21 01:08:18

Modified files:
	tools          : lvconvert.c 

Log message:
	auto-collapse layers

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50

--- LVM2/tools/lvconvert.c	2007/12/20 18:55:46	1.49
+++ LVM2/tools/lvconvert.c	2007/12/21 01:08:18	1.50
@@ -236,7 +236,14 @@
 	unsigned corelog = 0;
 
 	seg = first_seg(lv);
-	existing_mirrors = (lv->status & MIRRORED) ? seg->area_count : 1;
+	existing_mirrors = lv_mirror_count(lv);
+
+	/* If called with no argument, try collapsing the resync layers */
+	if (!arg_count(cmd, mirrors_ARG) && !arg_count(cmd, mirrorlog_ARG)) {
+		if (!collapse_mirrored_lv(lv))
+			return_0;
+		goto commit_changes;
+	}
 
 	/*
 	 * Adjust required number of mirrors
@@ -516,8 +523,7 @@
 		return ECMD_FAILED;
 	}
 
-	if (arg_count(cmd, mirrors_ARG) ||
-	    ((lv->status & MIRRORED) && arg_count(cmd, mirrorlog_ARG))) {
+	if (arg_count(cmd, mirrors_ARG) || (lv->status & MIRRORED)) {
 		if (!archive(lv->vg))
 			return ECMD_FAILED;
 		if (!lvconvert_mirrors(cmd, lv, lp))


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2007-08-01 20:54 jbrassow
  0 siblings, 0 replies; 38+ messages in thread
From: jbrassow @ 2007-08-01 20:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2007-08-01 20:54:29

Modified files:
	tools          : lvconvert.c 

Log message:
	- cleanup excessive indentation in tools/lvconvert.c:lvconvert_mirrors

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30

--- LVM2/tools/lvconvert.c	2007/07/23 22:20:41	1.29
+++ LVM2/tools/lvconvert.c	2007/08/01 20:54:28	1.30
@@ -241,19 +241,32 @@
 	seg = first_seg(lv);
 	existing_mirrors = seg->area_count;
 
-	/* Adjust required number of mirrors */
-	if (lp->mirrors_sign == SIGN_PLUS)
+	/*
+	 * Adjust required number of mirrors
+	 *
+	 * We check mirrors_ARG again to see if it
+	 * was supplied.  If not, they want the mirror
+	 * count to remain the same.  They may be changing
+	 * the logging type.
+	 */
+	if (!arg_count(cmd, mirrors_ARG))
+		lp->mirrors = existing_mirrors;
+	else if (lp->mirrors_sign == SIGN_PLUS)
 		lp->mirrors = existing_mirrors + lp->mirrors;
-	else if (lp->mirrors_sign == SIGN_MINUS) {
-		if (lp->mirrors >= existing_mirrors) {
-			log_error("Logical volume %s only has %" PRIu32 " mirrors.",
-				  lv->name, existing_mirrors);
-			return 0;
-		}
+	else if (lp->mirrors_sign == SIGN_MINUS)
 		lp->mirrors = existing_mirrors - lp->mirrors;
-	} else
+	else
 		lp->mirrors += 1;
 
+	/*
+	 * Did the user try to subtract more legs than available?
+	 */
+	if (lp->mirrors < 1) {
+		log_error("Logical volume %s only has %" PRIu32 " mirrors.",
+			  lv->name, existing_mirrors);
+		return 0;
+	}
+
 	if (arg_count(cmd, regionsize_ARG) && (lv->status & MIRRORED) &&
 	    (lp->region_size != seg->region_size)) {
 		log_error("Mirror log region size cannot be changed on "
@@ -261,6 +274,9 @@
 		return 0;
 	}
 
+	/*
+	 * Converting from mirror to linear
+	 */
 	if ((lp->mirrors == 1)) {
 		if (!(lv->status & MIRRORED)) {
 			log_error("Logical volume %s is already not mirrored.",
@@ -271,133 +287,143 @@
 		if (!remove_mirror_images(seg, 1,
 					  lp->pv_count ? lp->pvh : NULL, 1))
 			return_0;
-	} else {		/* mirrors > 1 */
-		if ((lv->status & MIRRORED)) {
-			if (list_size(&lv->segments) != 1) {
-				log_error("Logical volume %s has multiple "
-					  "mirror segments.", lv->name);
-				return 0;
-			}
-			if (lp->mirrors == existing_mirrors) {
-				if (!seg->log_lv && !arg_count(cmd, corelog_ARG)) {
-					/* No disk log present, add one. */
-					if (!(parallel_areas = build_parallel_areas_from_lv(cmd, lv)))
-						return_0;
-					if (!lv_mirror_percent(cmd, lv, 0, &sync_percent, NULL)) {
-						log_error("Unable to determine mirror sync status.");
-						return 0;
-					}
-
-					segtype = get_segtype_from_string(cmd, "striped");
-
-					if (!(ah = allocate_extents(lv->vg, NULL, segtype, 0,
-								    0, 1, 0,
-								    NULL, 0, 0, lp->pvh,
-								    lp->alloc,
-								    parallel_areas))) {
-						stack;
-						return 0;
-					}
-
-					if (sync_percent >= 100.0)
-						init_mirror_in_sync(1);
-					else
-						init_mirror_in_sync(0);
-
-					if (!(log_lv = create_mirror_log(cmd, lv->vg, ah,
-									 lp->alloc, lv->name,
-									 (sync_percent >= 100.0) ?
-									 1 : 0, &lv->tags))) {
-						log_error("Failed to create mirror log.");
-						return 0;
-					}
-					seg->log_lv = log_lv;
-					log_lv->status |= MIRROR_LOG;
-					first_seg(log_lv)->mirror_seg = seg;
-				} else if (seg->log_lv && arg_count(cmd, corelog_ARG)) {
-					/* Had disk log, switch to core. */
-					if (!lv_mirror_percent(cmd, lv, 0, &sync_percent, NULL)) {
-						log_error("Unable to determine mirror sync status.");
-						return 0;
-					}
-
-					if (sync_percent >= 100.0)
-						init_mirror_in_sync(1);
-					else
-						init_mirror_in_sync(0);
-
-					if (!remove_mirror_images(seg, lp->mirrors,
-								  lp->pv_count ?
-								  lp->pvh : NULL, 1))
-						return_0;
-				} else {
-					/* No change */
-					log_error("Logical volume %s already has %"
-						  PRIu32 " mirror(s).", lv->name,
-						  lp->mirrors - 1);
-					return 1;
-				}
-			} else if (lp->mirrors > existing_mirrors) {
-				/* FIXME Unless anywhere, remove PV of log_lv 
-				 * from allocatable_pvs & allocate 
-				 * (mirrors - existing_mirrors) new areas
-				 */
-				/* FIXME Create mirror hierarchy to sync */
-				log_error("Adding mirror images is not "
-					  "supported yet.");
+		goto commit_changes;
+	}
+
+	/*
+	 * Converting from linear to mirror
+	 */
+	if (!(lv->status & MIRRORED)) {
+		/* FIXME Share code with lvcreate */
+
+		/* FIXME Why is this restriction here?  Fix it! */
+		list_iterate_items(seg, &lv->segments) {
+			if (seg_is_striped(seg) && seg->area_count > 1) {
+				log_error("Mirrors of striped volumes are not yet supported.");
 				return 0;
-			} else {
-				/* Reduce number of mirrors */
-				if (!remove_mirror_images(seg, lp->mirrors,
-							  lp->pv_count ?
-							  lp->pvh : NULL, 0))
-					return_0;
 			}
-		} else {
-			/* Make existing LV into mirror set */
-			/* FIXME Share code with lvcreate */
+		}
 
-			/* FIXME Why is this restriction here?  Fix it! */
-			list_iterate_items(seg, &lv->segments) {
-				if (seg_is_striped(seg) && seg->area_count > 1) {
-					log_error("Mirrors of striped volumes are not yet supported.");
-					return 0;
-				}
-			}
+		if (!(parallel_areas = build_parallel_areas_from_lv(cmd, lv)))
+			return_0;
+
+		if (!(ah = allocate_extents(lv->vg, NULL, lp->segtype,
+					    1, lp->mirrors - 1,
+					    arg_count(cmd, corelog_ARG) ? 0 : 1,
+					    lv->le_count * (lp->mirrors - 1),
+					    NULL, 0, 0, lp->pvh,
+					    lp->alloc,
+					    parallel_areas)))
+			return_0;
 
+		lp->region_size = adjusted_mirror_region_size(lv->vg->extent_size,
+							      lv->le_count,
+							      lp->region_size);
+
+		log_lv = NULL;
+		if (!arg_count(cmd, corelog_ARG) &&
+		    !(log_lv = create_mirror_log(cmd, lv->vg, ah,
+						 lp->alloc,
+						 lv->name, 0, &lv->tags))) {
+			log_error("Failed to create mirror log.");
+			return 0;
+		}
+
+		if (!create_mirror_layers(ah, 1, lp->mirrors, lv,
+					  lp->segtype, 0,
+					  lp->region_size,
+					  log_lv))
+			return_0;
+		goto commit_changes;
+	}
+
+	/*
+	 * Converting from mirror to mirror with different leg count,
+	 * or different log type.
+	 */
+	if (list_size(&lv->segments) != 1) {
+		log_error("Logical volume %s has multiple "
+			  "mirror segments.", lv->name);
+		return 0;
+	}
+
+	if (lp->mirrors == existing_mirrors) {
+		if (!seg->log_lv && !arg_count(cmd, corelog_ARG)) {
+			/* No disk log present, add one. */
 			if (!(parallel_areas = build_parallel_areas_from_lv(cmd, lv)))
 				return_0;
+			if (!lv_mirror_percent(cmd, lv, 0, &sync_percent, NULL)) {
+				log_error("Unable to determine mirror sync status.");
+				return 0;
+			}
+
+			segtype = get_segtype_from_string(cmd, "striped");
 
-			if (!(ah = allocate_extents(lv->vg, NULL, lp->segtype,
-						    1, lp->mirrors - 1,
-						    arg_count(cmd, corelog_ARG) ? 0 : 1,
-						    lv->le_count * (lp->mirrors - 1),
+			if (!(ah = allocate_extents(lv->vg, NULL, segtype, 0,
+						    0, 1, 0,
 						    NULL, 0, 0, lp->pvh,
 						    lp->alloc,
-						    parallel_areas)))
-				return_0;
+						    parallel_areas))) {
+				stack;
+				return 0;
+			}
 
-			lp->region_size = adjusted_mirror_region_size(lv->vg->extent_size,
-								      lv->le_count,
-								      lp->region_size);
-
-			log_lv = NULL;
-			if (!arg_count(cmd, corelog_ARG) &&
-			    !(log_lv = create_mirror_log(cmd, lv->vg, ah,
-							 lp->alloc,
-							 lv->name, 0, &lv->tags))) {
+			if (sync_percent >= 100.0)
+				init_mirror_in_sync(1);
+			else
+				init_mirror_in_sync(0);
+
+			if (!(log_lv = create_mirror_log(cmd, lv->vg, ah,
+							 lp->alloc, lv->name,
+							 (sync_percent >= 100.0) ?
+							 1 : 0, &lv->tags))) {
 				log_error("Failed to create mirror log.");
 				return 0;
 			}
+			seg->log_lv = log_lv;
+			log_lv->status |= MIRROR_LOG;
+			first_seg(log_lv)->mirror_seg = seg;
+		} else if (seg->log_lv && arg_count(cmd, corelog_ARG)) {
+			/* Had disk log, switch to core. */
+			if (!lv_mirror_percent(cmd, lv, 0, &sync_percent, NULL)) {
+				log_error("Unable to determine mirror sync status.");
+				return 0;
+			}
 
-			if (!create_mirror_layers(ah, 1, lp->mirrors, lv,
-						  lp->segtype, 0,
-						  lp->region_size,
-						  log_lv))
+			if (sync_percent >= 100.0)
+				init_mirror_in_sync(1);
+			else
+				init_mirror_in_sync(0);
+
+			if (!remove_mirror_images(seg, lp->mirrors,
+						  lp->pv_count ?
+						  lp->pvh : NULL, 1))
 				return_0;
+		} else {
+			/* No change */
+			log_error("Logical volume %s already has %"
+				  PRIu32 " mirror(s).", lv->name,
+				  lp->mirrors - 1);
+			return 1;
 		}
+	} else if (lp->mirrors > existing_mirrors) {
+		/* FIXME Unless anywhere, remove PV of log_lv
+		 * from allocatable_pvs & allocate
+		 * (mirrors - existing_mirrors) new areas
+		 */
+		/* FIXME Create mirror hierarchy to sync */
+		log_error("Adding mirror images is not "
+			  "supported yet.");
+		return 0;
+	} else {
+		/* Reduce number of mirrors */
+		if (!remove_mirror_images(seg, lp->mirrors,
+					  lp->pv_count ?
+					  lp->pvh : NULL, 0))
+			return_0;
 	}
 
+commit_changes:
 	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
 
 	if (!vg_write(lv->vg))
@@ -449,9 +475,9 @@
 	if (!lp->zero || !(lv->status & LVM_WRITE))
 		log_warn("WARNING: \"%s\" not zeroed", lv->name);
 	else if (!set_lv(cmd, lv, 0, 0)) {
-			log_error("Aborting. Failed to wipe snapshot "
-				  "exception store.");
-			return 0;
+		log_error("Aborting. Failed to wipe snapshot "
+			  "exception store.");
+		return 0;
 	}
 
 	if (!deactivate_lv(cmd, lv)) {


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2006-05-11 18:56 agk
  0 siblings, 0 replies; 38+ messages in thread
From: agk @ 2006-05-11 18:56 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-05-11 18:56:55

Modified files:
	tools          : lvconvert.c 

Log message:
	Check in-sync status before changing disk log.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16


^ permalink raw reply	[flat|nested] 38+ messages in thread

* LVM2/tools lvconvert.c
@ 2006-04-07 14:14 agk
  0 siblings, 0 replies; 38+ messages in thread
From: agk @ 2006-04-07 14:14 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-04-07 14:14:31

Modified files:
	tools          : lvconvert.c 

Log message:
	missing vg_name initialisation

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7


^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2012-04-19 21:50 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-13  1:47 LVM2/tools lvconvert.c snitzer
  -- strict thread matches above, loose matches on Subject: below --
2012-04-19 21:50 jbrassow
2012-02-23 22:36 zkabelac
2012-02-22 16:03 jbrassow
2012-02-22 15:20 jbrassow
2012-02-13 18:38 jbrassow
2012-02-13 18:36 jbrassow
2012-01-25 22:38 zkabelac
2011-12-08 18:00 agk
2011-06-29  2:06 jbrassow
2011-06-28 21:28 jbrassow
2011-01-19 19:24 jbrassow
2010-11-28 18:37 snitzer
2010-07-13 22:04 jbrassow
2010-07-13 21:53 jbrassow
2010-07-01 10:10 mornfall
2010-06-23 20:32 jbrassow
2010-04-28 17:41 jbrassow
2010-04-26 18:12 agk
2010-04-20 12:18 agk
2010-03-31 20:39 agk
2010-02-05 22:47 snitzer
2010-01-13  1:49 snitzer
2010-01-11 17:13 jbrassow
2010-01-07 20:42 jbrassow
2009-10-21 22:19 jbrassow
2009-08-02 21:56 mornfall
2009-06-26 11:29 wysochanski
2009-06-10 15:27 mornfall
2009-05-19 10:27 mbroz
2009-05-19 10:12 mbroz
2008-01-16 22:54 agk
2008-01-16 19:40 agk
2008-01-16 19:16 agk
2007-12-21  1:08 agk
2007-08-01 20:54 jbrassow
2006-05-11 18:56 agk
2006-04-07 14:14 agk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).