[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] (rebase, v2) Fix BZ 463272.



Hi,

this didn't get any review/acks last time I posted it. Moreover, it has gotten
out of date due to lvconvert --repair getting through. I am therefore attaching
a new version of the two patches that apply (and work) on top of current CVS.

I also believe that this patch fixes some corner cases in lvconvert --repair
(eg.  when a double failure in a 3-way mirror with disk log takes out one of
the legs and the log).

Yours,
   Petr.

Wed May 20 22:19:39 CEST 2009  Petr Rockai <me mornfall net>
  * Slightly refactor mirror log conversions in lvconvert.
diff -rN -u -p old-upstream/tools/lvconvert.c new-upstream/tools/lvconvert.c
--- old-upstream/tools/lvconvert.c	2009-05-20 22:23:57.136893149 +0200
+++ new-upstream/tools/lvconvert.c	2009-05-20 22:23:57.400892484 +0200
@@ -431,6 +431,33 @@ static struct logical_volume *_original_
 	return next_lv;
 }
 
+static int _using_corelog(struct logical_volume *lv)
+{
+	return !first_seg(_original_lv(lv))->log_lv;
+}
+
+static int _lv_update_log_type(struct cmd_context *cmd,
+			       struct lvconvert_params *lp,
+			       struct logical_volume *lv,
+			       int corelog)
+{
+	struct logical_volume *original_lv = _original_lv(lv);
+	if (_using_corelog(lv) && !corelog) {
+		if (!add_mirror_log(cmd, original_lv, 1,
+				    adjusted_mirror_region_size(
+					lv->vg->extent_size,
+					lv->le_count,
+					lp->region_size),
+				    lp->pvh, lp->alloc))
+			return_0;
+	} else if (!_using_corelog(lv) && corelog) {
+		if (!remove_mirror_log(cmd, original_lv,
+				       lp->pv_count ? lp->pvh : NULL))
+			return_0;
+	}
+	return 1;
+}
+
 static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * lv,
 			     struct lvconvert_params *lp)
 {
@@ -438,7 +465,6 @@ static int lvconvert_mirrors(struct cmd_
 	uint32_t existing_mirrors;
 	const char *mirrorlog;
 	unsigned corelog = 0;
-	struct logical_volume *original_lv;
 	int r = 0;
 	struct logical_volume *log_lv;
 	int failed_mirrors = 0, failed_log = 0;
@@ -615,20 +641,8 @@ static int lvconvert_mirrors(struct cmd_
 		 * insertion to make the end result consistent with
 		 * linear-to-mirror conversion.
 		 */
-		original_lv = _original_lv(lv);
-		if (!first_seg(original_lv)->log_lv && !corelog) {
-			if (!add_mirror_log(cmd, original_lv, 1,
-					    adjusted_mirror_region_size(
-							lv->vg->extent_size,
-							lv->le_count,
-							lp->region_size),
-					    lp->pvh, lp->alloc))
-				return_0;
-		} else if (first_seg(original_lv)->log_lv && corelog) {
-			if (!remove_mirror_log(cmd, original_lv,
-					       lp->pv_count ? lp->pvh : NULL))
-				return_0;
-		}
+		if (!_lv_update_log_type(cmd, lp, lv, corelog))
+			return_0;
 		/* Insert a temporary layer for syncing,
 		 * only if the original lv is using disk log. */
 		if (seg->log_lv && !_insert_lvconvert_layer(cmd, lv)) {
@@ -649,24 +663,10 @@ static int lvconvert_mirrors(struct cmd_
 	}
 
 	if (lp->mirrors == existing_mirrors) {
-		/*
-		 * Convert Mirror log type
-		 */
-		original_lv = _original_lv(lv);
-		if (!first_seg(original_lv)->log_lv && !corelog) {
-			if (!add_mirror_log(cmd, original_lv, 1,
-					    adjusted_mirror_region_size(
-							lv->vg->extent_size,
-							lv->le_count,
-							lp->region_size),
-					    lp->pvh, lp->alloc))
-				return_0;
-		} else if (first_seg(original_lv)->log_lv && corelog) {
-			if (!remove_mirror_log(cmd, original_lv,
-					       lp->pv_count ? lp->pvh : NULL))
+		if (_using_corelog(lv) != corelog) {
+			if (!_lv_update_log_type(cmd, lp, lv, corelog))
 				return_0;
 		} else {
-			/* No change */
 			log_error("Logical volume %s already has %"
 				  PRIu32 " mirror(s).", lv->name,
 				  lp->mirrors - 1);
Wed May 20 22:20:01 CEST 2009  Petr Rockai <me mornfall net>
  * Fix BZ 463272.
diff -rN -u -p old-upstream/test/t-mirror-lvconvert.sh new-upstream/test/t-mirror-lvconvert.sh
--- old-upstream/test/t-mirror-lvconvert.sh	2009-05-20 22:24:26.296888834 +0200
+++ new-upstream/test/t-mirror-lvconvert.sh	2009-05-20 22:24:26.508889730 +0200
@@ -321,3 +321,9 @@ lvconvert -m1 $vg/$lv1
 check_mirror_count_ $vg/$lv1 2
 check_mirror_log_ $vg/$lv1
 check_and_cleanup_lvs_
+
+# BZ 463272: disk log mirror convert option is lost if downconvert option is also given
+prepare_lvs_
+lvcreate -l1 -m2 --corelog -n $lv1 $vg
+lvconvert -m1 --mirrorlog disk $vg/$lv1
+check_mirror_log_ $vg/$lv1
diff -rN -u -p old-upstream/tools/lvconvert.c new-upstream/tools/lvconvert.c
--- old-upstream/tools/lvconvert.c	2009-05-20 22:24:26.296888834 +0200
+++ new-upstream/tools/lvconvert.c	2009-05-20 22:24:26.524888831 +0200
@@ -600,6 +600,9 @@ static int lvconvert_mirrors(struct cmd_
 				       (corelog || lp->mirrors == 1) ? 1U : 0U,
 				       remove_pvs, 0))
 			return_0;
+		if (lp->mirrors > 1 &&
+		    !_lv_update_log_type(cmd, lp, lv, corelog))
+			return_0;
 	} else if (!(lv->status & MIRRORED)) {
 		/*
 		 * Converting from linear to mirror
-- 
Peter Rockai | me()mornfall!net | prockai()redhat!com
 http://blog.mornfall.net | http://web.mornfall.net

"In My Egotistical Opinion, most people's C programs should be
 indented six feet downward and covered with dirt."
     -- Blair P. Houghton on the subject of C program indentation

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]