public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/metadata/mirror.c tools/l ...
@ 2010-08-06 15:38 jbrassow
  0 siblings, 0 replies; 7+ messages in thread
From: jbrassow @ 2010-08-06 15:38 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-08-06 15:38:33

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

Log message:
	Fix for bug 619221 - log device splitting regression
	
	An incorrect fix on July 13, 2010 for an annoyance has caused a regression.
	The offending check-in was part of the 2.02.71 release of LVM.  That
	check-in caused any PVs specified on the command line to be ignored when
	performing a mirror split.
	
	This patch reverses the aforementioned check-in (solving the regressions)
	and posits a new solution to the list reversal problem.  The original
	problem was that we would always take the lowest mimage LVs from a mirror
	when performing a split, but what we really want is to take the highest
	mimage LVs.  This patch accomplishes that by working through the list in
	reverse order - choosing the higher numbered mimages first.  (This also
	reduces the amount of processing necessary.)
	
	Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
	Reviewed-by: Takahiro Yasui <takahiro.yasui@hds.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1696&r2=1.1697
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.130&r2=1.131
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.144&r2=1.145

--- LVM2/WHATS_NEW	2010/08/04 18:18:18	1.1696
+++ LVM2/WHATS_NEW	2010/08/06 15:38:32	1.1697
@@ -1,5 +1,6 @@
 Version 2.02.73 - 
 ================================
+  Split-mirror operations were ignoring user-specified PVs.
   Fix data corruption bug in cluster mirrors.
   Require logical volume(s) to be explicitly named for lvconvert --merge.
   Avoid changing aligned pe_start as a side-effect of very verbose logging.
