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

[lvm-devel] [PATCH lvconvert 7/11] Fix semantic consistency of mirrorlog option



'--mirrorlog'/'--corelog' options of lvconvert are used to
add/remove disklog of mirrored LV.
However, it had different meanings for "adding mirrors to mirror",
i.e. the options specify whether to use disklog for conversion.
The patch corrects it.

-- 
Jun'ichi Nomura, NEC Corporation of America
'lvconvert -m+1 --mirrorlog core' will:
  (a) convert linear LV to 2-way mirror LV with *corelog*
  (b) convert 2-way mirror LV with disklog to 3-way mirror LV with *disklog*

For (a), '--mirrorlog core' means the final LV has corelog.
For (b), '--mirrorlog core' means the temporary LV has corelog.
So it's not consistent.
The problem was introduced because I tried to interpret --mirrorlog/--corelog
option for the log type of conversion layer.

It seems reasonable to apply the same semantics as (a) for (b):
i.e. lvconvert should take the options for the end result
(i.e. the LV after conversion).

Index: LVM2.work/tools/lvconvert.c
===================================================================
--- LVM2.work.orig/tools/lvconvert.c
+++ LVM2.work/tools/lvconvert.c
@@ -513,20 +513,37 @@ static int lvconvert_mirrors(struct cmd_
 				  "without initial resync");
 			return 0;
 		}
-		/* FIXME: can't have multiple mlogs. force corelog. */
-		corelog = 1;
+		/*
+		 * Log addition/removal should be done before the layer
+		 * insertion to make the end result consistent with
+		 * linear-to-mirror conversion.
+		 */
+		if (!seg->log_lv && !corelog) {
+			if (!add_mirror_log(cmd, lv, 1,
+					    adjusted_mirror_region_size(
+							lv->vg->extent_size,
+							lv->le_count,
+							lp->region_size),
+					    lp->pvh, lp->alloc))
+				return_0;
+		} else if (seg->log_lv && corelog) {
+			if (!remove_mirror_log(cmd, lv,
+					       lp->pv_count ? lp->pvh : NULL))
+				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)) {
 			log_error("Failed to insert resync layer");
 			return 0;
 		}
+		/* FIXME: can't have multiple mlogs. force corelog. */
 		if (!lv_add_mirrors(cmd, lv, lp->mirrors - existing_mirrors, 1,
 				    adjusted_mirror_region_size(
 						lv->vg->extent_size,
 						lv->le_count,
 						lp->region_size),
-				    corelog ? 0U : 1U, lp->pvh, lp->alloc,
+				    0U, lp->pvh, lp->alloc,
 				    MIRROR_BY_LV))
 			return_0;
 		lp->wait_daemon = 1;

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