1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

lvconvert: prompt when splitting off LV of a 2-legged raid1 LV

Splitting off an image LV of a 2-legged
raid1 LV causes loss of resilience.

Ask user to avoid uninformed loss of all resilience.

Don't ask for N > 2 legged raid1 LVs.

Adjust tests.
This commit is contained in:
Heinz Mauelshagen 2017-03-09 13:59:47 +01:00
parent 6b1b66c266
commit 6dfe1ce251
5 changed files with 20 additions and 9 deletions

View File

@ -1216,7 +1216,7 @@ int lv_raid_change_image_count(struct logical_volume *lv,
uint32_t new_count,
uint32_t new_region_size,
struct dm_list *allocate_pvs);
int lv_raid_split(struct logical_volume *lv, const char *split_name,
int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
uint32_t new_count, struct dm_list *splittable_pvs);
int lv_raid_split_and_track(struct logical_volume *lv,
int yes,

View File

@ -3071,7 +3071,7 @@ int lv_raid_change_image_count(struct logical_volume *lv, int yes, uint32_t new_
return _lv_raid_change_image_count(lv, yes, new_count, allocate_pvs, NULL, 1, 0);
}
int lv_raid_split(struct logical_volume *lv, const char *split_name,
int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
uint32_t new_count, struct dm_list *splittable_pvs)
{
struct lv_list *lvl;
@ -3116,6 +3116,14 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
return 0;
}
/* Split on a 2-legged raid1 LV causes loosing all resilience */
if (new_count == 1 &&
!yes && yes_no_prompt("Are you sure you want to split %s LV %s loosing all resilience? [y/n]: ",
lvseg_name(first_seg(lv)), display_lvname(lv)) == 'n') {
log_error("Logical volume %s NOT split.", display_lvname(lv));
return 0;
}
/*
* We only allow a split while there is tracking if it is to
* complete the split of the tracking sub-LV

View File

@ -47,7 +47,8 @@ lvremove -f $vg
lvcreate -n corigin -m 1 --type raid1 --nosync -l 10 $vg
lvcreate -n cpool --type cache $vg/corigin --cachemode writeback -l 10 2>&1 | tee out
grep "WARNING: Data redundancy is lost" out
lvconvert --splitmirrors 1 --name split $vg/corigin "$dev1"
not lvconvert --splitmirrors 1 --name split $vg/corigin "$dev1"
lvconvert --yes --splitmirrors 1 --name split $vg/corigin "$dev1"
lvremove -f $vg
@ -75,8 +76,9 @@ not lvconvert --splitmirrors 1 --name split_cdata $vg/cpool_cdata "$dev1"
# but allow manipulating existing LVs with reserved names
aux wait_for_sync $vg cpool_cmeta
aux wait_for_sync $vg cpool_cdata
lvconvert --splitmirrors 1 --name split_meta $vg/cpool_cmeta "$dev1"
lvconvert --splitmirrors 1 --name split_data $vg/cpool_cdata "$dev1"
lvconvert --yes --splitmirrors 1 --name split_meta $vg/cpool_cmeta "$dev1"
lvconvert --yes --splitmirrors 1 --name split_data $vg/cpool_cdata "$dev1"
not lvconvert --splitmirrors 1 --name split_data $vg/cpool_cdata "$dev1"
lvremove -f $vg

View File

@ -134,7 +134,8 @@ lvremove -ff $vg
# 2-way to linear/linear
lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg
aux wait_for_sync $vg $lv1
lvconvert --splitmirrors 1 -n $lv2 $vg/$lv1
not lvconvert --splitmirrors 1 -n $lv2 $vg/$lv1
lvconvert --yes --splitmirrors 1 -n $lv2 $vg/$lv1
check linear $vg $lv1
check linear $vg $lv2
check active $vg $lv2
@ -144,7 +145,7 @@ lvremove -ff $vg
# 4-way
lvcreate --type raid1 -m 4 -l 2 -n $lv1 $vg
aux wait_for_sync $vg $lv1
lvconvert --yes --splitmirrors 1 --name $lv2 $vg/$lv1 "$dev2"
lvconvert --splitmirrors 1 --name $lv2 $vg/$lv1 "$dev2"
lvremove -ff $vg
###########################################
@ -179,7 +180,7 @@ fsck.ext4 -fn "$DM_DEV_DIR/$vg/$lv1"
aux wait_for_sync $vg $lv1
fsck.ext4 -fn "$DM_DEV_DIR/$vg/$lv1"
not lvconvert --splitmirrors 1 --trackchanges $vg/$lv1
lvconvert -y --splitmirrors 1 --trackchanges $vg/$lv1
lvconvert --yes --splitmirrors 1 --trackchanges $vg/$lv1
# FIXME: ensure no residual devices
lvremove -ff $vg

View File

@ -1349,7 +1349,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
return lv_raid_split_and_track(lv, lp->yes, lp->pvh);
if (lp->keep_mimages)
return lv_raid_split(lv, lp->lv_split_name, image_count, lp->pvh);
return lv_raid_split(lv, lp->yes, lp->lv_split_name, image_count, lp->pvh);
if (lp->mirrors_supplied) {
if (!*lp->type_str || !strcmp(lp->type_str, SEG_TYPE_NAME_RAID1) || !strcmp(lp->type_str, SEG_TYPE_NAME_LINEAR) ||