Skip to contentSkip to conversation

LVM2/tools lvconvert.c

PATCH [email protected] 3 participants 3 messages Jun 23, 2010

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: jbrassow at sourceware.org 2010-06-23 20:32:29

Modified files:
tools : lvconvert.c

Log message:
Committing Taka's patch... He found a problem during the failure of a device that contained both a image of a mirror and an image of the mirrored log. The order of the handling of those faults was important (and wrong), this patch corrects that.

Patch-From: Takahiro Yasui <[email protected]>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.134&r2=1.135

tools/lvconvert.c +31 -2
@@ -689,6 +689,27 @@
 	return lv_mirror_count(log_lv);
 }
 
+static int _lv_update_mirrored_log(struct logical_volume *lv,
+				   struct dm_list *operable_pvs,
+				   int log_count)
+{
+	int old_log_count;
+	struct logical_volume *log_lv;
+
+	log_lv = first_seg(_original_lv(lv))->log_lv;
+	if (!log_lv || !(log_lv->status & MIRRORED))
+		return 1;
+
+	old_log_count = _get_log_count(lv);
+	if (old_log_count == log_count)
+		return 1;
+
+	/* Reducing redundancy of the log */
+	return remove_mirror_images(log_lv, log_count,
+				    is_mirror_image_removable,
+				    operable_pvs, 0U);
+}
+
 static int _lv_update_log_type(struct cmd_context *cmd,
 			       struct lvconvert_params *lp,
 			       struct logical_volume *lv,
@@ -1218,15 +1239,23 @@
 	 * We must adjust the log first, or the entire mirror
 	 * will get stuck during a suspend.
 	 */
-	if (!_lv_update_log_type(cmd, lp, lv, failed_pvs, new_log_count))
+	if (!_lv_update_mirrored_log(lv, failed_pvs, new_log_count))
 		return 0;
 
+	if (lp->mirrors == 1)
+		new_log_count = 0;
+
 	if (failed_mirrors) {
-		if (!lv_remove_mirrors(cmd, lv, failed_mirrors, new_log_count,
+		if (!lv_remove_mirrors(cmd, lv, failed_mirrors,
+				       new_log_count ? 0U : 1U,
 				       _is_partial_lv, NULL, 0))
 			return 0;
 	}
 
+	if (!_lv_update_log_type(cmd, lp, lv, failed_pvs,
+				 new_log_count))
+		return 0;
+
 	if (!_reload_lv(cmd, lv))
 		return 0;
 
#1 lore raw
Quoted 4 lines · jbrassow at sourceware.org

the failure of a device that contained both a image of a mirror and an image of the mirrored log. The order of the handling of those faults was important (and wrong), this patch corrects that.

"order...was important...and wrong...this patch corrects..."

Can you be a bit more specific? Why was it important?
What was wrong about it?
What does this patch do to correct it?

We need something more precise for WHATS_NEW.

Alasdair

#2 lore raw

Yep, I should have just entered the whole thing instead of summarizing so tersely... Here is the original dialog in the patch that was sent.

brassow

<taka>
I found a case that lvconvert command can't repair failed lvm mirror volume. When a mirror leg and a mirror log failed at the same time, lvconvert --repair can't handle the error.

Before mirrored log function was introduced, the sequence of repair was

1. Fix mirror legs ... lv_remove_mirrors()
2. Fix mirror log ... _lv_update_log_type()

and after mirrored log function was introduced, the sequence was changed as follows because a recovery of mirror log should be done before a recovery of mirror leg is done.

1. Fix mirror log ... _lv_update_log_type()
2. Fix mirror legs ... lv_remove_mirrors()

It seems to introduced this issue. In _lv_update_log_type() function handles not only mirror log but also mirror leg and it does not seem to work properly.

One of the solutions to fix this issue is to change the sequence as the one before mirror log function was introduced and to add a function to handle a failure of mirrored log before mirror leg is recovered.

1. Fix mirrored log ... _lv_update_log() <NEW function> _lv_update_log() handles errors inside mirrored log and doesn't change an original lv.
2. Fix mirror legs ... lv_remove_mirrors()
3. Fix mirror log ... _lv_update_log_type()

I created a RFC patch and it worked well for my test cases. </taka>

Quoted 22 lines · Alasdair G Kergon
Quoted 4 lines · jbrassow at sourceware.org

the failure of a device that contained both a image of a mirror and an image of the mirrored log. The order of the handling of those faults was important (and wrong), this patch corrects that.

"order...was important...and wrong...this patch corrects..."

Can you be a bit more specific? Why was it important?
What was wrong about it?
What does this patch do to correct it?

We need something more precise for WHATS_NEW.

Alasdair

--
lvm-devel mailing list lvm-devel at redhat.com
https://www.redhat.com/mailman/listinfo/lvm-devel