From dc7b1640edea796ff236be8594e5278383474c53 Mon Sep 17 00:00:00 2001 From: Jonathan Earl Brassow Date: Thu, 15 Mar 2012 20:00:54 +0000 Subject: [PATCH] Fix name conflicts that prevent down-converting RAID1 when specifying a device When down-converting a RAID1 device, it is the last device that is extracted and removed when the user does not specify a particular device. However, when a device is specified (and it is not the last), the device is removed and the remaining sub-LVs are "shifted down" to fill the hole. This cause problems when resuming the LV because if the shifted devices were resumed (and thus renamed) before the sub-LV being extracted, there would be a name conflict. The solution is to resume the extracted sub-LVs first so that they can be properly renamed preventing a possible conflict. This addresses bug 801967. --- WHATS_NEW | 1 + lib/metadata/raid_manip.c | 14 +++++++++++++- test/shell/lvconvert-raid.sh | 7 +++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index f04ebc3a8..d4b8b2bbd 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.96 - ================================ + Fix name conflicts that prevent down-converting RAID1 when specifying a device Improve thin_check option passing and use configured path. Add --with-thin-check configure option for path to thin_check. Detect lvm binary path in lvmetad udev rules. diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index a4a6a40d9..ffaab2778 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -1011,9 +1011,21 @@ static int _raid_remove_images(struct logical_volume *lv, return 0; } + /* + * We resume the extracted sub-LVs first so they are renamed + * and won't conflict with the remaining (possibly shifted) + * sub-LVs. + */ + dm_list_iterate_items(lvl, &removal_list) { + if (!resume_lv(lv->vg->cmd, lvl->lv)) { + log_error("Failed to resume extracted LVs"); + return 0; + } + } + /* * Resume original LV - * This also resumes all other sub-lvs (including the extracted) + * This also resumes all other sub-LVs */ if (!resume_lv(lv->vg->cmd, lv)) { log_error("Failed to resume %s/%s after committing changes", diff --git a/test/shell/lvconvert-raid.sh b/test/shell/lvconvert-raid.sh index 66a7a249b..72b94e899 100644 --- a/test/shell/lvconvert-raid.sh +++ b/test/shell/lvconvert-raid.sh @@ -156,6 +156,13 @@ for i in 1 2 3 4; do done done done + +# 3-way to 2-way convert while specifying devices +lvcreate --type raid1 -m 2 -l 2 -n $lv1 $vg $dev1 $dev2 $dev3 +wait_for_sync $vg/$lv1 +lvconvert -m1 $vg/$lv1 $dev2 +lvremove -ff $vg + # # FIXME: Add tests that specify particular devices to be removed # -- 2.43.5