--- LVM2/lib/metadata/mirror.c	2010/08/02 21:07:41	1.130
+++ LVM2/lib/metadata/mirror.c	2010/08/06 15:38:32	1.131
@@ -524,34 +524,22 @@
 					  uint32_t count,
 					  struct dm_list *removable_pvs)
 {
-	int i, images;
+	int i;
 	struct logical_volume *sub_lv;
 	struct lv_segment *mirrored_seg = first_seg(lv);
 
 	if (!removable_pvs)
 		return 1;
 
-	/*
-	 * When we shift an image to the end, we must start from
-	 * the begining of the list again.  We must visit the
-	 * images up to the last one we just moved.
-	 */
-	for (images = mirrored_seg->area_count; images && count; images--) {
-		for (i = 0; i < images; i++) {
-			sub_lv = seg_lv(mirrored_seg, i);
-
-			if (!is_temporary_mirror_layer(sub_lv) &&
-			    is_mirror_image_removable(sub_lv, removable_pvs)) {
-				if (!shift_mirror_images(mirrored_seg, i))
-					return_0;
-				count--;
-				break;
-			}
-		}
+	for (i = mirrored_seg->area_count - 1; (i >= 0) && count; i--) {
+		sub_lv = seg_lv(mirrored_seg, i);
 
-		/* Did we shift any images? */
-		if (i == images)
-			return 0;
+		if (!is_temporary_mirror_layer(sub_lv) &&
+		    is_mirror_image_removable(sub_lv, removable_pvs)) {
+			if (!shift_mirror_images(mirrored_seg, i))
+				return_0;
+			count--;
+		}
 	}
 
 	return !count;
--- LVM2/tools/lvconvert.c	2010/08/03 20:22:31	1.144
+++ LVM2/tools/lvconvert.c	2010/08/06 15:38:32	1.145
@@ -1015,7 +1015,7 @@
 						  lv->le_count,
 						  lp->region_size);
 
-	if (!operable_pvs && !lp->keep_mimages)
+	if (!operable_pvs)
 		operable_pvs = lp->pvh;
 
 	seg = first_seg(lv);


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

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

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

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

Log message:
	Taka's fix for handling failure of all mirrored log devices and
	all but one mirror leg.
	
	<patch header>
	To handle a double failure of a mirrored log, Jon's two patches are
	commited, however, lvconvert command can't still handle an error
	when mirror leg and mirrored log got failure at the same time.
	
	[Patch]: Handle both devices of a mirrored log failing (bug 607347)
	posted: https://www.redhat.com/archives/lvm-devel/2010-July/msg00009.html
	commit: https://www.redhat.com/archives/lvm-devel/2010-July/msg00027.html
	
	[Patch]: Handle both devices of a mirrored log failing (bug 607347) -
	additional fix
	posted: https://www.redhat.com/archives/lvm-devel/2010-July/msg00093.html
	commit: https://www.redhat.com/archives/lvm-devel/2010-July/msg00101.html
	
	In the second patch, the target type of mirrored log is replaced with
	error target when remove_log is set to 1, but this procedure should be
	also used in other cases such as the number of mirror leg is 1. This
	patch relocates the procedure to the main path.
	
	In addition, I added following three changes.
	
	- Removed tmp_orphan_lvs handling procedure
	It seems that _delete_lv() can handle detached_log_lv properly
	without adding mirror legs in mirrored log to tmp_orphan_lvs.
	Therefore, I removed the procedure.
	
	- Removed vg_write()/vg_commit()
	Metadata is saved by vg_write()/vg_commit() just after detached_log_lv
	is handled. Therefore, I removed vg_write()/vg_commit().
	
	- With Jon's second patch, we think that we don't have to call
	remove_mirror_log() in _lv_update_mirrored_log() because will be
	handled remove_mirror_images() in _lvconvert_mirrors_repaire().
	</patch header>
	
	Signed-off-by: Takahiro Yasui <takahiro.yasui@hds.com>
	Reviewed-by: Petr Rockai <prockai@redhat.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.1687&r2=1.1688
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.129&r2=1.130
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143

--- LVM2/WHATS_NEW	2010/08/02 19:03:45	1.1687
+++ LVM2/WHATS_NEW	2010/08/02 21:07:40	1.1688
@@ -1,5 +1,6 @@
 Version 2.02.73 - 
 ================================
+  Handle failure of all mirrored log devices and all but one mirror leg. 
   Disallow 'mirrored' log type for cluster mirrors.
   Do not use VPATH in include/Makefile.
   Fix exported_symbols generation to use standard compiler arguments.
--- LVM2/lib/metadata/mirror.c	2010/08/02 19:03:45	1.129
+++ LVM2/lib/metadata/mirror.c	2010/08/02 21:07:41	1.130
@@ -902,71 +902,47 @@
 		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 (detached_log_lv && lv_is_mirrored(detached_log_lv) &&
+	    (detached_log_lv->status & PARTIAL_LV)) {
+		log_very_verbose("%s being removed due to failures",
+				 detached_log_lv->name);
+
+		if (!replace_lv_with_error_segment(detached_log_lv)) {
+			log_error("Failed error target substitution for %s",
+				  detached_log_lv->name);
+			return 0;
+		}
+
 		/*
-		 * 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.
+		 * Flush all I/Os held by mirrored log.
 		 */
-		if (detached_log_lv && 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)))) {
-					log_error("dm_pool_alloc failed");
-					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 (!suspend_lv(detached_log_lv->vg->cmd,
+				detached_log_lv)) {
+			log_error("Failed to suspend %s",
+				  detached_log_lv->name);
+			return 0;
+ 		}
 
-			if (!resume_lv(detached_log_lv->vg->cmd,
-				       detached_log_lv))
-					return_0;
+		if (!resume_lv(detached_log_lv->vg->cmd,
+			       detached_log_lv)) {
+			log_error("Failed to resume %s",
+				  detached_log_lv->name);
+			return_0;
 		}
 	}
 
--- LVM2/tools/lvconvert.c	2010/08/02 19:03:45	1.142
+++ LVM2/tools/lvconvert.c	2010/08/02 21:07:41	1.143
@@ -696,6 +696,13 @@
 	int old_log_count;
 	struct logical_volume *log_lv;
 
