public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2011-10-25 13:17 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2011-10-25 13:17 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-10-25 13:17:05

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Disallow 'mirrored' log for cluster mirrors.
	
	Git commit ID 0864378250956c310cb81608978d091fcdcc97d8 was meant to disallow
	'mirrored' logs for cluster mirrors.  However, when add_mirror_log is used
	to create the log (as is now the case when using 'lvcreate' or converting only
	the log) the check is bypassed.
	
	This patch adds the check to add_mirror_log.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2171&r2=1.2172
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.173&r2=1.174

--- LVM2/WHATS_NEW	2011/10/24 10:24:39	1.2171
+++ LVM2/WHATS_NEW	2011/10/25 13:17:04	1.2172
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Fix regression that allowed mirrored logs for cluster mirrors.
   Don't print char type[8] as a plain string in pvck PV type.
   Use vg memory pool implicitely for vg read.
   Always use vg memory pool for allocated lv segment.
--- LVM2/lib/metadata/mirror.c	2011/10/06 14:55:40	1.173
+++ LVM2/lib/metadata/mirror.c	2011/10/25 13:17:04	1.174
@@ -1898,6 +1898,11 @@
 	unsigned old_log_count;
 	int r = 0;
 
+	if (vg_is_clustered(lv->vg) && (log_count > 1)) {
+		log_error("Log type, \"mirrored\", is unavailable to cluster mirrors");
+		return 0;
+	}
+
 	if (dm_list_size(&lv->segments) != 1) {
 		log_error("Multiple-segment mirror is not supported");
 		return 0;


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2012-03-23 16:28 mbroz
  0 siblings, 0 replies; 29+ messages in thread
From: mbroz @ 2012-03-23 16:28 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2012-03-23 16:28:41

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix pvmove if LV is activated exclusively but cmirror is not running.
	
	In this case we should allow to use local mirror, check for cmirror
	should apply only for lvconvert/lvcreate.
	
	Introduced in 2.02.86 by removing !(lv->status & ACTIVATE_EXCL).
	
	(Partially workaround, it is minimalistic patch for now.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2366&r2=1.2367
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.179&r2=1.180

--- LVM2/WHATS_NEW	2012/03/23 10:33:26	1.2366
+++ LVM2/WHATS_NEW	2012/03/23 16:28:40	1.2367
@@ -1,5 +1,6 @@
 Version 2.02.96 - 
 ================================
+  Fix pvmove for exclusively activated LV pvmove in clustered VG. (2.02.86)
   Always free hash table on update_pvid_to_vgid() in lvmetad.
   Update and fix monitoring of thin pool devices.
   Check hash insert success in lock_vg clvmd.
--- LVM2/lib/metadata/mirror.c	2012/02/23 22:24:47	1.179
+++ LVM2/lib/metadata/mirror.c	2012/03/23 16:28:40	1.180
@@ -2070,7 +2070,10 @@
 
 	if (vg_is_clustered(lv->vg)) {
 		/* FIXME: review check of lv_is_active_remotely */
-		if (!_cluster_mirror_is_available(lv)) {
+		/* FIXME: move this test out of this function */
+		/* Skip test for pvmove mirrors, it can use local mirror */
+		if (!(lv->status & (PVMOVE | LOCKED)) &&
+		    !_cluster_mirror_is_available(lv)) {
 			log_error("Shared cluster mirrors are not available.");
 			return 0;
 		}


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2012-02-01 13:50 zkabelac
  0 siblings, 0 replies; 29+ messages in thread
From: zkabelac @ 2012-02-01 13:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-01 13:50:37

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Add synchornization point in mirror log init.
	
	Put extra sync point when mirror log is deactivated and before
	it's activated for the second time.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2253&r2=1.2254
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.174&r2=1.175

--- LVM2/WHATS_NEW	2012/02/01 13:47:27	1.2253
+++ LVM2/WHATS_NEW	2012/02/01 13:50:36	1.2254
@@ -1,5 +1,6 @@
 Version 2.02.90 - 
 ===================================
+  Add synchronization point in mirror log initialization.
   Disable partial activation for thin LVs and LVs with all missing segments.
   Do not print warning for pv_min_size set in range between 512KB and 2MB.
   Clean up systemd unit ordering and requirements.
--- LVM2/lib/metadata/mirror.c	2011/10/25 13:17:04	1.174
+++ LVM2/lib/metadata/mirror.c	2012/02/01 13:50:37	1.175
@@ -325,6 +325,8 @@
 
 	backup(log_lv->vg);
 
+	// FIXME: Wait here explicitly, so deactivation of log_lv is finished
+	sync_local_dev_names(cmd);
 	if (!activate_lv(cmd, log_lv)) {
 		log_error("Aborting. Failed to activate mirror log.");
 		goto revert_new_lv;
@@ -437,7 +439,8 @@
 	if (!_activate_lv_like_model(lv, lv))
 		return_0;
 
-	sync_local_dev_names(lv->vg->cmd);
+	// FIXME: Wait here should not be need
+	sync_local_dev_names(cmd);
 	if (!deactivate_lv(cmd, lv))
 		return_0;
 


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2011-10-06 14:49 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2011-10-06 14:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-10-06 14:49:19

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Revert initial solution to bug 733114 - I/O error message during splitmirror
	
	The original commit comments can be located via this git commit ID:
	7d8e615c0b30fc2ef300c90378a51f01c328128c
	
	There were three possible solutions to the original problem proposed in the
	initial check-in.  The one chosen was as follows:
	2) Do like _remove_mirror_images does and suspend the original, then suspend
	the sub-lv (the error target), then resume the sub-lv, and finally resume the
	original LV.  This seems like extra pointless operations to me, but it doesn't
	produce the error message (although, I'm not sure why) and it allows us to
	leave the visible flag in place.
	Turns out, the cluster also views the extra suspend/resume operations as
	pointless too and ignores them.  So, this solution doesn't work in a cluster.
	Further, I've noticed that in addition to the remote cluster nodes still getting
	I/O errors from scanning the error target, they also have a different LVM and
	DM views of the same LV.  IOW, while the LVM level (gotten from the LVM metadata)
	sees the correct name for the newly split LV, device-mapper still maintains the
	old names.
	
	Because the original fix failed to completely fix the problem (or work-around it)
	and because a better solution must be found to address the additional cluster
	issue of device renaming, I am reverting the above mentioned commit.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2147&r2=1.2148
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.171&r2=1.172

--- LVM2/WHATS_NEW	2011/10/06 14:45:40	1.2147
+++ LVM2/WHATS_NEW	2011/10/06 14:49:16	1.2148
@@ -42,7 +42,6 @@
   Fix failure to down-convert a mirror to linear due to udev "dev open" conflict
   Fix mirrored log creation when PE size is small - force log_size >= region_size
   Fix log size calculation when only a log is being added to a mirror.
-  Work around resume_lv causing error LV scanning during splitmirror operation.
   Add 7th lv_attr char to show the related kernel target.
   Terminate pv_attr field correctly. (2.02.86)
   Fix 'not not' typo in pvcreate man page.
--- LVM2/lib/metadata/mirror.c	2011/09/19 14:28:23	1.171
+++ LVM2/lib/metadata/mirror.c	2011/10/06 14:49:16	1.172
@@ -673,10 +673,6 @@
 		return 0;
 	}
 
-	/* Suspend temporary error target (see FIXME for resume below) */
-	if (sub_lv && !suspend_lv(sub_lv->vg->cmd, sub_lv))
-		return_0;
-
 	if (!vg_commit(mirrored_seg->lv->vg)) {
 		resume_lv(cmd, mirrored_seg->lv);
 		return 0;
@@ -685,42 +681,6 @@
 	log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name);
 
 	/*
-	 * FIXME:
-When an image is split from a 2-way mirror, the original mirror is converted to
-a linear device.  To do this, the top "layer" must be removed.  The segments
-are transferred from the sub-lv to the top-level LV and the link is severed. 
-The former sub-lv - having its segments transferred - now contains a temporary
-error target.
-
-When the original LV is resumed, the old sub-lv that now contains an error
-segment is activated and scanned.  This causes I/O error messages.  There are
-three ways to fix this problem:
-
-1) Do not set the sub-lv which contains the error target as "visible" before
-suspending the original LV.  This way, when the original is resumed, the sub-lv
-device node is not created and it is not scanned - avoiding the error messages.
- The problem with this approach is that if the machine crashes after the
-resume, it leaves the *hidden* LV in place and the user has a more difficult
-time noticing that it needs to be cleaned up.  Thus, this type of processing is
-frowned upon.
-
-2) Do like _remove_mirror_images does and suspend the original, then suspend
-the sub-lv (the error target), then resume the sub-lv, and finally resume the
-original LV.  This seems like extra pointless operations to me, but it does not
-produce the error message (although, I'm not sure why) and it allows us to
-leave the visible flag in place.  ** THIS IS THE CHOSEN SOLUTION HERE **
-
-3) Flag the sub-lv (error target) with a "do not scan" flag.  This seems like
-the cleanest approach, but I have been unable to find the method for doing
-this.  LVs get tagged in such a way by _get_udev_flags, but in this case the
-resume of the original LV also resumes the error target LV without running it
-through _get_udev_flags (likely because they are no longer linked).  Could
-there be something wrong in resume_lv?
-	*/
-	if (sub_lv && !resume_lv(sub_lv->vg->cmd, sub_lv))
-		return_0;
-
-	/*
 	 * Resume the mirror - this also activates the visible, independent
 	 *                     soon-to-be-split sub-LVs
 	 */


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2011-09-14  2:45 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2011-09-14  2:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-09-14 02:45:37

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix for bug 734252 - problem up converting striped mirror after image failure
	
	lv_mirror_count was not able to handle mirrors of stripes properly.  When a
	failed device is removed, the MIRRORED status flag is removed from the LV
	conditionally based on the results of lv_mirror_count.  However, lv_mirror_count
	trusted the MIRRORED flag - thinking any such LV must be mirrored.  It would
	happily assign first_seg(lv)->area_count as the number of mirrors, but when
	a mirrored striped LV was reduced to a simple striped LV area_count would be
	the number of /stripes/ not the number of /mirrors/.  A result higher than 1
	would be returned from lv_mirror_count, the MIRRORED flag would not be cleared,
	and the LV would fail to be up-converted properly in lvconvert_mirrors_aux
	because of it.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2106&r2=1.2107
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.166&r2=1.167

--- LVM2/WHATS_NEW	2011/09/13 21:13:33	1.2106
+++ LVM2/WHATS_NEW	2011/09/14 02:45:36	1.2107
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Fix lv_mirror_count to handle mirrored stripes properly.
   Fix failure to down-convert a mirror to linear due to udev "dev open" conflict
   Fix mirrored log creation when PE size is small - force log_size >= region_size
   Fix improper RAID 64-bit status flag reset when and'ing against 32-bit flag.
--- LVM2/lib/metadata/mirror.c	2011/09/13 21:13:33	1.166
+++ LVM2/lib/metadata/mirror.c	2011/09/14 02:45:37	1.167
@@ -114,16 +114,18 @@
 		return 1;
 
 	seg = first_seg(lv);
-	mirrors = seg->area_count;
+	mirrors = 0;
 
 	for (s = 0; s < seg->area_count; s++) {
 		if (seg_type(seg, s) != AREA_LV)
 			continue;
 		if (is_temporary_mirror_layer(seg_lv(seg, s)))
 			mirrors += lv_mirror_count(seg_lv(seg, s)) - 1;
+		else
+			mirrors++;
 	}
 
-	return mirrors;
+	return mirrors ? mirrors : 1;
 }
 
 struct lv_segment *find_mirror_seg(struct lv_segment *seg)


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2011-09-13 21:13 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2011-09-13 21:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-09-13 21:13:33

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix bug 733400 - Mirror down conversion when specifying the secondary leg is broke
	
	The operation of deactivating the residual error target LV after removing a
	mirror layer can cause a "device in-use" conflict with udev.  Giving udev a
	poke before calling deactivate_lv eliminates the conflict.  The stick used
	to poke udev is 'sync_local_dev_names'.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2105&r2=1.2106
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.165&r2=1.166

--- LVM2/WHATS_NEW	2011/09/13 18:42:57	1.2105
+++ LVM2/WHATS_NEW	2011/09/13 21:13:33	1.2106
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Fix failure to down-convert a mirror to linear due to udev "dev open" conflict
   Fix mirrored log creation when PE size is small - force log_size >= region_size
   Fix improper RAID 64-bit status flag reset when and'ing against 32-bit flag.
   Fix log size calculation when only a log is being added to a mirror.
--- LVM2/lib/metadata/mirror.c	2011/09/13 18:11:38	1.165
+++ LVM2/lib/metadata/mirror.c	2011/09/13 21:13:33	1.166
@@ -419,6 +419,7 @@
 			return_0;
 	}
 
+	sync_local_dev_names(lv->vg->cmd);
 	if (!deactivate_lv(cmd, lv))
 		return_0;
 


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2011-09-13 14:37 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2011-09-13 14:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-09-13 14:37:49

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix for bug 737125 - unable to create mirror on 1K extent size VG
	
	_alloc_init calculates the number of necessary log extents via
	'mirror_log_extents'.  'mirror_log_extents' takes 3 arguments: region_size,
	pe_size, and size of the mirror LV.  Unfortunately, _alloc_init is guessing at
	the mirror size by using 'ah->new_extents / ah->area_multiple' - the number of
	extents that the mirror images have.  However, this is /always/ wrong when
	allocating the log separately.  Further, the log is always allocated separately
	unless we are up-converting the mirror at the same time.  It was by luck alone
	that a default value of '1' reflects what we want in most cases.
	
	In order to get a decent value computed, we need to pass in the 'lv' argument
	to allocate_extents.  This would normally imply a desire for cling/contiguous
	allocation to the given LV, but since we are not allocating any parallel
	extents and only log extents, it works fine.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2102&r2=1.2103
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.163&r2=1.164

--- LVM2/WHATS_NEW	2011/09/13 13:59:19	1.2102
+++ LVM2/WHATS_NEW	2011/09/13 14:37:48	1.2103
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Fix log size calculation when only a log is being added to a mirror.
   Work around resume_lv causing error LV scanning during splitmirror operation.
   Add 7th lv_attr char to show the related kernel target.
   Terminate pv_attr field correctly. (2.02.86)
--- LVM2/lib/metadata/mirror.c	2011/09/13 13:59:19	1.163
+++ LVM2/lib/metadata/mirror.c	2011/09/13 14:37:49	1.164
@@ -1966,7 +1966,7 @@
 	}
 
 	/* allocate destination extents */
-	ah = allocate_extents(lv->vg, NULL, segtype,
+	ah = allocate_extents(lv->vg, lv, segtype,
 			      0, 0, log_count - old_log_count, region_size, 0,
 			      allocatable_pvs, alloc, parallel_areas);
 	if (!ah) {


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2011-09-13 13:59 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2011-09-13 13:59 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-09-13 13:59:19

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix for bug 733114.
	
	When an image is split from a 2-way mirror, the original mirror is converted to
	a linear device.  To do this, the top "layer" must be removed.  The segments
	are transferred from the sub-lv to the top-level LV and the link is severed.
	The former sub-lv - having its segments transferred - now contains a temporary
	error target.
	
	When the original LV is resumed, the old sub-lv that now contains an error
	segment is activated and scanned.  This is what causes the I/O error messages.
	There are three ways to fix this problem:
	
	1) Do not set the sub-lv which contains the error target as "visible" before
	suspending the original LV.  This way, when the original is resumed, the sub-lv
	device node is not created and it is not scanned - avoiding the error messages.
	The problem with this approach is that if the machine crashes after the
	resume, it leaves the *hidden* LV in place and the user has a more difficult
	time noticing that it needs to be cleaned up.  Thus, this type of processing is
	frowned upon.
	
	2) Do like _remove_mirror_images does and suspend the original, then suspend
	the sub-lv (the error target), then resume the sub-lv, and finally resume the
	original LV.  This seems like extra pointless operations to me, but it does not
	produce the error message (although, I'm not sure why) and it allows us to
	leave the visible flag in place.
	
	3) Flag the sub-lv (error target) with a "do not scan" flag.  This seems like
	the cleanest approach, but I have been unable to find the method for doing
	this.  LVs get tagged in such a way by _get_udev_flags, but in this case the
	resume of the original LV also resumes the error target LV without running it
	through _get_udev_flags (likely because they are no longer linked).  Could
	there be something wrong in resume_lv?
	
	Option #2 was chosen to fix this bug, but it seems like more of a workaround
	for now.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2101&r2=1.2102
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.162&r2=1.163

--- LVM2/WHATS_NEW	2011/09/08 20:55:39	1.2101
+++ LVM2/WHATS_NEW	2011/09/13 13:59:19	1.2102
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Work around resume_lv causing error LV scanning during splitmirror operation.
   Add 7th lv_attr char to show the related kernel target.
   Terminate pv_attr field correctly. (2.02.86)
   Fix 'not not' typo in pvcreate man page.
--- LVM2/lib/metadata/mirror.c	2011/09/06 19:25:43	1.162
+++ LVM2/lib/metadata/mirror.c	2011/09/13 13:59:19	1.163
@@ -666,6 +666,10 @@
 		return 0;
 	}
 
