mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvconvert: allow raid4 -> linear conversion request
Allow "lvconvert --type linear RaidLV" on a raid4 LV providing convenient interim steps to convert to linear. Add respective new test lvconvert-raid-takeover-raid4_to_linear.sh and lvconvert-raid-takeover-linear_to_raid4.sh for linear to raid4 once on it.
This commit is contained in:
parent
e2e30a64ab
commit
989626926c
@ -1,5 +1,6 @@
|
|||||||
Version 3.0.0
|
Version 3.0.0
|
||||||
=============
|
=============
|
||||||
|
Allow raid4 -> linear conversion request.
|
||||||
Fix lvconvert striped/raid0/raid0_meta -> raid6 regression.
|
Fix lvconvert striped/raid0/raid0_meta -> raid6 regression.
|
||||||
Add 'lvm2-activation-generator:' prefix for kmsg messages logged by generator.
|
Add 'lvm2-activation-generator:' prefix for kmsg messages logged by generator.
|
||||||
Add After=rbdmap.service to {lvm2-activation-net,blk-availability}.service.
|
Add After=rbdmap.service to {lvm2-activation-net,blk-availability}.service.
|
||||||
|
@ -6149,9 +6149,17 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
|
|||||||
else if (!segtype_is_raid4(*segtype) && !segtype_is_any_raid5(*segtype))
|
else if (!segtype_is_raid4(*segtype) && !segtype_is_any_raid5(*segtype))
|
||||||
seg_flag = SEG_RAID5_LS;
|
seg_flag = SEG_RAID5_LS;
|
||||||
|
|
||||||
/* raid5* -> */
|
/* raid4/raid5* -> */
|
||||||
} else if (seg_is_any_raid5(seg_from)) {
|
} else if (seg_is_raid4(seg_from) || seg_is_any_raid5(seg_from)) {
|
||||||
if (segtype_is_raid1(*segtype) || segtype_is_linear(*segtype)) {
|
if (seg_is_raid4(seg_from) && segtype_is_any_raid5(*segtype)) {
|
||||||
|
if (!segtype_is_raid5_n(*segtype))
|
||||||
|
seg_flag = SEG_RAID5_N;
|
||||||
|
|
||||||
|
} else if (seg_is_any_raid5(seg_from) && segtype_is_raid4(*segtype)) {
|
||||||
|
if (!seg_is_raid5_n(seg_from))
|
||||||
|
seg_flag = SEG_RAID5_N;
|
||||||
|
|
||||||
|
} else if (segtype_is_raid1(*segtype) || segtype_is_linear(*segtype)) {
|
||||||
if (seg_from->area_count != 2) {
|
if (seg_from->area_count != 2) {
|
||||||
log_error("Converting %s LV %s to 2 stripes first.",
|
log_error("Converting %s LV %s to 2 stripes first.",
|
||||||
lvseg_name(seg_from), display_lvname(seg_from->lv));
|
lvseg_name(seg_from), display_lvname(seg_from->lv));
|
||||||
@ -6173,12 +6181,12 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
|
|||||||
lvseg_name(seg_from), display_lvname(seg_from->lv), *new_image_count);
|
lvseg_name(seg_from), display_lvname(seg_from->lv), *new_image_count);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
seg_flag = _raid_seg_flag_5_to_6(seg_from);
|
seg_flag = seg_is_raid4(seg_from) ? SEG_RAID6_N_6 :_raid_seg_flag_5_to_6(seg_from);
|
||||||
|
|
||||||
} else if (segtype_is_striped(*segtype) || segtype_is_raid10(*segtype)) {
|
} else if (segtype_is_striped(*segtype) || segtype_is_raid10(*segtype)) {
|
||||||
int change = 0;
|
int change = 0;
|
||||||
|
|
||||||
if (!seg_is_raid5_n(seg_from)) {
|
if (!seg_is_raid4(seg_from) && !seg_is_raid5_n(seg_from)) {
|
||||||
seg_flag = SEG_RAID5_N;
|
seg_flag = SEG_RAID5_N;
|
||||||
|
|
||||||
} else if (*stripes > 2 && *stripes != seg_from->area_count - seg_from->segtype->parity_devs) {
|
} else if (*stripes > 2 && *stripes != seg_from->area_count - seg_from->segtype->parity_devs) {
|
||||||
@ -6199,10 +6207,6 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
|
|||||||
lvseg_name(seg_from), display_lvname(seg_from->lv), *new_image_count);
|
lvseg_name(seg_from), display_lvname(seg_from->lv), *new_image_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* raid4 -> * */
|
|
||||||
} else if (seg_is_raid4(seg_from) && !segtype_is_raid4(*segtype) && !segtype_is_striped(*segtype)) {
|
|
||||||
seg_flag = segtype_is_any_raid6(*segtype) ? SEG_RAID6_N_6 : SEG_RAID5_N;
|
|
||||||
|
|
||||||
/* raid6 -> striped/raid0/raid5/raid10 */
|
/* raid6 -> striped/raid0/raid5/raid10 */
|
||||||
} else if (seg_is_any_raid6(seg_from)) {
|
} else if (seg_is_any_raid6(seg_from)) {
|
||||||
if (segtype_is_raid1(*segtype)) {
|
if (segtype_is_raid1(*segtype)) {
|
||||||
|
71
test/shell/lvconvert-raid-takeover-linear_to_raid4.sh
Normal file
71
test/shell/lvconvert-raid-takeover-linear_to_raid4.sh
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (C) 2018 Red Hat, Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# This copyrighted material is made available to anyone wishing to use,
|
||||||
|
# modify, copy, or redistribute it subject to the terms and conditions
|
||||||
|
# of the GNU General Public License v.2.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
|
SKIP_WITH_LVMPOLLD=1
|
||||||
|
|
||||||
|
. lib/inittest
|
||||||
|
|
||||||
|
which mkfs.ext4 || skip
|
||||||
|
aux have_raid 1 9 1 || skip
|
||||||
|
|
||||||
|
aux prepare_vg 4 32
|
||||||
|
|
||||||
|
# FIXME: lvconvert leaks 'error' devices
|
||||||
|
detect_error_leak_()
|
||||||
|
{
|
||||||
|
local err=""
|
||||||
|
|
||||||
|
for i in $(dmsetup info -c -o name --noheadings) ; do
|
||||||
|
case "$i" in
|
||||||
|
"$vg*") (dmsetup table "$i" | grep "error ") && err="$err $i" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
test -z "$err" || {
|
||||||
|
dmsetup table | grep $vg
|
||||||
|
dmsetup ls --tree
|
||||||
|
die "Device(s) $err should not be here."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create linear LV
|
||||||
|
lvcreate -y -L 9M -n $lv $vg
|
||||||
|
check lv_field $vg/$lv segtype "linear"
|
||||||
|
check lv_field $vg/$lv data_stripes 1
|
||||||
|
check lv_field $vg/$lv stripes 1
|
||||||
|
mkfs.ext4 "$DM_DEV_DIR/$vg/$lv"
|
||||||
|
fsck -fn "$DM_DEV_DIR/$vg/$lv"
|
||||||
|
|
||||||
|
# Step 1: convert linear -> raid4 (convert to 2-legged raid1)
|
||||||
|
lvconvert -y --stripes 3 --ty raid4 $vg/$lv
|
||||||
|
detect_error_leak_
|
||||||
|
check lv_field $vg/$lv segtype "raid1"
|
||||||
|
check lv_field $vg/$lv data_stripes 2
|
||||||
|
check lv_field $vg/$lv stripes 2
|
||||||
|
aux wait_for_sync $vg $lv
|
||||||
|
|
||||||
|
# Step 2: convert linear ->raid4 (convert to raid4)
|
||||||
|
lvconvert -y --stripes 3 --ty raid4 $vg/$lv
|
||||||
|
detect_error_leak_
|
||||||
|
check lv_field $vg/$lv segtype "raid4"
|
||||||
|
check lv_field $vg/$lv data_stripes 1
|
||||||
|
check lv_field $vg/$lv stripes 2
|
||||||
|
|
||||||
|
# Step 3: convert linear ->raid4 (reshape to add stripes)
|
||||||
|
lvconvert -y --stripes 3 --ty raid4 $vg/$lv
|
||||||
|
detect_error_leak_
|
||||||
|
check lv_field $vg/$lv segtype "raid4"
|
||||||
|
check lv_field $vg/$lv data_stripes 3
|
||||||
|
check lv_field $vg/$lv stripes 4
|
||||||
|
|
||||||
|
vgremove -ff $vg
|
82
test/shell/lvconvert-raid-takeover-raid4_to_linear.sh
Normal file
82
test/shell/lvconvert-raid-takeover-raid4_to_linear.sh
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (C) 2018 Red Hat, Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# This copyrighted material is made available to anyone wishing to use,
|
||||||
|
# modify, copy, or redistribute it subject to the terms and conditions
|
||||||
|
# of the GNU General Public License v.2.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA2110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
|
SKIP_WITH_LVMPOLLD=1
|
||||||
|
|
||||||
|
. lib/inittest
|
||||||
|
|
||||||
|
which mkfs.ext4 || skip
|
||||||
|
aux have_raid 1 9 1 || skip
|
||||||
|
|
||||||
|
aux prepare_vg 4 32
|
||||||
|
|
||||||
|
# FIXME: lvconvert leaks 'error' devices
|
||||||
|
detect_error_leak_()
|
||||||
|
{
|
||||||
|
local err=""
|
||||||
|
|
||||||
|
for i in $(dmsetup info -c -o name --noheadings) ; do
|
||||||
|
case "$i" in
|
||||||
|
"$vg*") (dmsetup table "$i" | grep "error ") && err="$err $i" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
test -z "$err" || {
|
||||||
|
dmsetup table | grep $vg
|
||||||
|
dmsetup ls --tree
|
||||||
|
die "Device(s) $err should not be here."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create 3-way striped raid4 (4 legs total)
|
||||||
|
lvcreate -y --ty raid4 --stripes 3 -L 9M -n $lv $vg
|
||||||
|
check lv_field $vg/$lv segtype "raid4"
|
||||||
|
check lv_field $vg/$lv data_stripes 3
|
||||||
|
check lv_field $vg/$lv stripes 4
|
||||||
|
mkfs.ext4 "$DM_DEV_DIR/$vg/$lv"
|
||||||
|
fsck -fn "$DM_DEV_DIR/$vg/$lv"
|
||||||
|
|
||||||
|
# Step 1: grow before removing stripes
|
||||||
|
lvextend -y -L27M $vg/$lv
|
||||||
|
aux wait_for_sync $vg $lv
|
||||||
|
|
||||||
|
# Step 2: convert raid4 -> linear (reshape to remove stripes)
|
||||||
|
lvconvert -y -f --ty linear $vg/$lv
|
||||||
|
detect_error_leak_
|
||||||
|
check lv_field $vg/$lv segtype "raid4"
|
||||||
|
check lv_field $vg/$lv data_stripes 1
|
||||||
|
check lv_field $vg/$lv stripes 4
|
||||||
|
aux wait_for_sync $vg $lv 1
|
||||||
|
|
||||||
|
# Step 2: convert raid4 -> linear (remove freed stripes)
|
||||||
|
lvconvert -y --ty linear $vg/$lv
|
||||||
|
detect_error_leak_
|
||||||
|
check lv_field $vg/$lv segtype "raid4"
|
||||||
|
check lv_field $vg/$lv data_stripes 1
|
||||||
|
check lv_field $vg/$lv stripes 2
|
||||||
|
|
||||||
|
# Step 3: convert raid4 -> linear (convert to raid1)
|
||||||
|
lvconvert -y --ty linear $vg/$lv
|
||||||
|
detect_error_leak_
|
||||||
|
check lv_field $vg/$lv segtype "raid1"
|
||||||
|
check lv_field $vg/$lv data_stripes 2
|
||||||
|
check lv_field $vg/$lv stripes 2
|
||||||
|
|
||||||
|
# Step 4: convert raid4 -> linear (convert to linear)
|
||||||
|
lvconvert -y --ty linear $vg/$lv
|
||||||
|
detect_error_leak_
|
||||||
|
check lv_field $vg/$lv segtype "linear"
|
||||||
|
check lv_field $vg/$lv data_stripes 1
|
||||||
|
check lv_field $vg/$lv stripes 1
|
||||||
|
|
||||||
|
vgremove -ff $vg
|
Loading…
Reference in New Issue
Block a user