+	/*
+	 * When log_count is 0, mirrored log doesn't need to be
+	 * updated here but it will be removed later.
+	 */
+	if (!log_count)
+		return 1;
+
 	log_lv = first_seg(_original_lv(lv))->log_lv;
 	if (!log_lv || !(log_lv->status & MIRRORED))
 		return 1;
@@ -705,12 +712,9 @@
 		return 1;
 
 	/* Reducing redundancy of the log */
-	if (log_count)
-		return remove_mirror_images(log_lv, log_count,
-					    is_mirror_image_removable,
-					    operable_pvs, 0U);
-
-	return remove_mirror_log(lv->vg->cmd, lv, operable_pvs);
+	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,


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-08-02 19:03:46

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

Log message:
	Disallow mirrored logs in cluster mirrors.
	
	The cluster log daemon (cmirrord) is not multi-threaded and
	can handle only one request at a time.  When a log is stacked
	on top of a mirror (which itself contains a 'core' log), it
	creates a situation that cannot be solved without threading.
	
	When the top level mirror issues a "resume", the log daemon
	attempts to read from the log device to retrieve the log
	state.  However, the log is a mirror which, before issuing
	the read, attempts to determine the 'sync' status of the
	region of the mirror which is to be read.  This sync status
	request cannot be completed by the daemon because it is
	blocked on a read I/O to the very mirror requesting the
	sync status.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1686&r2=1.1687
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.128&r2=1.129
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.141&r2=1.142

--- LVM2/WHATS_NEW	2010/08/02 13:56:35	1.1686
+++ LVM2/WHATS_NEW	2010/08/02 19:03:45	1.1687
@@ -1,5 +1,6 @@
 Version 2.02.73 - 
 ================================
+  Disallow 'mirrored' log type for cluster mirrors.
   Do not use VPATH in include/Makefile.
   Fix exported_symbols generation to use standard compiler arguments.
   Use #include <> not "" in lvm2app.h which gets installed on the system.
--- LVM2/lib/metadata/mirror.c	2010/07/21 13:40:22	1.128
+++ LVM2/lib/metadata/mirror.c	2010/08/02 19:03:45	1.129
@@ -1970,10 +1970,21 @@
 		return 0;
 	}
 
-	if (vg_is_clustered(lv->vg) &&  !(lv->status & ACTIVATE_EXCL) &&
-	    !cluster_mirror_is_available(lv)) {
-		log_error("Shared cluster mirrors are not available.");
-		return 0;
+	if (vg_is_clustered(lv->vg)) {
+		if (!(lv->status & ACTIVATE_EXCL) &&
+		    !cluster_mirror_is_available(lv)) {
+			log_error("Shared cluster mirrors are not available.");
+			return 0;
+		}
+
+		/*
+		 * No mirrored logs for cluster mirrors until
+		 * log daemon is multi-threaded.
+		 */
+		if (log_count > 1) {
+			log_error("Log type, \"mirrored\", is unavailable to cluster mirrors");
+			return 0;
+		}
 	}
 
 	/* For corelog mirror, activation code depends on
--- LVM2/tools/lvconvert.c	2010/07/30 17:50:16	1.141
+++ LVM2/tools/lvconvert.c	2010/08/02 19:03:45	1.142
@@ -919,6 +919,15 @@
 		return 0;
 	}
 
+	/*
+	 * No mirrored logs for cluster mirrors until
+	 * log daemon is multi-threaded.
+	 */
+	if ((*new_log_count == 2) && vg_is_clustered(lv->vg)) {
+		log_error("Log type, \"mirrored\", is unavailable to cluster mirrors");
+		return 0;
+	}
+
 	log_verbose("Setting logging type to %s", mirrorlog);
 
 	/*


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c tools/l ...
@ 2008-06-26 23:05 agk
  0 siblings, 0 replies; 7+ messages in thread
From: agk @ 2008-06-26 23:05 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-06-26 23:05:11

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

Log message:
	Update validation of safe mirror log type conversions in lvconvert. (brassow)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.918&r2=1.919
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66

--- LVM2/WHATS_NEW	2008/06/26 21:38:57	1.918
+++ LVM2/WHATS_NEW	2008/06/26 23:05:10	1.919
@@ -1,5 +1,6 @@
 Version 2.02.39 -
 ================================
+  Update validation of safe mirror log type conversions in lvconvert.
   Fix lvconvert to disallow snapshot and mirror combinations.
   Fix reporting of LV fields alongside unallocated PV segments.
   Add --unquoted and --rows to reporting tools.
--- LVM2/lib/metadata/mirror.c	2008/06/13 12:15:55	1.72
+++ LVM2/lib/metadata/mirror.c	2008/06/26 23:05:11	1.73
@@ -1140,6 +1140,8 @@
 		      struct list *removable_pvs)
 {
 	float sync_percent;
+	struct lvinfo info;
+	struct volume_group *vg = lv->vg;
 
 	/* Unimplemented features */
 	if (list_size(&lv->segments) != 1) {
@@ -1148,10 +1150,21 @@
 	}
 
 	/* Had disk log, switch to core. */
-	if (!lv_mirror_percent(cmd, lv, 0, &sync_percent, NULL)) {
-		log_error("Unable to determine mirror sync status.");
+	if (lv_info(cmd, lv, &info, 0, 0) && info.exists) {
+		if (!lv_mirror_percent(cmd, lv, 0, &sync_percent, NULL)) {
+			log_error("Unable to determine mirror sync status.");
+			return 0;
+		}
+	} else if (vg_is_clustered(vg)) {
+		log_error("Unable to convert the log of inactive "
+			  "cluster mirror %s", lv->name);
+		return 0;
+	} else if (yes_no_prompt("Full resync required to convert "
+				 "inactive mirror %s to core log. "
+				 "Proceed? [y/n]: "))
+		sync_percent = 0;
+	else
 		return 0;
-	}
 
 	if (sync_percent >= 100.0)
 		init_mirror_in_sync(1);
@@ -1269,12 +1282,9 @@
 	return add_seg_to_segs_using_this_lv(log_lv, seg);
 }
 
