Skip to contentSkip to conversation

Fix removal of multiple devices from a mirror.

PATCH New Petr Rockai 3 participants 4 messages Dec 17, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix removal of multiple devices from a mirror.

Hi,

the code for removing mirror images, as it is, shifts the first failed leg twice and fails to shift the second failed one at all, which reorders the mirror image array in such a way that a wrong leg is removed as a result.

The trivial patch below fixes that behaviour by adjusting the array pointer to accommodate for the shift. Fixes RHBZ 543225.

Yours,
Petr.

Index: lib/metadata/mirror.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/metadata/mirror.c,v
retrieving revision 1.99

metadata/mirror.c +1 -0
diff -u -p -r1.99 mirror.c
@@ -533,6 +533,7 @@ static int _remove_mirror_images(struct 
 			    _is_mirror_image_removable(sub_lv, removable_pvs)) {
 				if (!shift_mirror_images(mirrored_seg, s))
 					return_0;
+				s--; /* adjust counter after shifting */
 				new_area_count--;
 			}
 		}
#1 lore raw

PATCH 1/1 Fix removal of multiple devices from a mirror.

Quoted 4 lines · Petr Rockai

the code for removing mirror images, as it is, shifts the first failed leg twice and fails to shift the second failed one at all, which reorders the mirror image array in such a way that a wrong leg is removed as a result.

well the code is not easily readable for me.
but the fix seems correct.

metadata/mirror.c static int _remove_mirror_images(struct · line 536

Quoted 5 lines
metadata/mirror.c +1 -0
@@ -533,6 +533,7 @@ static int _remove_mirror_images(struct 
 			    _is_mirror_image_removable(sub_lv, removable_pvs)) {
 				if (!shift_mirror_images(mirrored_seg, s))
 					return_0;
+				s--; /* adjust counter after shifting */

uint32_t s;

if the s drops to max_uint here, it will skip to 0 in next loop. well, another loop style is probably better...
but let's not complicate it now...

metadata/mirror.c static int _remove_mirror_images(struct · line 539

Quoted 3 lines
metadata/mirror.c +0 -0
 				new_area_count--;
 			}
 		}

ack.

Milan

#2 lore raw

PATCH 1/1 Fix removal of multiple devices from a mirror.

In reply to Petr Rockai

Is this problem still present after applying the previous patch:
https://www.redhat.com/archives/lvm-devel/2009-November/msg00043.html

The above patch was posted to fix a problem with specified PVs not being handled properly.
brassow

Quoted 33 lines · Petr Rockai

Hi,

the code for removing mirror images, as it is, shifts the first failed leg twice and fails to shift the second failed one at all, which reorders the mirror image array in such a way that a wrong leg is removed as a result.

The trivial patch below fixes that behaviour by adjusting the array pointer to accommodate for the shift. Fixes RHBZ 543225.

Yours,
Petr.

Index: lib/metadata/mirror.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/metadata/mirror.c,v
retrieving revision 1.99
diff -u -p -r1.99 mirror.c

metadata/mirror.c +1 -1
@@ -533,6 +533,7 @@ static int _remove_mirror_images(struct
 			    _is_mirror_image_removable(sub_lv, removable_pvs)) {
 				if (!shift_mirror_images(mirrored_seg, s))
 					return_0;
+				s--; /* adjust counter after shifting */
 				new_area_count--;
 			}
 		}
 
--

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

#3 lore raw

PATCH 1/1 Fix removal of multiple devices from a mirror.

This new patch achieves the same result as the old one in a simpler way.

ACK.

brassow

Quoted 48 lines · Jonathan Brassow

Is this problem still present after applying the previous patch:
https://www.redhat.com/archives/lvm-devel/2009-November/msg00043.html

The above patch was posted to fix a problem with specified PVs not being handled properly.
brassow

Quoted 31 lines · Petr Rockai

Hi,

the code for removing mirror images, as it is, shifts the first failed
leg twice and fails to shift the second failed one at all, which reorders the mirror image array in such a way that a wrong leg is removed as a result.

The trivial patch below fixes that behaviour by adjusting the array pointer to accommodate for the shift. Fixes RHBZ 543225.

Yours,
Petr.

Index: lib/metadata/mirror.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/metadata/mirror.c,v
retrieving revision 1.99
diff -u -p -r1.99 mirror.c

metadata/mirror.c +1 -1
@@ -533,6 +533,7 @@ static int _remove_mirror_images(struct
 			    _is_mirror_image_removable(sub_lv, removable_pvs)) {
 				if (!shift_mirror_images(mirrored_seg, s))
 					return_0;
+				s--; /* adjust counter after shifting */
 				new_area_count--;
 			}
 		}
 
--
Quoted 3 lines

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

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