All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix removal of multiple devices from a mirror.
@ 2009-12-17 13:51 Petr Rockai
  2009-12-17 14:12 ` Milan Broz
  2009-12-17 14:50 ` Jonathan Brassow
  0 siblings, 2 replies; 4+ messages in thread
From: Petr Rockai @ 2009-12-17 13:51 UTC (permalink / raw)
  To: lvm-devel

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
--- lib/metadata/mirror.c	9 Dec 2009 19:53:39 -0000	1.99
+++ lib/metadata/mirror.c	17 Dec 2009 13:43:30 -0000
@@ -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--;
 			}
 		}



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Fix removal of multiple devices from a mirror.
  2009-12-17 13:51 [PATCH] Fix removal of multiple devices from a mirror Petr Rockai
@ 2009-12-17 14:12 ` Milan Broz
  2009-12-17 14:50 ` Jonathan Brassow
  1 sibling, 0 replies; 4+ messages in thread
From: Milan Broz @ 2009-12-17 14:12 UTC (permalink / raw)
  To: lvm-devel

On 12/17/2009 02:51 PM, Petr Rockai wrote:
> 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.

> @@ -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...

>  				new_area_count--;
>  			}
>  		}

ack.

Milan



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Fix removal of multiple devices from a mirror.
  2009-12-17 13:51 [PATCH] Fix removal of multiple devices from a mirror Petr Rockai
  2009-12-17 14:12 ` Milan Broz
@ 2009-12-17 14:50 ` Jonathan Brassow
  2009-12-17 15:19   ` Jonathan Brassow
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Brassow @ 2009-12-17 14:50 UTC (permalink / raw)
  To: lvm-devel

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

On Dec 17, 2009, at 7:51 AM, Petr Rockai wrote:

> 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
> --- lib/metadata/mirror.c	9 Dec 2009 19:53:39 -0000	1.99
> +++ lib/metadata/mirror.c	17 Dec 2009 13:43:30 -0000
> @@ -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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Fix removal of multiple devices from a mirror.
  2009-12-17 14:50 ` Jonathan Brassow
@ 2009-12-17 15:19   ` Jonathan Brassow
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Brassow @ 2009-12-17 15:19 UTC (permalink / raw)
  To: lvm-devel

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

ACK.

  brassow

On Dec 17, 2009, at 8:50 AM, Jonathan Brassow wrote:

> 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
>
> On Dec 17, 2009, at 7:51 AM, Petr Rockai wrote:
>
>> 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
>> --- lib/metadata/mirror.c	9 Dec 2009 19:53:39 -0000	1.99
>> +++ lib/metadata/mirror.c	17 Dec 2009 13:43:30 -0000
>> @@ -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
>
> --
> lvm-devel mailing list
> lvm-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/lvm-devel



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-12-17 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-17 13:51 [PATCH] Fix removal of multiple devices from a mirror Petr Rockai
2009-12-17 14:12 ` Milan Broz
2009-12-17 14:50 ` Jonathan Brassow
2009-12-17 15:19   ` Jonathan Brassow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.