-int add_mirror_log(struct cmd_context *cmd,
-		   struct logical_volume *lv,
-		   uint32_t log_count,
-		   uint32_t region_size,
-		   struct list *allocatable_pvs,
-		   alloc_policy_t alloc)
+int add_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
+		   uint32_t log_count, uint32_t region_size,
+		   struct list *allocatable_pvs, alloc_policy_t alloc)
 {
 	struct alloc_handle *ah;
 	const struct segment_type *segtype;
@@ -1282,17 +1292,31 @@
 	float sync_percent;
 	int in_sync;
 	struct logical_volume *log_lv;
+	struct lvinfo info;
 
 	/* Unimplemented features */
 	if (log_count > 1) {
 		log_error("log_count > 1 is not supported");
 		return 0;
 	}
+
 	if (list_size(&lv->segments) != 1) {
 		log_error("Multiple-segment mirror is not supported");
 		return 0;
 	}
 
+	/*
+	 * We are unable to convert the log of inactive cluster mirrors
+	 * due to the inability to detect whether the mirror is active
+	 * on remote nodes (even though it is inactive on this node)
+	 */
+	if (vg_is_clustered(lv->vg) &&
+	    !(lv_info(cmd, lv, &info, 0, 0) && info.exists)) {
+		log_error("Unable to convert the log of inactive "
+			  "cluster mirror %s", lv->name);
+		return 0;
+	}
+
 	if (!(parallel_areas = build_parallel_areas_from_lv(cmd, lv)))
 		return_0;
 
--- LVM2/tools/lvconvert.c	2008/06/26 21:38:58	1.65
+++ LVM2/tools/lvconvert.c	2008/06/26 23:05:11	1.66
@@ -508,6 +508,9 @@
 	}
 
 	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,


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c tools/l ...
@ 2007-03-26 16:10 mbroz
  0 siblings, 0 replies; 7+ messages in thread
From: mbroz @ 2007-03-26 16:10 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2007-03-26 17:10:11

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : mirror.c 
	tools          : lvconvert.c lvcreate.c toollib.c toollib.h 