+	/* Suspend temporary error target (see FIXME for resume below) */
+	if (sub_lv && !suspend_lv(sub_lv->vg->cmd, sub_lv))
+		return_0;
+
 	if (!vg_commit(mirrored_seg->lv->vg)) {
 		resume_lv(cmd, mirrored_seg->lv);
 		return 0;
@@ -674,6 +678,42 @@
 	log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name);
 
 	/*
+	 * FIXME:
+When an image is split from a 2-way mirror, the original mirror is converted to
+a linear device.  To do this, the top "layer" must be removed.  The segments
+are transferred from the sub-lv to the top-level LV and the link is severed. 
+The former sub-lv - having its segments transferred - now contains a temporary
+error target.
+
+When the original LV is resumed, the old sub-lv that now contains an error
+segment is activated and scanned.  This causes I/O error messages.  There are
+three ways to fix this problem:
+
+1) Do not set the sub-lv which contains the error target as "visible" before
+suspending the original LV.  This way, when the original is resumed, the sub-lv
+device node is not created and it is not scanned - avoiding the error messages.
+ The problem with this approach is that if the machine crashes after the
+resume, it leaves the *hidden* LV in place and the user has a more difficult
+time noticing that it needs to be cleaned up.  Thus, this type of processing is
+frowned upon.
+
+2) Do like _remove_mirror_images does and suspend the original, then suspend
+the sub-lv (the error target), then resume the sub-lv, and finally resume the
+original LV.  This seems like extra pointless operations to me, but it does not
+produce the error message (although, I'm not sure why) and it allows us to
+leave the visible flag in place.  ** THIS IS THE CHOSEN SOLUTION HERE **
+
+3) Flag the sub-lv (error target) with a "do not scan" flag.  This seems like
+the cleanest approach, but I have been unable to find the method for doing
+this.  LVs get tagged in such a way by _get_udev_flags, but in this case the
+resume of the original LV also resumes the error target LV without running it
+through _get_udev_flags (likely because they are no longer linked).  Could
+there be something wrong in resume_lv?
+	*/
+	if (sub_lv && !resume_lv(sub_lv->vg->cmd, sub_lv))
+		return_0;
+
+	/*
 	 * Resume the mirror - this also activates the visible, independent
 	 *                     soon-to-be-split sub-LVs
 	 */


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2011-09-01 19:22 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2011-09-01 19:22 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-09-01 19:22:11

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix for bug 732142: Unsafe table load during mirror image split
	
	There was a bad sequence:
	*) Make changes to LV layout to split images (e.g. 4-way -> 2-way/2-way)
	1) vg_write, suspend_lv(original_mirror), vg_commit
	2) activate_lv(newly_split_lv)
	3) resume_lv(original_mirror)
	
	Step #2 is not allowed.  However, without it, the resume of the original
	mirror will also resume its former sub-LVs - making it impossible to
	activate the newly split LV due to the changes in layering, pointers, and
	names that had already been made.  Additionally, the resume or the original
	brings the sub-lv's online with names that differ from the metadata on disk -
	also a no-no.  Thus, the split must be done in stages such that the active LVs
	always reflect what is in the committed LVM metadata.
	
	First, alter the original mirror by releasing the images.  The images are made
	visible and independent as an intermediate stage.  (This way, we can have
	consistency between LVM metadata and active LVs.)  The second stage collects
	the recently split LVs, deactivates them, forms them into a mirror if necessary,
	and then activates them.  It is a bit of a circuitous method, but it is the only
	way to split a mirror from a mirror and obey these general rules:
	1) Never [de]activate sub-lvs when the top-level LV is suspended
	2) Avoid having active LVs that differ from the description in the LVM metadata
	
	Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2088&r2=1.2089
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.159&r2=1.160

