1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

raid: fix raid1 to mirror conversion

Fix order of operation when converting raid1 into old mirror.
Before any later metadata modification are initiated prepare
mirror_log device with all clearing.
Then directly convert  raid1 into mirror with mirror_log.
This convertion now properly see as precommitted metadata
new 'mirror' and committed old 'raid' and is able to
preload all LVs.
This commit is contained in:
Zdenek Kabelac 2016-12-10 20:01:05 +01:00
parent 31564834db
commit 0c8369099b
2 changed files with 8 additions and 6 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.169 - Version 2.02.169 -
===================================== =====================================
Fix lvconvert raid1 to mirror table reload order.
Add internal function for separate mirror log preparation. Add internal function for separate mirror log preparation.
Fix segfault in lvmetad from missing NULL in daemon_reply_simple. Fix segfault in lvmetad from missing NULL in daemon_reply_simple.
Simplify internal _info_run() and use _setup_task_run() for mknod. Simplify internal _info_run() and use _setup_task_run() for mknod.

View File

@ -2207,6 +2207,7 @@ static int _convert_raid1_to_mirror(struct logical_volume *lv,
int update_and_reload, int update_and_reload,
struct dm_list *removal_lvs) struct dm_list *removal_lvs)
{ {
struct logical_volume *log_lv;
struct lv_segment *seg = first_seg(lv); struct lv_segment *seg = first_seg(lv);
if (!seg_is_raid1(seg)) { if (!seg_is_raid1(seg)) {
@ -2227,7 +2228,10 @@ static int _convert_raid1_to_mirror(struct logical_volume *lv,
return 0; return 0;
} }
init_mirror_in_sync(new_image_count > seg->area_count ? 0 : 1); if (!(log_lv = prepare_mirror_log(lv, (new_image_count <= seg->area_count) /* in sync */,
new_region_size,
allocate_pvs, lv->vg->alloc)))
return_0; /* TODO remove log_lv on error path */
/* Change image pair count to requested # of images */ /* Change image pair count to requested # of images */
if (new_image_count != seg->area_count) { if (new_image_count != seg->area_count) {
@ -2255,11 +2259,8 @@ static int _convert_raid1_to_mirror(struct logical_volume *lv,
seg->status &= ~RAID; seg->status &= ~RAID;
lv->status |= (MIRROR | MIRRORED); lv->status |= (MIRROR | MIRRORED);
/* Add mirror_log LV (should happen in wih image allocation */ if (!attach_mirror_log(first_seg(lv), log_lv))
if (!add_mirror_log(lv->vg->cmd, lv, 1, seg->region_size, allocate_pvs, lv->vg->alloc)) { return_0;
log_error("Unable to add mirror log to %s.", display_lvname(lv));
return 0;
}
return update_and_reload ? _lv_update_reload_fns_reset_eliminate_lvs(lv, removal_lvs) : 1; return update_and_reload ? _lv_update_reload_fns_reset_eliminate_lvs(lv, removal_lvs) : 1;
} }