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

[lvm-devel] [PATCH 8/11] Allow "mirror" segment with only 1 area



Allow "mirror" segment with only 1 area.

As a transitional state, "mirror" segment with only 1 area makes sense
for keeping mirror specific parameters (log_lv, region_size) in metadata.

The segment handler already has a code to add "linear" target line
for table. (see MIRR_DISABLED)

Codes to get copy percent have to consider the segment is in-sync
if area_count is 1.

-- 
Jun'ichi Nomura, NEC Corporation of America
Allow "mirror" segment with only 1 area.

As a transitional state, "mirror" segment with only 1 area makes sense
for keeping mirror specific parameters (log_lv, region_size) in metadata.

The segment handler already has a code to add "linear" target line
for table. (see MIRR_DISABLED)

Codes to get copy percent have to consider the segment is in-sync
if area_count is 1.

Index: LVM2.work/lib/mirror/mirrored.c
===================================================================
--- LVM2.work.orig/lib/mirror/mirrored.c
+++ LVM2.work/lib/mirror/mirrored.c
@@ -283,6 +283,11 @@ static int _mirrored_add_target_line(str
 
 	mirr_state = *target_state;
 
+	/* Mirror segment could have only 1 area temporarily,
+	 * if the segment is under conversion. */
+ 	if (seg->area_count == 1)
+		mirror_status = MIRR_DISABLED;
+
 	/*
 	 * For pvmove, only have one mirror segment RUNNING at once.
 	 * Segments before this are COMPLETED and use 2nd area.
Index: LVM2.work/lib/activate/activate.c
===================================================================
--- LVM2.work.orig/lib/activate/activate.c
+++ LVM2.work/lib/activate/activate.c
@@ -508,6 +508,13 @@ int lv_mirror_percent(struct cmd_context
 	struct dev_manager *dm;
 	struct lvinfo info;
 
+	/* If mirrored LV is temporarily shrinked to 1 area (= linear),
+	 * it should be considered in-sync. */
+	if (list_size(&lv->segments) == 1 && first_seg(lv)->area_count == 1) {
+		*percent = 100.0;
+		return 1;
+	}
+
 	if (!activation())
 		return 0;
 
Index: LVM2.work/lib/metadata/mirror.c
===================================================================
--- LVM2.work.orig/lib/metadata/mirror.c
+++ LVM2.work/lib/metadata/mirror.c
@@ -935,7 +935,7 @@ float copy_percent(struct logical_volume
 	list_iterate_items(seg, &lv_mirr->segments) {
 		denominator += seg->area_len;
 
-		if (seg_is_mirrored(seg))
+		if (seg_is_mirrored(seg) && seg->area_count > 1)
 			numerator += seg->extents_copied;
 		else
 			numerator += seg->area_len;

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