--- LVM2/WHATS_NEW	2011/09/01 10:25:22	1.2088
+++ LVM2/WHATS_NEW	2011/09/01 19:22:11	1.2089
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Fix unsafe table load when splitting off smaller mirror from a larger one.
   Use size_t return type for text_vg_export_raw() and export_vg_to_buffer().
   Add configure --enable-lvmetad for building the (experimental) LVMetaD.
   Fix resource leak when strdup fails in _get_device_status() (2.02.85).
--- LVM2/lib/metadata/mirror.c	2011/08/30 14:55:17	1.159
+++ LVM2/lib/metadata/mirror.c	2011/09/01 19:22:11	1.160
@@ -585,7 +585,8 @@
 	struct logical_volume *detached_log_lv = NULL;
 	struct lv_segment *mirrored_seg = first_seg(lv);
 	struct dm_list split_images;
-	struct lv_list *lvl;
+	struct lv_list *lvl, *new_lvl;
+	struct cmd_context *cmd = lv->vg->cmd;
 
 	if (!(lv->status & MIRRORED)) {
 		log_error("Unable to split non-mirrored LV, %s",
@@ -594,7 +595,7 @@
 	}
 
 	if (!split_count) {
-		log_error("split_count is zero!");
+		log_error(INTERNAL_ERROR "split_count is zero!");
 		return 0;
 	}
 
@@ -614,6 +615,12 @@
 		return 0;
 	}
 
+	/*
+	 * Step 1:
+	 *   Remove the images from the mirror.
+	 *   Make them visible, independent LVs (don't change names yet).
+	 *   Track them in a list for later instantiation.
+	 */
 	dm_list_init(&split_images);
 	for (i = 0; i < split_count; i++) {
 		mirrored_seg->area_count--;
@@ -626,31 +633,114 @@
 
 		log_very_verbose("%s assigned to be split", sub_lv->name);
 
+		lvl = dm_pool_alloc(lv->vg->vgmem, sizeof(*lvl));
+		if (!lvl) {
+			log_error("lv_list alloc failed");
+			return 0;
+		}
+		lvl->lv = sub_lv;
+		dm_list_add(&split_images, &lvl->list);
+	}
+	sub_lv = NULL;
+
+	/*
+	 * If no more mirrors, remove mirror layer.
+	 * The sub_lv is removed entirely later - leaving
+	 * only the top-level (now linear) LV.
+	 */
+	if (mirrored_seg->area_count == 1) {
+		sub_lv = seg_lv(mirrored_seg, 0);
+		sub_lv->status &= ~MIRROR_IMAGE;
+		lv_set_visible(sub_lv);
+		detached_log_lv = detach_mirror_log(mirrored_seg);
+		if (!remove_layer_from_lv(lv, sub_lv))
+			return_0;
+		lv->status &= ~MIRRORED;
+		lv->status &= ~LV_NOTSYNCED;
+	}
+
+	if (!vg_write(mirrored_seg->lv->vg)) {
+		log_error("Intermediate VG metadata write failed.");
+		return 0;
+	}
+
+	/*
+	 * Suspend the mirror - this includes all the sub-LVs and
+	 *                      soon-to-be-split sub-LVs
+	 */
+	if (!suspend_lv(cmd, mirrored_seg->lv)) {
+		log_error("Failed to lock %s", mirrored_seg->lv->name);
+		vg_revert(mirrored_seg->lv->vg);
+		return 0;
+	}
+
+	if (!vg_commit(mirrored_seg->lv->vg)) {
+		resume_lv(cmd, mirrored_seg->lv);
+		return 0;
+	}
+
+	log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name);
+
+	/*
+	 * Resume the mirror - this also activates the visible, independent
+	 *                     soon-to-be-split sub-LVs
+	 */
+	if (!resume_lv(cmd, mirrored_seg->lv)) {
+		log_error("Problem resuming %s", mirrored_seg->lv->name);
+		return 0;
+	}
+
+	/* Remove original mirror layer if it has been converted to linear */
+	if (sub_lv && !_delete_lv(lv, sub_lv))
+		return_0;
+
+	/* Remove the log if it has been converted to linear */
+	if (detached_log_lv && !_delete_lv(lv, detached_log_lv))
+		return_0;
+
+	/*
+	 * Step 2:
+	 *   The original mirror has been changed and we now have visible,
+	 *   independent, not-yet-renamed, active sub-LVs.  We must:
+	 *   - deactivate the split sub-LVs
+	 *   - rename them
+	 *   - form new mirror if necessary
+	 *   - commit VG changes
+	 *   - activate the new LV
+	 */
+	new_lv = NULL;
+	dm_list_iterate_items(lvl, &split_images) {
 		if (!new_lv) {
-			new_lv = sub_lv;
-			new_lv->name = dm_pool_strdup(lv->vg->cmd->mem,
-						      split_name);
-			if (!new_lv->name) {
-				log_error("Unable to rename newly split LV");
-				return 0;
-			}
-		} else {
-			lvl = dm_pool_alloc(lv->vg->cmd->mem, sizeof(*lvl));
-			if (!lvl) {
-				log_error("lv_list alloc failed");
-				return 0;
-			}
-			lvl->lv = sub_lv;
-			dm_list_add(&split_images, &lvl->list);
+			/* Grab 1st sub-LV for later */
+			new_lvl = lvl;
+			new_lv = lvl->lv;
+		}
+
+		sub_lv = lvl->lv;
+		if (!deactivate_lv(cmd, sub_lv)) {
+			log_error("Failed to deactivate former mirror image, %s",
+				  sub_lv->name);
+			return 0;
 		}
 	}
 
