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

[lvm-devel] [PATCH mirror 8/13] lvconvert to stack a temporary resync mirror on addition



Allow lvconvert to add mirror by inserting a "_resync<n>" layer
and add mirrors to it.

FIXME: Limited to corelog. It'll be fixed with later patches.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
Allow lvconvert to add mirror.

FIXME: Can't create multiple mlogs.

Changes since rev1:
  * Use "_resync" suffix for resync layer
  * Use insert_layer_for_lv() + lv_add_mirror()

Index: LVM2.work/tools/lvconvert.c
===================================================================
--- LVM2.work.orig/tools/lvconvert.c
+++ LVM2.work/tools/lvconvert.c
@@ -369,14 +369,20 @@ static int lvconvert_mirrors(struct cmd_
 			return 1;
 		}
 	} else if (lp->mirrors > existing_mirrors) {
-		/* FIXME Unless anywhere, remove PV of log_lv
-		 * from allocatable_pvs & allocate
-		 * (mirrors - existing_mirrors) new areas
-		 */
-		/* FIXME Create mirror hierarchy to sync */
-		log_error("Adding mirror images is not "
-			  "supported yet.");
-		return 0;
+		/* FIXME: can't have multiple mlogs. force corelog. */
+		corelog = 1;
+		if (!insert_layer_for_lv(cmd, lv, 0, "_resync%d")) {
+			log_error("Failed to insert resync layer");
+			return 0;
+		}
+		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,
+				    MIRROR_BY_LV))
+			return_0;
 	} else {
 		/* Reduce number of mirrors */
 		if (!lv_remove_mirrors(cmd, lv, existing_mirrors - lp->mirrors,
Index: LVM2.work/tools/toollib.c
===================================================================
--- LVM2.work.orig/tools/toollib.c
+++ LVM2.work/tools/toollib.c
@@ -1222,6 +1222,12 @@ int apply_lvname_restrictions(const char
 		return 0;
 	}
 
+	if (strstr(name, "_resync")) {
+		log_error("Names including \"_resync\" are reserved. "
+			  "Please choose a different LV name.");
+		return 0;
+	}
+
 	return 1;
 }
 

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