Log message:
	Fix creation and conversion of mirrors with tags.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.591&r2=1.592
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.133&r2=1.134
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.h.diff?cvsroot=lvm2&r1=1.45&r2=1.46

--- LVM2/WHATS_NEW	2007/03/23 12:43:17	1.591
+++ LVM2/WHATS_NEW	2007/03/26 16:10:09	1.592
@@ -1,5 +1,6 @@
 Version 2.02.25 -
 =================================
+  Fix creation and conversion of mirrors with tags.
   Fix vgsplit for lvm1 format (set and validate VG name in PVs metadata).
   Split metadata areas in vgsplit properly.
 
--- LVM2/lib/metadata/mirror.c	2006/11/30 17:52:47	1.37
+++ LVM2/lib/metadata/mirror.c	2007/03/26 16:10:10	1.38
@@ -21,6 +21,7 @@
 #include "activate.h"
 #include "lv_alloc.h"
 #include "lvm-string.h"
+#include "str_list.h"
 #include "locking.h"	/* FIXME Should not be used in this file */
 
 #include "defaults.h" /* FIXME: should this be defaults.h? */
@@ -77,6 +78,42 @@
 	lv_from->size = 0;
 }
 
+
+/*
+ * Delete independent/orphan LV, it must acquire lock.
+ */
+static int _delete_lv(struct lv_segment *mirrored_seg, struct logical_volume *lv)
+{
+	struct cmd_context *cmd = mirrored_seg->lv->vg->cmd;
+	struct str_list *sl;
+
+	/* Inherit tags - maybe needed for activation */
+	if (!str_list_match_list(&mirrored_seg->lv->tags, &lv->tags)) {
+		list_iterate_items(sl, &mirrored_seg->lv->tags)
+			if (!str_list_add(cmd->mem, &lv->tags, sl->str)) {
+				log_error("Aborting. Unable to tag.");
+				return 0;
+			}
+
+		if (!vg_write(mirrored_seg->lv->vg) ||
+		    !vg_commit(mirrored_seg->lv->vg)) {
+			log_error("Intermediate VG commit for orphan volume failed.");
+			return 0;
+		}
+	}
+
+	if (!activate_lv(cmd, lv))
+		return_0;
+
+	if (!deactivate_lv(cmd, lv))
+		return_0;
+
+	if (!lv_remove(lv))
+		return_0;
+
+	return 1;
+}
+
 /*
  * Reduce mirrored_seg to num_mirrors images.
  */
