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

[lvm-devel] [PATCH 7/11] lvconvert adds/removes mirror log to/from the original LV



If mirror log addition/removal was requested during conversion,
lvconvert should manipulate on the original LV, not the top-level LV.

Use find_tmp_mirror() to find out the original LV.

-- 
Jun'ichi Nomura, NEC Corporation of America
If mirror log addition/removal was requested during conversion,
lvconvert should manipulate on the original LV, not the top-level LV.

Use find_tmp_mirror() to find out the original LV.

Index: LVM2.work/tools/lvconvert.c
===================================================================
--- LVM2.work.orig/tools/lvconvert.c
+++ LVM2.work/tools/lvconvert.c
@@ -360,6 +360,17 @@ static int _insert_lvconvert_layer(struc
 	return 1;
 }
 
+/* walk down the stacked mirror LV to the original mirror LV */
+static struct logical_volume *_original_lv(struct logical_volume *lv)
+{
+	struct logical_volume *next_lv = lv, *tmp_lv;
+
+	while ((tmp_lv = find_tmp_mirror(next_lv)))
+		next_lv = tmp_lv;
+
+	return next_lv;
+}
+
 static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * lv,
 			     struct lvconvert_params *lp)
 {
@@ -367,6 +378,7 @@ static int lvconvert_mirrors(struct cmd_
 	uint32_t existing_mirrors;
 	const char *mirrorlog;
 	unsigned corelog = 0;
+	struct logical_volume *original_lv;
 
 	seg = first_seg(lv);
 	existing_mirrors = lv_mirror_count(lv);
@@ -490,8 +502,9 @@ static int lvconvert_mirrors(struct cmd_
 	}
 
 	if (lp->mirrors == existing_mirrors) {
+		original_lv = _original_lv(lv);
 		if (!seg->log_lv && !corelog) {
-			if (!add_mirror_log(cmd, lv, 1,
+			if (!add_mirror_log(cmd, original_lv, 1,
 					    adjusted_mirror_region_size(
 							lv->vg->extent_size,
 							lv->le_count,
@@ -499,7 +512,7 @@ static int lvconvert_mirrors(struct cmd_
 					    lp->pvh, lp->alloc))
 				return_0;
 		} else if (seg->log_lv && corelog) {
-			if (!remove_mirror_log(cmd, lv,
+			if (!remove_mirror_log(cmd, original_lv,
 					       lp->pv_count ? lp->pvh : NULL))
 				return_0;
 		} else {
@@ -520,8 +533,9 @@ static int lvconvert_mirrors(struct cmd_
 		 * insertion to make the end result consistent with
 		 * linear-to-mirror conversion.
 		 */
+		original_lv = _original_lv(lv);
 		if (!seg->log_lv && !corelog) {
-			if (!add_mirror_log(cmd, lv, 1,
+			if (!add_mirror_log(cmd, original_lv, 1,
 					    adjusted_mirror_region_size(
 							lv->vg->extent_size,
 							lv->le_count,
@@ -529,7 +543,7 @@ static int lvconvert_mirrors(struct cmd_
 					    lp->pvh, lp->alloc))
 				return_0;
 		} else if (seg->log_lv && corelog) {
-			if (!remove_mirror_log(cmd, lv,
+			if (!remove_mirror_log(cmd, original_lv,
 					       lp->pv_count ? lp->pvh : NULL))
 				return_0;
 		}

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