Fix mirror corruption during primary device failure
PATCH 1/1 Fix mirror corruption during primary device failure
There is another spot in tools/vgreduce.c that makes the same error as in lib/metadata/mirror.c. This patch addresses that.
I did duplicate the function I created in mirror.c in the previous patch.
brassow
tools/vgreduce.c +26 -3
@@ -130,6 +130,31 @@ static int _remove_lv(struct cmd_contextreturn 1 ; } +/* +* FIXME: exact same function as found in lib/metadata/mirror.c +* should reuse code +*/ +static int shift_mirror_legs (struct lv_segment *mirrored_seg,int leg_pos) +{ +int i; +struct lv_segment_area area; + + +if (leg_pos >= mirrored_seg->area_count) +return 1 ;/* -EINVAL */ + + area = mirrored_seg->areas[leg_pos]; + +/* Shift everyone down to fill the hole */ +for (i = leg_pos+1 ; i < mirrored_seg->area_count; i++) + mirrored_seg->areas[i-1 ] = mirrored_seg->areas[i]; + +/* Stick this one at the end */ + mirrored_seg->areas[i-1 ] = area; + +return 0 ; +} +static int _make_vg_consistent (struct cmd_context *cmd,struct volume_group *vg) {struct list *pvh, *pvht;
@@ -250,9 +275,7 @@ static int _make_vg_consistent(struct cm lvl2->lv != seg_lv(mirrored_seg, s))continue ;list_del (&lvl2->list); - area = mirrored_seg->areas[mimages -1 ]; - mirrored_seg->areas[mimages -1 ] = mirrored_seg->areas[s]; - mirrored_seg->areas[s] = area; +shift_mirror_legs (mirrored_seg, s); mimages--;/* FIXME Assumes uniqueness */ } }