@@ -205,57 +242,15 @@
 	}
 
 	/* 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;
-		}
-
-		if (!lv_remove(seg_lv(mirrored_seg, m))) {
-			stack;
-			return 0;
-		}
-	}
-
-	if (lv1) {
-		if (!activate_lv(mirrored_seg->lv->vg->cmd, lv1)) {
-			stack;
-			return 0;
-		}
-
-		if (!deactivate_lv(mirrored_seg->lv->vg->cmd, lv1)) {
-			stack;
+	for (m = num_mirrors; m < old_area_count; m++)
+		if (!_delete_lv(mirrored_seg, seg_lv(mirrored_seg, m)))
 			return 0;
-		}
-
-		if (!lv_remove(lv1)) {
-			stack;
-			return 0;
-		}
-	}
 
-	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;
-		}
+	if (lv1 && !_delete_lv(mirrored_seg, lv1))
+		return 0;
 
-		if (!lv_remove(log_lv)) {
-			stack;
-			return 0;
-		}
-	}
+	if (log_lv && !_delete_lv(mirrored_seg, log_lv))
+		return 0;
 
 	return 1;
 }
--- LVM2/tools/lvconvert.c	2007/01/10 14:13:46	1.25
+++ LVM2/tools/lvconvert.c	2007/03/26 16:10:10	1.26
@@ -307,7 +307,7 @@
 					if (!(log_lv = create_mirror_log(cmd, lv->vg, ah,
 									 lp->alloc, lv->name,
 									 (sync_percent >= 100.0) ?
-									 1 : 0))) {
+									 1 : 0, &lv->tags))) {
 						log_error("Failed to create mirror log.");
 						return 0;
 					}
@@ -385,7 +385,7 @@
 			if (!arg_count(cmd, corelog_ARG) &&
 			    !(log_lv = create_mirror_log(cmd, lv->vg, ah,
 							 lp->alloc,
-							 lv->name, 0))) {
+							 lv->name, 0, &lv->tags))) {
 				log_error("Failed to create mirror log.");
 				return 0;
 			}
--- LVM2/tools/lvcreate.c	2007/03/09 20:47:41	1.133
+++ LVM2/tools/lvcreate.c	2007/03/26 16:10:10	1.134
@@ -476,8 +476,8 @@
 	uint64_t tmp_size;
 	struct volume_group *vg;
 	struct logical_volume *lv, *org = NULL, *log_lv = NULL;
-	struct list *pvh;
-	const char *tag;
+	struct list *pvh, tags;
+	const char *tag = NULL;
 	int consistent = 1;
 	struct alloc_handle *ah = NULL;
 	char lv_name_buf[128];
@@ -675,6 +675,19 @@
 		lv_name = &lv_name_buf[0];
 	}
 
+	if (arg_count(cmd, addtag_ARG)) {
+		if (!(tag = arg_str_value(cmd, addtag_ARG, NULL))) {
+			log_error("Failed to get tag");
+			return 0;
+		}
+
+		if (!(vg->fid->fmt->features & FMT_TAGS)) {
+			log_error("Volume group %s does not support tags",
+				  vg->name);
+			return 0;
+		}
+	}
+
 	if (lp->mirrors > 1) {
 		/* FIXME Calculate how many extents needed for the log */
 
@@ -698,9 +711,13 @@
 			status |= MIRROR_NOTSYNCED;
 		}
 
+		list_init(&tags);
+		if (tag)
+			str_list_add(cmd->mem, &tags, tag);
+
 		if (!lp->corelog &&
 		    !(log_lv = create_mirror_log(cmd, vg, ah, lp->alloc,
-						 lv_name, lp->nosync))) {
+						 lv_name, lp->nosync, &tags))) {
 			log_error("Failed to create mirror log.");
 			return 0;
 		}
@@ -725,23 +742,10 @@
 			    lv->minor);
 	}
 