+	dm_list_del(&new_lvl->list);
+	new_lv->name = dm_pool_strdup(lv->vg->vgmem, split_name);
+	if (!new_lv->name) {
+		log_error("Unable to rename newly split LV");
+		return 0;
+	}
+
 	if (!dm_list_empty(&split_images)) {
 		size_t len = strlen(new_lv->name) + 32;
 		char *layer_name, format[len];
 
-		if (!insert_layer_for_lv(lv->vg->cmd, new_lv,
-					 0, "_mimage_%d")) {
+		/*
+		 * A number of images have been split and
+		 * a new mirror layer must be formed
+		 */
+
+		if (!insert_layer_for_lv(cmd, new_lv, 0, "_mimage_%d")) {
 			log_error("Failed to build new mirror, %s",
 				  new_lv->name);
 			return 0;
@@ -664,7 +754,7 @@
 			dm_snprintf(format, len, "%s_mimage_%%d",
 				    new_lv->name);
 
-			layer_name = dm_pool_alloc(lv->vg->cmd->mem, len);
+			layer_name = dm_pool_alloc(lv->vg->vgmem, len);
 			if (!layer_name) {
 				log_error("Unable to allocate memory");
 				return 0;
@@ -691,63 +781,17 @@
 		init_mirror_in_sync(1);
 	}
 
-	sub_lv = NULL;
-
-	/*
-	 * If no more mirrors, remove mirror layer.
-	 * The sub_lv is removed entirely later - leaving
-	 * only the top-level (now linear) LV.
-	 */
-	if (mirrored_seg->area_count == 1) {
-		sub_lv = seg_lv(mirrored_seg, 0);
-		sub_lv->status &= ~MIRROR_IMAGE;
-		lv_set_visible(sub_lv);
-		detached_log_lv = detach_mirror_log(mirrored_seg);
-		if (!remove_layer_from_lv(lv, sub_lv))
-			return_0;
-		lv->status &= ~MIRRORED;
-		lv->status &= ~LV_NOTSYNCED;
-	}
-
-	if (!vg_write(mirrored_seg->lv->vg)) {
-		log_error("Intermediate VG metadata write failed.");
-		return 0;
-	}
-
-	/*
-	 * Suspend the original device and all its sub devices
-	 */
-	if (!suspend_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
-		log_error("Failed to lock %s", mirrored_seg->lv->name);
-		vg_revert(mirrored_seg->lv->vg);
-		return 0;
-	}
-
-	if (!vg_commit(mirrored_seg->lv->vg)) {
-		resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv);
-		return 0;
-	}
+	if (!vg_write(mirrored_seg->lv->vg) ||
+	    !vg_commit(mirrored_seg->lv->vg))
+		return_0;
 
 	/* Bring newly split-off LV into existence */
-	if (!activate_lv(lv->vg->cmd, new_lv)) {
+	if (!activate_lv(cmd, new_lv)) {
 		log_error("Failed to activate newly split LV, %s",
 			  new_lv->name);
 		return 0;
 	}
 
-	/* Resume altered original LV */
-	log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name);
-	if (!resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
-		log_error("Problem reactivating %s", mirrored_seg->lv->name);
-		return 0;
-	}
-
-	if (sub_lv && !_delete_lv(lv, sub_lv))
-		return_0;
-
-	if (detached_log_lv && !_delete_lv(lv, detached_log_lv))
-		return_0;
-
 	log_very_verbose("%" PRIu32 " image(s) detached from %s",
 			 split_count, lv->name);
 


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2011-06-17 14:27 zkabelac
  0 siblings, 0 replies; 29+ messages in thread
From: zkabelac @ 2011-06-17 14:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-06-17 14:27:35

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Remove test for status flag
	
	As the ACTIVATE_EXCL could be set only in clvmd code - there is no
	use for this test in lv_add_mirrors() function only called from
	tools context.
	
	FIXME: Add cluster test case for this.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2019&r2=1.2020
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.153&r2=1.154

--- LVM2/WHATS_NEW	2011/06/17 14:22:48	1.2019
+++ LVM2/WHATS_NEW	2011/06/17 14:27:34	1.2020
@@ -1,5 +1,6 @@
 Version 2.02.86 -  
 =================================
+  Remove useless test of ACTIVATE_EXCL in lv_add_mirrors() clustered code path.
   Use lv_activate_opts struct instead of MERGING status flag.
   Use lv_activate_opts struct instead of ACTIVATE_EXCL status flag.
   Add lv_activate_opts structure for activation (replacing activation flags).
--- LVM2/lib/metadata/mirror.c	2011/06/17 14:24:18	1.153
+++ LVM2/lib/metadata/mirror.c	2011/06/17 14:27:35	1.154
@@ -2021,8 +2021,7 @@
 
 	if (vg_is_clustered(lv->vg)) {
 		/* FIXME: review check of lv_is_active_remotely */
-		if (!(lv->status & ACTIVATE_EXCL) &&
-		    !cluster_mirror_is_available(lv)) {
+		if (!cluster_mirror_is_available(lv)) {
 			log_error("Shared cluster mirrors are not available.");
 			return 0;
 		}


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2010-08-16 18:02 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2010-08-16 18:02 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-08-16 18:02:15

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix for bug 612291: dm devices of split off mirror images are not removed
	
	DM devices were not handled properly on nodes in a cluster that were not
	where the splitmirrors command was issued.  This was happening because
	suspend_lv/resume_lv were being used in a place where activate_lv should
	have been used.
	
	When the suspend/resume are issued on (effectively) new LVs, their
	'resource' (UUID) is not located in the lv_hash.  Thus, both operations
	turn into no-ops.  You can see this from the output of clvmd from one
	of the remote nodes:
	<snip>
	do_suspend_lv, lock not already held
	<snip>
	do_resume_lv, lock not already held
	
	'activate_lv' enjoins the other nodes in the cluster to process the lock
	and activate the new LV.  clvmd output from remote node as follows:
	do_lock_lv: resource 'zMseY7CBuO3Ty09vXlplPAHzD0Y0CovjrTdv0R1VcwggMwPdYhutHErRcwm5Nd2S', cmd = 0x19 LCK_LV_ACTIVATE (READ|LV|NONBLOCK), flags = 0x84 (DMEVENTD_MONITOR ), memlock = 1
	sync_lock: 'zMseY7CBuO3Ty09vXlplPAHzD0Y0CovjrTdv0R1VcwggMwPdYhutHErRcwm5Nd2S' mode:1 flags=1
	sync_lock: returning lkid 27b0001
	
	Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
	Reviewed-by: Petr Rockai <prockai@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1702&r2=1.1703
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.131&r2=1.132

--- LVM2/WHATS_NEW	2010/08/12 09:14:59	1.1702
+++ LVM2/WHATS_NEW	2010/08/16 18:02:14	1.1703
@@ -1,5 +1,6 @@
 Version 2.02.73 - 
 ================================
+  Fix 'lvconvert --splitmirrors' in cluster operation.
   Fix clvmd init script exit code when executed as non-root user.
   Change default alignment of pe_start to 1MB.
   Add --norestorefile option to pvcreate.
--- LVM2/lib/metadata/mirror.c	2010/08/06 15:38:32	1.131
+++ LVM2/lib/metadata/mirror.c	2010/08/16 18:02:14	1.132
@@ -719,19 +719,8 @@
 		return 0;
 	}
 
-	/*
-	 * Suspend the newly split-off LV (balance memlock count
-	 * and prepare for DM automated renaming via resume).
-	 */
-	if (!suspend_lv(lv->vg->cmd, new_lv)) {
-		log_error("Failed to lock newly split LV, %s", new_lv->name);
-		vg_revert(lv->vg);
-		return 0;
-	}
-
 	/* Bring newly split-off LV into existence */
-	log_very_verbose("Creating %s", new_lv->name);
-	if (!resume_lv(lv->vg->cmd, new_lv)) {
+	if (!activate_lv(lv->vg->cmd, new_lv)) {
 		log_error("Failed to activate newly split LV, %s",
 			  new_lv->name);
 		return 0;


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2010-07-13 22:24 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2010-07-13 22:24 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix for bug 614164: No check for existing name when splitting mirror
	
	The user could use the same name as an existing LV when specifying a
	name for an LV split off from a mirror.  This causes all sorts of
	issues.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1667&r2=1.1668
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.126&r2=1.127

--- LVM2/WHATS_NEW	2010/07/13 21:48:16	1.1667
+++ LVM2/WHATS_NEW	2010/07/13 22:24:39	1.1668
@@ -1,5 +1,6 @@
 Version 2.02.71 -
 ===============================
+  Check if LV with specified name already exists when splitting a mirror.
   Fix suspend/resume logic for LVs resulting from splitting a mirror.
   Switch cmirrord and clvmd to use dm_create_lockfile.
   Allow clvmd pidfile to be configurable.
--- LVM2/lib/metadata/mirror.c	2010/07/13 21:48:17	1.126
+++ LVM2/lib/metadata/mirror.c	2010/07/13 22:24:39	1.127
@@ -1982,6 +1982,12 @@
 {
 	int r;
 
+	if (find_lv_in_vg(lv->vg, split_name)) {
+		log_error("Logical Volume \"%s\" already exists in "
+			  "volume group \"%s\"", split_name, lv->vg->name);
+		return 0;
+	}
+
 	/* Can't split a mirror that is not in-sync... unless force? */
 	if (!_mirrored_lv_in_sync(lv)) {
 		log_error("Unable to split mirror that is not in-sync.");


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2010-07-13 21:48 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2010-07-13 21:48 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix for bugs: 612248 & 612291 Split mirror issues
	
	The main problem with these bugs was that the newly split
	off LV was not being suspended properly.  This meant that
	the memlock count was not being balanced, the DM devices
	were not being renamed, and some DM devices which should
	have been removed were not.
	
	I've also renamed some of the variables and added comments
	to make things clearer as to what is going on.  (I can break
	this patch in two if it means easier review.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1666&r2=1.1667
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126

--- LVM2/WHATS_NEW	2010/07/13 13:51:01	1.1666
+++ LVM2/WHATS_NEW	2010/07/13 21:48:16	1.1667
@@ -1,5 +1,6 @@
 Version 2.02.71 -
 ===============================
+  Fix suspend/resume logic for LVs resulting from splitting a mirror.
   Switch cmirrord and clvmd to use dm_create_lockfile.
   Allow clvmd pidfile to be configurable.
   Update comments about memory handling in lvm2app.h.
--- LVM2/lib/metadata/mirror.c	2010/07/09 17:57:51	1.125
+++ LVM2/lib/metadata/mirror.c	2010/07/13 21:48:17	1.126
@@ -553,9 +553,9 @@
 				struct dm_list *removable_pvs)
 {
 	uint32_t i;
-	struct logical_volume *sub_lv, *new_lv = NULL;
+	struct logical_volume *sub_lv = NULL;
+	struct logical_volume *new_lv = NULL;
 	struct logical_volume *detached_log_lv = NULL;
-	struct logical_volume *lv1 = NULL;
 	struct lv_segment *mirrored_seg = first_seg(lv);
 	struct dm_list split_images;
 	struct lv_list *lvl;
@@ -597,6 +597,8 @@
 		release_lv_segment_area(mirrored_seg, mirrored_seg->area_count,
 					mirrored_seg->area_len);
 
+		log_very_verbose("%s assigned to be split", sub_lv->name);
+
 		if (!new_lv) {
 			new_lv = sub_lv;
 			new_lv->name = dm_pool_strdup(lv->vg->cmd->mem,
@@ -662,13 +664,19 @@
 		init_mirror_in_sync(1);
 	}
 
-	/* If no more mirrors, remove mirror layer */
+	sub_lv = NULL;
+
+	/*
+	 * If no more mirrors, remove mirror layer.
+	 * The sub_lv is removed entirely later - leaving
+	 * only the top-level (now linear) LV.
+	 */
 	if (mirrored_seg->area_count == 1) {
-		lv1 = seg_lv(mirrored_seg, 0);
-		lv1->status &= ~MIRROR_IMAGE;
-		lv_set_visible(lv1);
+		sub_lv = seg_lv(mirrored_seg, 0);
+		sub_lv->status &= ~MIRROR_IMAGE;
+		lv_set_visible(sub_lv);
 		detached_log_lv = detach_mirror_log(mirrored_seg);
-		if (!remove_layer_from_lv(lv, lv1))
+		if (!remove_layer_from_lv(lv, sub_lv))
 			return_0;
 		lv->status &= ~MIRRORED;
 		lv->status &= ~MIRROR_NOTSYNCED;
@@ -679,6 +687,9 @@
 		return 0;
 	}
 
+	/*
+	 * Suspend the original device and all its sub devices
+	 */
 	if (!suspend_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
 		log_error("Failed to lock %s", mirrored_seg->lv->name);
 		vg_revert(mirrored_seg->lv->vg);
@@ -690,35 +701,32 @@
 		return 0;
 	}
 
-	log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name);
-
 	/*
-	 * If we have split off a mirror instead of linear (i.e. the
-	 * split_images list is not empty), then we must perform a
-	 * resume to get the mirror started.
+	 * Suspend the newly split-off LV (balance memlock count
+	 * and prepare for DM automated renaming via resume).
 	 */
-	if (!dm_list_empty(&split_images) && !resume_lv(lv->vg->cmd, new_lv)) {
-		log_error("Failed to resume newly split LV, %s", new_lv->name);
+	if (!suspend_lv(lv->vg->cmd, new_lv)) {
+		log_error("Failed to lock newly split LV, %s", new_lv->name);
+		vg_revert(lv->vg);
 		return 0;
 	}
 
-	/*
-	 * Avoid having same mirror target loaded twice simultaneously by first
-	 * resuming the removed LV which now contains an error segment.
-	 * As it's now detached from mirrored_seg->lv we must resume it
-	 * explicitly.
-	 */
-	if (lv1 && !resume_lv(lv1->vg->cmd, lv1)) {
-		log_error("Problem resuming temporary LV, %s", lv1->name);
+	/* Bring newly split-off LV into existence */
+	log_very_verbose("Creating %s", new_lv->name);
+	if (!resume_lv(lv->vg->cmd, new_lv)) {
+		log_error("Failed to activate newly split LV, %s",
+			  new_lv->name);
 		return 0;
 	}
 
+	/* Resume altered original LV */
+	log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name);
 	if (!resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
 		log_error("Problem reactivating %s", mirrored_seg->lv->name);
 		return 0;
 	}
 
-	if (lv1 && !_delete_lv(lv, lv1))
+	if (sub_lv && !_delete_lv(lv, sub_lv))
 		return_0;
 
 	if (detached_log_lv && !_delete_lv(lv, detached_log_lv))


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2010-07-09 15:08 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2010-07-09 15:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-07-09 15:08:15

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Finish fix for bug 607347: failing both redundant mirror log legs...
	
	A previous check-in added logic to handle the case where both images
	of a mirrored log failed.  It solved the problem by simply removing
	the log entirely - leaving the parent mirror with a 'core' log.  This
	worked for most cases.  However, if there was a small delay between
	the failures of the two mirrored log devices, the mirror would hang,
	LVM would hang, and no additional LVM commands could be issued.
	
	When the first leg of the log fails, it signals the need for repair.
	Before 'lvconvert --repair' is run by dmeventd, the second leg fails.
	'lvconvert' would see both devices as failed and try to remove the
	log entirely.  When it came time to suspend the parent mirror to
	update the configuration, the suspend would hang because it couldn't
	get any I/O through the mirrored log, which was plugged waiting for
	corrective action.  The solution is to replace the log with an error
	target to clear any pending writes before removing it.  This allows
	the parent mirror to suspend and make the proper changes.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1659&r2=1.1660
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123

--- LVM2/WHATS_NEW	2010/07/08 12:24:04	1.1659
+++ LVM2/WHATS_NEW	2010/07/09 15:08:12	1.1660
@@ -1,5 +1,6 @@
 Version 2.02.71 -
 ===============================
+  Fix possible hang when all mirror images of a mirrored log fail.
   Do not log backtrace in valid _lv_resume() code path.
   Cleanup help strings in configure.in.
   Prompt if metadataignore with vgextend or pvchange would adjust vg_mda_copies.
--- LVM2/lib/metadata/mirror.c	2010/07/02 21:16:50	1.122
+++ LVM2/lib/metadata/mirror.c	2010/07/09 15:08:15	1.123
@@ -864,9 +864,72 @@
 		lv->status &= ~MIRROR_NOTSYNCED;
 		if (!replace_lv_with_error_segment(lv))
 			return_0;
-	} else if (remove_log)
+	} else if (remove_log) {
 		detached_log_lv = detach_mirror_log(mirrored_seg);
 
+		/*
+		 * The log may be removed due to repair.  If the log
+		 * happens to be a mirrored log, then there is a special
+		 * case we need to consider.  One of the images of a
+		 * mirrored log can fail followed shortly afterwards by
+		 * a failure of the second.  This means that the top-level
+		 * mirror is waiting for writes to the log to finish, but
+		 * they never will unless the mirrored log can be repaired
+		 * or replaced with an error target.  Since both the devices
+		 * have failed, we must replace with error target - it is
+		 * the only way to release the pending writes.
+		 */
+		if (lv_is_mirrored(detached_log_lv) &&
+		    (detached_log_lv->status & PARTIAL_LV)) {
+			struct lv_segment *seg = first_seg(detached_log_lv);
+
+			log_very_verbose("%s being removed due to failures",
+					 detached_log_lv->name);
+
+			/*
+			 * We are going to replace the mirror with an
+			 * error segment, but before we do, we must remember
+			 * all of the LVs that must be deleted later (i.e.
+			 * the sub-lv's)
+			 */
+			for (m = 0; m < seg->area_count; m++) {
+				seg_lv(seg, m)->status &= ~MIRROR_IMAGE;
+				lv_set_visible(seg_lv(seg, m));
+				if (!(lvl = dm_pool_alloc(lv->vg->cmd->mem,
+							  sizeof(*lvl))))
+					return 0;
+				lvl->lv = seg_lv(seg, m);
+				dm_list_add(&tmp_orphan_lvs, &lvl->list);
+			}
+
+			if (!replace_lv_with_error_segment(detached_log_lv)) {
+				log_error("Failed error target substitution for %s",
+					  detached_log_lv->name);
+				return_0;
+			}
+
+			if (!vg_write(detached_log_lv->vg)) {
+				log_error("intermediate VG write fail.");
+				return 0;
+			}
+
+			if (!suspend_lv(detached_log_lv->vg->cmd,
+					detached_log_lv)) {
+				log_error("Failed to suspend %s",
+					  detached_log_lv->name);
+				vg_revert(detached_log_lv->vg);
+				return 0;
+			}
+
+			if (!vg_commit(detached_log_lv->vg))
+				return_0;
+
+			if (!resume_lv(detached_log_lv->vg->cmd,
+				       detached_log_lv))
+					return 0;
+		}
+	}
+
 	/*
 	 * To successfully remove these unwanted LVs we need to
 	 * remove the LVs from the mirror set, commit that metadata


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2010-06-28 14:19 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2010-06-28 14:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-06-28 14:19:46

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix for bz608048 from Taka...
	
	The same region size is used for both mirror volume and mirrored
	log volume, but when the physical extent size is bigger than region size,
	the size of mirror leg for mirrored log is smaller than the region size
	and lvcreate command fails.
	
	This patch adjusts a region size of mirrored log to a smaller value of
	region size or physical extent size.
	
	[This patch ensures that the region_size of the mirrored log does not
	exceed the size of the mirrored log itself, which would violate the
	kernel constraint: (region_size <= ti->len).]
	
	Signed-off-by: Takahiro Yasui <takahiro.yasui@hds.com>
	Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1637&r2=1.1638
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121

--- LVM2/WHATS_NEW	2010/06/25 18:17:38	1.1637
+++ LVM2/WHATS_NEW	2010/06/28 14:19:41	1.1638
@@ -1,5 +1,6 @@
 Version 2.02.69 - 
 ================================
+  Ensure region_size of mirrored log does not exceed its full size.
   Generate liblvm2app and libdevmapper exported symbols from header file.
   Preload libc locale messages to prevent reading it in memory locked state.
   Fix handling of simultaneous mirror image and mirrored log image failure.
--- LVM2/lib/metadata/mirror.c	2010/06/23 13:57:26	1.120
+++ LVM2/lib/metadata/mirror.c	2010/06/28 14:19:45	1.121
@@ -1816,7 +1816,9 @@
 	 * create and initialize mirror log
 	 */
 	if (log_count &&
-	    !(log_lv = _set_up_mirror_log(cmd, ah, lv, log_count, region_size,
+	    !(log_lv = _set_up_mirror_log(cmd, ah, lv, log_count,
+					  (region_size > lv->vg->extent_size) ?
+					  lv->vg->extent_size : region_size,
 					  alloc, mirror_in_sync()))) {
 		stack;
 		goto out_remove_images;


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2010-06-21 16:12 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2010-06-21 16:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-06-21 16:12:34

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Mirrors can be layered - as in the case of an converting 2-way
	to 3-way mirror.  When conversion operations are performed on
	these types of mirrors, log options can be confused/ignored.
	
	In the case of a converting 3-way mirror, we have a top-level
	2-way corelog mirror whose legs are 1) a 2-way disk-log mirror
	and 2) a linear device.  If we wish to convert this 3-way mirror
	to a 2-way mirror, the linear device is removed and the extra
	top layer is eliminated.  If we also wished to convert the disk
	log to a core log in the same step, ambiguity creeps in.  It is
	somewhat obvious what the user wants - a 2-way mirror with a
	corelog.  However, looking at the top level mirror before
	compression, it seems that the mirror already has a core log.
	This is why the operation seemed to fail.
	
	This patch simply re-evaluates what mirrored_seg points to after
	a compression and then considers the log argument.
	
	This is a fix for bug 599898.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1622&r2=1.1623
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119

--- LVM2/WHATS_NEW	2010/06/21 15:56:57	1.1622
+++ LVM2/WHATS_NEW	2010/06/21 16:12:33	1.1623
@@ -1,5 +1,6 @@
 Version 2.02.68 -
 ===============================
+  Honor log argument when down-converting stacked mirror.
   Sleep to workaround clvmd -S race: socket closed early and server drops cmd.
   Use early udev synchronisation and update of dev nodes for clustered mirrors.
   Remove incorrect inclusion of kdev_t.h from cmirrord/functions.h.
--- LVM2/lib/metadata/mirror.c	2010/05/24 15:32:20	1.118
+++ LVM2/lib/metadata/mirror.c	2010/06/21 16:12:34	1.119
@@ -851,6 +851,9 @@
 			log_error("Failed to add mirror images");
 			return 0;
 		}
+		mirrored_seg = first_seg(lv);
+		if (remove_log && !detached_log_lv)
+			detached_log_lv = detach_mirror_log(mirrored_seg);
 	} else if (new_area_count == 0) {
 		log_very_verbose("All mimages of %s are gone", lv->name);
 


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2010-04-27 15:27 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2010-04-27 15:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-04-27 15:26:59

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix comment from last commit.  Additionally, there is no need
	to put a comment into the WHATS_NEW file if it is a regression
	that was created and fixed inside the same release window.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1539&r2=1.1540
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.115&r2=1.116

--- LVM2/WHATS_NEW	2010/04/27 14:57:49	1.1539
+++ LVM2/WHATS_NEW	2010/04/27 15:26:58	1.1540
@@ -1,6 +1,5 @@
 Version 2.02.64 -
 =================================
-  Fix regression in down-convert of mirror images with partial PV specification.
   Fix lvconvert error message when existing mirrored LV is not found.
   Disallow the direct removal of a merging snapshot.
   Set appropriate udev flags for reserved LVs.
--- LVM2/lib/metadata/mirror.c	2010/04/27 14:57:49	1.115
+++ LVM2/lib/metadata/mirror.c	2010/04/27 15:26:59	1.116
@@ -811,7 +811,6 @@
 	 * If removable_pvs were specified, then they have been shifted
 	 * to the end to ensure they are removed.  The remaining balance
 	 * of images left to remove will be taken from the unspecified.
-	 * This may not be correct behavior, but it is historical.
 	 */
 	new_area_count = old_area_count - num_removed;
 


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2010-04-27 14:57 jbrassow
  0 siblings, 0 replies; 29+ messages in thread
From: jbrassow @ 2010-04-27 14:57 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-04-27 14:57:49

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Patch to fix bug 586021 and mantain historical behavior of
	being able to remove more images from a mirror than the
	number of PVs directly specified for removal.
	
	The effort to fix bug 581611 corrected a bug that was unnoticed
	at the time.  The loop in _remove_mirror_images that looks over
	the specified PVs was allowing devices that were previously
	counted and moved to the end of the list to be double-counted.
	This resulted in the number of devices needed for removal always
	being satisfied - even if the user did not specify enough PVs
	for removal to satisfy the request.  When 581611 was fixed, this
	double-counting no longer took place and the result was to remove
	only the minimum of the number of PVs specified or the number
	that was asked to be removed.
	
	By simply always setting 'new_area_count' (as used to be done
	only in the else statement), we return to the previous behavior.
	Indeed, this is exactly what the double-counting was allowing
	to happen before the fix of 581611.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1538&r2=1.1539
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.114&r2=1.115

--- LVM2/WHATS_NEW	2010/04/26 18:31:58	1.1538
+++ LVM2/WHATS_NEW	2010/04/27 14:57:49	1.1539
@@ -1,5 +1,6 @@
 Version 2.02.64 -
 =================================
+  Fix regression in down-convert of mirror images with partial PV specification.
   Fix lvconvert error message when existing mirrored LV is not found.
   Disallow the direct removal of a merging snapshot.
   Set appropriate udev flags for reserved LVs.
--- LVM2/lib/metadata/mirror.c	2010/04/21 13:55:08	1.114
+++ LVM2/lib/metadata/mirror.c	2010/04/27 14:57:49	1.115
@@ -805,8 +805,15 @@
 		}
 		if (num_removed && old_area_count == new_area_count)
 			return 1;
-	} else
-		new_area_count = old_area_count - num_removed;
+	}
+
+	/*
+	 * If removable_pvs were specified, then they have been shifted
+	 * to the end to ensure they are removed.  The remaining balance
+	 * of images left to remove will be taken from the unspecified.
+	 * This may not be correct behavior, but it is historical.
+	 */
+	new_area_count = old_area_count - num_removed;
 
 	/* Remove mimage LVs from the segment */
 	dm_list_init(&tmp_orphan_lvs);


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2009-12-09 19:53 mbroz
  0 siblings, 0 replies; 29+ messages in thread
From: mbroz @ 2009-12-09 19:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-12-09 19:53:39

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Call explicitly suspend for temporary mirror layer.
	
	The memlock_inc() fix is wrong, memlock count is not
	propagated to long living process (clvmd) and just
	it underflow there.
	Also suspend is needed to pre-load precommited metadata
	on other nodes (remapping to error taget in this case).
	
	With explicit suspend we generate lock request and code
	can update memlock count.
	
	(Infinitely "locked" memory caused that fs_unlock() was not
	called properly and on cluster nodes remains
	old links in /dev/mapper for not active devices.)
	
	(N.B. failing of suspend call here is not handled as fatal
	error - the LV is going to be removed later anyway.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1349&r2=1.1350
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99

--- LVM2/WHATS_NEW	2009/12/09 19:29:04	1.1349
+++ LVM2/WHATS_NEW	2009/12/09 19:53:39	1.1350
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Explicitly call suspend for temporary mirror layer.
   Allow use precommited metadata when a PV is missing.
   Add memlock information to do_lock_lv debug output.
   Never use distributed lock for LV in non-clustered VG.
--- LVM2/lib/metadata/mirror.c	2009/12/09 19:43:39	1.98
+++ LVM2/lib/metadata/mirror.c	2009/12/09 19:53:39	1.99
@@ -603,6 +603,16 @@
 		return 0;
 	}
 
+	/* FIXME: second suspend should not be needed
+	 * Explicitly suspend temporary LV
+	 * This balance memlock_inc() calls with memlock_dec() in resume
+	 * (both localy and in cluster) and also properly propagates precommited
+	 * metadata into dm table on other nodes.
+	 * (visible flag set causes the suspend is not properly propagated?)
+	 */
+	if (temp_layer_lv && !suspend_lv(temp_layer_lv->vg->cmd, temp_layer_lv))
+		log_error("Problem suspending temporary LV %s", temp_layer_lv->name);
+
 	if (!vg_commit(mirrored_seg->lv->vg)) {
 		resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv);
 		return 0;
@@ -616,23 +626,9 @@
 	 * As it's now detached from mirrored_seg->lv we must resume it
 	 * explicitly.
 	 */
-	if (temp_layer_lv) {
-		if (!resume_lv(temp_layer_lv->vg->cmd, temp_layer_lv)) {
-			log_error("Problem resuming temporary LV, %s", temp_layer_lv->name);
-			return 0;
-		}
-
-		/*
-		 * The code above calls a suspend_lv once, however we now need
-		 * to resume 2 LVs, due to image removal: the mirror image
-		 * itself here, and now the remaining mirror LV. Since
-		 * suspend_lv/resume_lv call memlock_inc/memlock_dec and these
-		 * need to be balanced, we need to call an extra memlock_inc()
-		 * here to balance for the this extra resume -- the following
-		 * one could otherwise either deadlock due to suspended
-		 * devices, or alternatively drop memlock_count below 0.
-		 */
-		memlock_inc();
+	if (temp_layer_lv && !resume_lv(temp_layer_lv->vg->cmd, temp_layer_lv)) {
+		log_error("Problem resuming temporary LV, %s", temp_layer_lv->name);
+		return 0;
 	}
 
 	if (!resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2009-12-09 18:09 mbroz
  0 siblings, 0 replies; 29+ messages in thread
From: mbroz @ 2009-12-09 18:09 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-12-09 18:09:53

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Remove newly created log volume if initial deactivation fails.
	
	If there is problem deactivate LV and
	_init_mirror_log is called with remove_on_failure = 1,
	remove the newly created log LV from metadata.
	
	(This can happen if there is active device with the same name
	but different UUID.)
	
	The main reason for this "workaround" patch is to
	- do not keep _mlog volume in metadata, so user can repeat the action
	- print better error message describing the real problem
	
	# lvcreate -m 2 -n lv1 -l 1 --nosync vg_bar
	WARNING: New mirror won't be synchronised. Don't read what you didn't write!
	/dev/vg_bar/lv1_mlog: not found: device not cleared
	Aborting. Failed to wipe mirror log.
	Error locking on node bar-01: Input/output error
	Unable to deactivate mirror log LV. Manual intervention required.
	Failed to create mirror log.
	
	# lvcreate -m 2 -n lv1 -l 1 --nosync vg_bar
	WARNING: New mirror won't be synchronised. Don't read what you didn't write!
	Aborting. Unable to deactivate mirror log.
	Failed to initialise mirror log.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1342&r2=1.1343
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.96&r2=1.97

--- LVM2/WHATS_NEW	2009/12/04 14:26:22	1.1342
+++ LVM2/WHATS_NEW	2009/12/09 18:09:52	1.1343
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Remove log volume from metadata if initial deactivation fails.
   Give better error message for pvmove when all data is skipped.
   Fix memory lock imbalance in lv_suspend if already suspended.
   Fix pvmove test mode to not fail and do not poll.
--- LVM2/lib/metadata/mirror.c	2009/11/24 22:55:56	1.96
+++ LVM2/lib/metadata/mirror.c	2009/12/09 18:09:52	1.97
@@ -255,8 +255,16 @@
 
 	/* If the LV is active, deactivate it first. */
 	if (lv_info(cmd, log_lv, &info, 0, 0) && info.exists) {
-		if (!deactivate_lv(cmd, log_lv))
-			return_0;
+		(void)deactivate_lv(cmd, log_lv);
+		/*
+		 * FIXME: workaround to fail early
+		 * Ensure that log is really deactivated because deactivate_lv
+		 * on cluster do not fail if there is log_lv with different UUID.
+		 */
+		if (lv_info(cmd, log_lv, &info, 0, 0) && info.exists) {
+			log_error("Aborting. Unable to deactivate mirror log.");
+			goto revert_new_lv;
+		}
 		was_active = 1;
 	}
 
@@ -1354,7 +1362,7 @@
 	}
 
 	if (!_init_mirror_log(cmd, log_lv, in_sync, &lv->tags, 1)) {
-		log_error("Failed to create mirror log.");
+		log_error("Failed to initialise mirror log.");
 		return NULL;
 	}
 


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2009-04-10  9:53 mbroz
  0 siblings, 0 replies; 29+ messages in thread
From: mbroz @ 2009-04-10  9:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-04-10 09:53:43

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix mirror log convert validation question.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1081&r2=1.1082
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83

--- LVM2/WHATS_NEW	2009/04/08 14:08:23	1.1081
+++ LVM2/WHATS_NEW	2009/04/10 09:53:42	1.1082
@@ -1,5 +1,6 @@
 Version 2.02.46 - 
 ================================
+  Fix mirror log convert validation question.
   Avoid referencing files from DESTDIR during build process.
   Avoid creating some static libraries without static_link.
   Enable use of cached metadata for pvs and pvdisplay commands.
--- LVM2/lib/metadata/mirror.c	2009/04/07 10:20:29	1.82
+++ LVM2/lib/metadata/mirror.c	2009/04/10 09:53:43	1.83
@@ -1219,7 +1219,7 @@
 		return 0;
 	} else if (yes_no_prompt("Full resync required to convert "
 				 "inactive mirror %s to core log. "
-				 "Proceed? [y/n]: "))
+				 "Proceed? [y/n]: ") == 'y')
 		sync_percent = 0;
 	else
 		return 0;


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2008-10-17 10:50 agk
  0 siblings, 0 replies; 29+ messages in thread
From: agk @ 2008-10-17 10:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-10-17 10:50:15

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	In resume_mirror_images replace activate_lv with resume_lv as workaround.
	
	(The resume has the side-effect of resuming all of the original
	mirror's sub-lvs in addition to the new 'error' target middle layer.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.975&r2=1.976
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78

--- LVM2/WHATS_NEW	2008/10/17 00:55:46	1.975
+++ LVM2/WHATS_NEW	2008/10/17 10:50:14	1.976
@@ -1,5 +1,6 @@
 Version 2.02.41 -
 =====================================
+  In resume_mirror_images replace activate_lv with resume_lv as workaround.
   Avoid overwriting in-use on-disk text metadata by forgetting MDA_HEADER_SIZE.
   Fix snapshot monitoring library to not cancel monitoring invalid snapshot.
   Generate man pages from templates and include version.
--- LVM2/lib/metadata/mirror.c	2008/09/19 04:30:02	1.77
+++ LVM2/lib/metadata/mirror.c	2008/10/17 10:50:14	1.78
@@ -598,13 +598,13 @@
 	log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name);
 
 	/*
-	 * Avoid having same mirror target loaded twice simultaneouly by first
-	 * activating the removed LV which now contains an error segment.
-	 * As it's now detached from mirrored_seg->lv we must activate it
+	 * Avoid having same mirror target loaded twice simultaneously by first
+	 * resuming the removed LV which now contains an error segment.
+	 * As it's now detached from mirrored_seg->lv we must resume it
 	 * explicitly.
 	 */
-	if (lv1 && !activate_lv(lv1->vg->cmd, lv1)) {
-		log_error("Problem reactivating removed %s", lv1->name);
+	if (lv1 && !resume_lv(lv1->vg->cmd, lv1)) {
+		log_error("Problem resuming temporary LV, %s", lv1->name);
 		return 0;
 	}
 


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2008-09-18 19:09 agk
  0 siblings, 0 replies; 29+ messages in thread
From: agk @ 2008-09-18 19:09 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-09-18 19:09:47

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Add missing LV error target activation in _remove_mirror_images.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.953&r2=1.954
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74

--- LVM2/WHATS_NEW	2008/09/18 18:51:58	1.953
+++ LVM2/WHATS_NEW	2008/09/18 19:09:47	1.954
@@ -1,5 +1,6 @@
 Version 2.02.40 - 
 ================================
+  Add missing LV error target activation in _remove_mirror_images.
   Prevent resizing an LV while lvconvert is using it.
   Avoid repeatedly wiping cache while VG_GLOBAL is held in vgscan & pvscan.
   Fix pvresize to not allow resize if PV has two metadata areas.
--- LVM2/lib/metadata/mirror.c	2008/06/26 23:05:11	1.73
+++ LVM2/lib/metadata/mirror.c	2008/09/18 19:09:47	1.74
@@ -552,6 +552,17 @@
 
 	log_very_verbose("Updating \"%s\" in kernel", mirrored_seg->lv->name);
 
+	/*
+	 * Avoid having same mirror target loaded twice simultaneouly by first
+	 * activating the removed LV which now contains an error segment.
+	 * As it's now detached from mirrored_seg->lv we must activate it
+	 * explicitly.
+	 */
+	if (lv1 && !activate_lv(lv1->vg->cmd, lv1)) {
+		log_error("Problem reactivating removed %s", lv1->name);
+		return 0;
+	}
+
 	if (!resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
 		log_error("Problem reactivating %s", mirrored_seg->lv->name);
 		return 0;


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2008-06-13 12:15 meyering
  0 siblings, 0 replies; 29+ messages in thread
From: meyering @ 2008-06-13 12:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	meyering@sourceware.org	2008-06-13 12:15:55

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Don't deref uninitialized log_lv upon failed mirror addition.
	
	* mirror.c (add_mirror_images): Ensure that log_lv is initialized.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.902&r2=1.903
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.71&r2=1.72

--- LVM2/WHATS_NEW	2008/06/13 07:44:14	1.902
+++ LVM2/WHATS_NEW	2008/06/13 12:15:55	1.903
@@ -1,10 +1,11 @@
 Version 2.02.39 -
 ================================
+  Fix add_mirror_images not to dereference uninitialized log_lv upon failure.
   Don't call openlog for every debug line output by clvmd.
   Add --force to lvextend and lvresize.
   Fix vgchange to not activate mirror leg and log volumes directly.
   Fix test directory clean up in make distclean.
- 
+
 Version 2.02.38 - 11th June 2008
 ================================
   Fix tracking of validity of PVs with no mdas in lvmcache.
--- LVM2/lib/metadata/mirror.c	2008/04/07 10:23:46	1.71
+++ LVM2/lib/metadata/mirror.c	2008/06/13 12:15:55	1.72
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -1344,7 +1344,8 @@
 	struct alloc_handle *ah;
 	const struct segment_type *segtype;
 	struct list *parallel_areas;
-	struct logical_volume **img_lvs, *log_lv;
+	struct logical_volume **img_lvs;
+	struct logical_volume *log_lv = NULL;
 
 	if (stripes > 1) {
 		log_error("stripes > 1 is not supported");
@@ -1416,8 +1417,8 @@
 	return 1;
 
   out_remove_log:
-	if (!lv_remove(log_lv) || !vg_write(log_lv->vg) ||
-	    (backup(log_lv->vg), !vg_commit(log_lv->vg)))
+	if (log_lv && (!lv_remove(log_lv) || !vg_write(log_lv->vg) ||
+		       (backup(log_lv->vg), !vg_commit(log_lv->vg))))
 		log_error("Manual intervention may be required to remove "
 			  "abandoned log LV before retrying.");
 


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2008-02-22 13:28 agk
  0 siblings, 0 replies; 29+ messages in thread
From: agk @ 2008-02-22 13:28 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-02-22 13:28:29

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix resetting of MIRROR_IMAGE and VISIBLE_LV after removal of LV.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.797&r2=1.798
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70

--- LVM2/WHATS_NEW	2008/02/22 13:22:44	1.797
+++ LVM2/WHATS_NEW	2008/02/22 13:28:29	1.798
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Fix resetting of MIRROR_IMAGE and VISIBLE_LV after removal of LV. (2.02.30)
   Fix remove_layer_from_lv to empty the LV before removing it. (2.02.30)
   Add missing no-longer-used segs_using_this_lv test to check_lv_segments.
   Remove redundant non-NULL tests before calling free in clvmd.c.
--- LVM2/lib/metadata/mirror.c	2008/01/31 12:19:35	1.69
+++ LVM2/lib/metadata/mirror.c	2008/02/22 13:28:29	1.70
@@ -504,6 +504,8 @@
 	 * to remove the layer. */
 	if (new_area_count == 1 && !is_temporary_mirror_layer(lv)) {
 		lv1 = seg_lv(mirrored_seg, 0);
+		lv1->status &= ~MIRROR_IMAGE;
+		lv1->status |= VISIBLE_LV;
 		detached_log_lv = detach_mirror_log(mirrored_seg);
 		if (!remove_layer_from_lv(lv, lv1))
 			return_0;


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2007-11-22 13:57 agk
  0 siblings, 0 replies; 29+ messages in thread
From: agk @ 2007-11-22 13:57 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-11-22 13:57:21

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Start refactoring pvmove allocation code.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.739&r2=1.740
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45

--- LVM2/WHATS_NEW	2007/11/16 21:16:20	1.739
+++ LVM2/WHATS_NEW	2007/11/22 13:57:20	1.740
@@ -1,5 +1,6 @@
 Version 2.02.29 -
 ==================================
+  Refactor pvmove allocation code.
   Decode cluster locking state in log message.
   Change file locking state messages from debug to very verbose.
   Fix --addtag to drop @ prefix from name.
--- LVM2/lib/metadata/mirror.c	2007/10/12 14:29:32	1.44
+++ LVM2/lib/metadata/mirror.c	2007/11/22 13:57:21	1.45
@@ -532,6 +532,37 @@
 	return lv_add_more_mirrored_areas(lv, img_lvs, num_mirrors, 0);
 }
 
+static int _alloc_and_insert_pvmove_seg(struct logical_volume *lv_mirr,
+					struct lv_segment *seg, uint32_t s,
+					struct list *allocatable_pvs,
+					alloc_policy_t alloc,
+					const struct segment_type *segtype)
+{
+	struct physical_volume *pv = seg_pv(seg, s);
+	uint32_t start_le = lv_mirr->le_count;
+	uint32_t pe = seg_pe(seg, s);
+
+	log_very_verbose("Moving %s:%u-%u of %s/%s", pv_dev_name(pv),
+			 pe, pe + seg->area_len - 1,
+			 seg->lv->vg->name, seg->lv->name);
+
+	release_lv_segment_area(seg, s, seg->area_len);
+
+	if (!lv_extend(lv_mirr, segtype, 1,
+	       	seg->area_len, 0u, seg->area_len,
+	       	pv, pe,
+	       	PVMOVE, allocatable_pvs,
+	       	alloc)) {
+		log_error("Unable to allocate "
+			  "temporary LV for pvmove.");
+		return 0;
+	}
+
+	set_lv_segment_area_lv(seg, s, lv_mirr, start_le, 0);
+
+	return 1;
+}
+
 /* 
  * Replace any LV segments on given PV with temporary mirror.
  * Returns list of LVs changed.
@@ -547,10 +578,8 @@
 	struct lv_segment *seg;
 	struct lv_list *lvl;
 	struct pv_list *pvl;
-	struct physical_volume *pv;
-	uint32_t pe;
 	int lv_used = 0;
-	uint32_t s, start_le, extent_count = 0u;
+	uint32_t s, extent_count = 0u;
 	const struct segment_type *segtype;
 	struct pe_range *per;
 	uint32_t pe_start, pe_end, per_end, stripe_multiplier;
@@ -648,27 +677,11 @@
 					lv_used = 1;
 				}
 	
-				pv = seg_pv(seg, s);
-				pe = seg_pe(seg, s);
-				log_very_verbose("Moving %s:%u-%u of %s/%s",
-						 pv_dev_name(pvl->pv),
-						 pe, pe + seg->area_len - 1,
-						 lv->vg->name, lv->name);
-
-				start_le = lv_mirr->le_count;
-				/* FIXME Clean this up */
-				release_lv_segment_area(seg, s, seg->area_len);
-				if (!lv_extend(lv_mirr, segtype, 1,
-				       	seg->area_len, 0u, seg->area_len,
-				       	pv, pe,
-				       	PVMOVE, allocatable_pvs,
-				       	alloc)) {
-					log_error("Unable to allocate "
-						  "temporary LV for pvmove.");
-					return 0;
-				}
-				set_lv_segment_area_lv(seg, s, lv_mirr, start_le, 0);
-	
+				if (!_alloc_and_insert_pvmove_seg(lv_mirr, seg, s,
+								  allocatable_pvs,
+								  alloc, segtype))
+					return_0;
+
 				extent_count += seg->area_len;
 	
 				lv->status |= LOCKED;


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2006-11-30 17:52 agk
  0 siblings, 0 replies; 29+ messages in thread
From: agk @ 2006-11-30 17:52 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-11-30 17:52:47

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix mirror segment removal to use temporary error segment.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.510&r2=1.511
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37

--- LVM2/WHATS_NEW	2006/11/30 13:19:42	1.510
+++ LVM2/WHATS_NEW	2006/11/30 17:52:47	1.511
@@ -1,5 +1,6 @@
 Version 2.02.16 -
 ====================================
+  Fix mirror segment removal to use temporary error segment.
   Always compile debug logging into clvmd.
   Add startup timeout to RHEL4 clvmd startup script.
   Add -T (startup timeout) switch to clvmd.
--- LVM2/lib/metadata/mirror.c	2006/11/10 20:15:10	1.36
+++ LVM2/lib/metadata/mirror.c	2006/11/30 17:52:47	1.37
@@ -84,6 +84,7 @@
 			 struct list *removable_pvs, int remove_log)
 {
 	uint32_t m;
+	uint32_t extents;
 	uint32_t s, s1;
 	struct logical_volume *sub_lv;
 	struct logical_volume *log_lv = NULL;
@@ -95,6 +96,7 @@
 	struct pv_list *pvl;
 	uint32_t old_area_count = mirrored_seg->area_count;
 	uint32_t new_area_count = mirrored_seg->area_count;
+	struct segment_type *segtype;
 
 	log_very_verbose("Reducing mirror set from %" PRIu32 " to %"
 			 PRIu32 " image(s)%s.",
@@ -156,9 +158,14 @@
 	/* If no more mirrors, remove mirror layer */
 	if (num_mirrors == 1) {
 		lv1 = seg_lv(mirrored_seg, 0);
+		extents = lv1->le_count;
 		_move_lv_segments(mirrored_seg->lv, lv1);
 		mirrored_seg->lv->status &= ~MIRRORED;
 		remove_log = 1;
+		/* Replace mirror with error segment */
+		segtype = get_segtype_from_string(mirrored_seg->lv->vg->cmd, "error");
+		if (!lv_add_virtual_segment(lv1, 0, extents, segtype))
+			return_0;
 	}
 
 	if (remove_log && mirrored_seg->log_lv) {
@@ -174,8 +181,6 @@
 	 * then deactivate and remove them fully.
 	 */
 
-	/* FIXME lv1 has no segments here so shouldn't be written to disk! */
-
 	if (!vg_write(mirrored_seg->lv->vg)) {
 		log_error("intermediate VG write failed.");
 		return 0;


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2006-11-10 19:35 agk
  0 siblings, 0 replies; 29+ messages in thread
From: agk @ 2006-11-10 19:35 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-11-10 19:35:03

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix adjusted_mirror_region_size() for 64-bit size.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.492&r2=1.493
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35

--- LVM2/WHATS_NEW	2006/11/10 18:24:11	1.492
+++ LVM2/WHATS_NEW	2006/11/10 19:35:02	1.493
@@ -1,6 +1,7 @@
 Version 2.02.14 - 
 ===================================
-  Add some missing bounds checks on 32 bit extent counters.
+  Fix adjusted_mirror_region_size() to handle 64-bit size.
+  Add some missing bounds checks on 32-bit extent counters.
   Add Petabyte and Exabyte support.
   Fix lvcreate error message when 0 extents requested.
   lvremove man page: volumes must be cluster inactive before being removed.
--- LVM2/lib/metadata/mirror.c	2006/10/18 18:01:52	1.34
+++ LVM2/lib/metadata/mirror.c	2006/11/10 19:35:03	1.35
@@ -36,20 +36,20 @@
 }
 
 /*
- * Ensure region size is compatible with volume size.
+ * Reduce the region size if necessary to ensure
+ * the volume size is a multiple of the region size.
  */
 uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
 				     uint32_t region_size)
 {
-	uint32_t region_max;
+	uint64_t region_max;
 
 	region_max = (1 << (ffs((int)extents) - 1)) * extent_size;
 
-	if (region_max < region_size) {
-		region_size = region_max;
+	if (region_max < UINT32_MAX && region_size > region_max) {
+		region_size = (uint32_t) region_max;
 		log_print("Using reduced mirror region size of %" PRIu32
-			  " sectors", region_max);
-		return region_max;
+			  " sectors", region_size);
 	}
 
 	return region_size;


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c
@ 2006-07-20 20:37 agk
  0 siblings, 0 replies; 29+ messages in thread
From: agk @ 2006-07-20 20:37 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-07-20 20:37:10

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 

Log message:
	Fix locking for mimage removal.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.412&r2=1.413
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31

--- LVM2/WHATS_NEW	2006/07/19 18:55:58	1.412
+++ LVM2/WHATS_NEW	2006/07/20 20:37:09	1.413
@@ -1,5 +1,6 @@
 Version 2.02.08 - 
 ================================
+  Fix locking for mimage removal.
   Fix clvmd_init_rhel4 'status' exit code.
 
 Version 2.02.07 - 17th July 2006
--- LVM2/lib/metadata/mirror.c	2006/05/12 19:47:40	1.30
+++ LVM2/lib/metadata/mirror.c	2006/07/20 20:37:10	1.31
@@ -199,6 +199,12 @@
 
 	/* Delete the 'orphan' LVs */
 	for (m = num_mirrors; m < old_area_count; m++) {
+		/* LV is now independent of the mirror so must acquire lock. */
+		if (!activate_lv(mirrored_seg->lv->vg->cmd, seg_lv(mirrored_seg, m))) {
+			stack;
+			return 0;
+		}
+
 		if (!deactivate_lv(mirrored_seg->lv->vg->cmd, seg_lv(mirrored_seg, m))) {
 			stack;
 			return 0;
@@ -211,6 +217,11 @@
 	}
 
 	if (lv1) {
+		if (!activate_lv(mirrored_seg->lv->vg->cmd, lv1)) {
+			stack;
+			return 0;
+		}
+
 		if (!deactivate_lv(mirrored_seg->lv->vg->cmd, lv1)) {
 			stack;
 			return 0;
@@ -223,6 +234,11 @@
 	}
 
 	if (log_lv) {
+		if (!activate_lv(mirrored_seg->lv->vg->cmd, log_lv)) {
+			stack;
+			return 0;
+		}
+
 		if (!deactivate_lv(mirrored_seg->lv->vg->cmd, log_lv)) {
 			stack;
 			return 0;


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

end of thread, other threads:[~2012-03-23 16:28 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-25 13:17 LVM2 ./WHATS_NEW lib/metadata/mirror.c jbrassow
  -- strict thread matches above, loose matches on Subject: below --
2012-03-23 16:28 mbroz
2012-02-01 13:50 zkabelac
2011-10-06 14:49 jbrassow
2011-09-14  2:45 jbrassow
2011-09-13 21:13 jbrassow
2011-09-13 14:37 jbrassow
2011-09-13 13:59 jbrassow
2011-09-01 19:22 jbrassow
2011-06-17 14:27 zkabelac
2010-08-16 18:02 jbrassow
2010-07-13 22:24 jbrassow
2010-07-13 21:48 jbrassow
2010-07-09 15:08 jbrassow
2010-06-28 14:19 jbrassow
2010-06-21 16:12 jbrassow
2010-04-27 15:27 jbrassow
2010-04-27 14:57 jbrassow
2009-12-09 19:53 mbroz
2009-12-09 18:09 mbroz
2009-04-10  9:53 mbroz
2008-10-17 10:50 agk
2008-09-18 19:09 agk
2008-06-13 12:15 meyering
2008-02-22 13:28 agk
2007-11-22 13:57 agk
2006-11-30 17:52 agk
2006-11-10 19:35 agk
2006-07-20 20:37 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).