-	if (arg_count(cmd, addtag_ARG)) {
-		if (!(tag = arg_str_value(cmd, addtag_ARG, NULL))) {
-			log_error("Failed to get tag");
-			goto error;
-		}
-
-		if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
-			log_error("Volume group %s does not support tags",
-				  lv->vg->name);
-			goto error;
-		}
-
-		if (!str_list_add(cmd->mem, &lv->tags, tag)) {
-			log_error("Failed to add tag %s to %s/%s",
-				  tag, lv->vg->name, lv->name);
-			goto error;
-		}
+	if (tag && !str_list_add(cmd->mem, &lv->tags, tag)) {
+		log_error("Failed to add tag %s to %s/%s",
+			  tag, lv->vg->name, lv->name);
+		goto error;
 	}
 
 	if (lp->mirrors > 1) {
--- LVM2/tools/toollib.c	2007/03/09 20:47:41	1.97
+++ LVM2/tools/toollib.c	2007/03/26 16:10:10	1.98
@@ -1310,11 +1310,13 @@
 					 struct alloc_handle *ah,
 					 alloc_policy_t alloc,
 					 const char *lv_name,
-					 int in_sync)
+					 int in_sync,
+					 struct list *tags)
 {
 	struct logical_volume *log_lv;
 	char *log_name;
 	size_t len;
+	struct str_list *sl;
 
 	len = strlen(lv_name) + 32;
 	if (!(log_name = alloca(len)) ||
@@ -1336,6 +1338,13 @@
 		goto error;
 	}
 
+	/* Temporary tag mirror log */
+	list_iterate_items(sl, tags)
+		if (!str_list_add(cmd->mem, &log_lv->tags, sl->str)) {
+			log_error("Aborting. Unable to tag mirror log.");
+			goto error;
+		}
+
 	/* store mirror log on disk(s) */
 	if (!vg_write(vg)) {
 		stack;
@@ -1361,6 +1370,11 @@
 		goto error;
 	}
 
+	list_iterate_items(sl, tags)
+		if (!str_list_del(&log_lv->tags, sl->str))
+			log_error("Failed to remove tag %s from mirror log.",
+				  sl->str);
+
 	if (activation() && !set_lv(cmd, log_lv, log_lv->size,
 				    in_sync ? -1 : 0)) {
 		log_error("Aborting. Failed to wipe mirror log. "
--- LVM2/tools/toollib.h	2007/03/09 20:47:41	1.45
+++ LVM2/tools/toollib.h	2007/03/26 16:10:10	1.46
@@ -100,7 +100,8 @@
 					 struct alloc_handle *ah,
 					 alloc_policy_t alloc,
 					 const char *lv_name,
-					 int in_sync);
+					 int in_sync,
+					 struct list *tags);
 
 int set_lv(struct cmd_context *cmd, struct logical_volume *lv,
 	   uint64_t sectors, int value);


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c tools/l ...
@ 2006-09-19 19:13 agk
  0 siblings, 0 replies; 7+ messages in thread
From: agk @ 2006-09-19 19:13 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-09-19 19:13:41

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

Log message:
	Fix lvconvert mirror change case detection logic.
	Fix mirror log detachment so it correctly becomes a standalone LV.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.438&r2=1.439
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21

--- LVM2/WHATS_NEW	2006/09/11 21:14:55	1.438
+++ LVM2/WHATS_NEW	2006/09/19 19:13:41	1.439
@@ -1,5 +1,7 @@
 Version 2.02.10 - 
 ==================================
+  Fix lvconvert mirror change case detection logic.
+  Fix mirror log detachment so it correctly becomes a standalone LV.
   Extend _check_contiguous() to detect single-area LVs.
   Include mirror log (untested) in _for_each_pv() processing.
   Use MIRROR_LOG_SIZE constant.
--- LVM2/lib/metadata/mirror.c	2006/08/21 12:54:53	1.32
+++ LVM2/lib/metadata/mirror.c	2006/09/19 19:13:41	1.33
@@ -161,9 +161,11 @@
 		remove_log = 1;
 	}
 
-	if (remove_log) {
+	if (remove_log && mirrored_seg->log_lv) {
 		log_lv = mirrored_seg->log_lv;
 		mirrored_seg->log_lv = NULL;
+		log_lv->status &= ~MIRROR_LOG;
+		log_lv->status |= VISIBLE_LV;
 	}
 
 	/*
--- LVM2/tools/lvconvert.c	2006/09/02 01:18:17	1.20
+++ LVM2/tools/lvconvert.c	2006/09/19 19:13:41	1.21
@@ -344,8 +344,7 @@
 						  lp->mirrors - 1);
 					return 1;
 				}
-			}
-			if (lp->mirrors > existing_mirrors) {
+			} else if (lp->mirrors > existing_mirrors) {
 				/* FIXME Unless anywhere, remove PV of log_lv 
 				 * from allocatable_pvs & allocate 
 				 * (mirrors - existing_mirrors) new areas


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

* LVM2 ./WHATS_NEW lib/metadata/mirror.c tools/l ...
@ 2004-05-24 20:51 agk
  0 siblings, 0 replies; 7+ messages in thread
From: agk @ 2004-05-24 20:51 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2004-05-24 20:51:56

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

Log message:
	Additional kernel target checks before pvmove & snapshot creation.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83


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

end of thread, other threads:[~2010-08-06 15:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-06 15:38 LVM2 ./WHATS_NEW lib/metadata/mirror.c tools/l jbrassow
  -- strict thread matches above, loose matches on Subject: below --
2010-08-02 21:07 jbrassow
2010-08-02 19:03 jbrassow
2008-06-26 23:05 agk
2007-03-26 16:10 mbroz
2006-09-19 19:13 agk
2004-05-24 20:51 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).