2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2016-08-24 19:22:34 +03:00
# Copyright (C) 2016 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, MA 02110-1301 USA
2018-05-24 17:49:48 +03:00
2016-08-24 19:22:34 +03:00
SKIP_WITH_LVMPOLLD = 1
. lib/inittest
aux have_raid 1 3 2 || skip
2017-11-14 16:15:09 +03:00
v1_9_0 = 0
2018-05-30 13:50:34 +03:00
aux have_raid 1 9 0 && v1_9_0 = 1
2016-08-24 19:22:34 +03:00
aux prepare_vg 8
2017-07-06 20:41:25 +03:00
get_devs
2016-08-24 19:22:34 +03:00
2017-01-04 18:02:08 +03:00
_sync( ) {
2017-07-06 20:41:25 +03:00
aux enable_dev " ${ DEVICES [@] } "
2017-01-04 18:02:08 +03:00
aux wait_for_sync $vg $lv1
2017-07-11 12:18:22 +03:00
test " $# " -eq 0 || check raid_leg_status $vg $lv1 " $@ "
2017-01-04 18:02:08 +03:00
# restore to delay_dev tables for all devices
2017-07-06 20:41:25 +03:00
aux restore_from_devtable " ${ DEVICES [@] } "
2017-01-04 18:02:08 +03:00
}
2016-09-23 00:35:37 +03:00
# Delay legs so that rebuilding status characters can be read
2017-07-06 20:41:25 +03:00
for d in " ${ DEVICES [@] } "
2016-08-25 02:36:13 +03:00
do
2017-07-10 11:40:09 +03:00
aux delay_dev " $d " 0 50 " $( get first_extent_sector " $d " ) "
2016-08-25 02:36:13 +03:00
done
2016-08-24 19:22:34 +03:00
# rhbz 1064592
##############################################
# Create an 8-way striped raid10 with 4 mirror
# groups and rebuild selected PVs.
2019-10-02 15:59:17 +03:00
lvcreate --type raid10 -m 1 -i 4 -l 64 -n $lv1 $vg
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuild 1st and 2nd device would rebuild a
# whole mirror group and needs to be rejected.
not lvchange --yes --rebuild " $dev1 " --rebuild " $dev2 " $vg /$lv1
2017-11-14 16:15:09 +03:00
not check raid_leg_status $vg $lv1 "aaAAAAA"
2017-01-04 18:02:08 +03:00
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
2016-09-23 00:35:37 +03:00
# Rebuild 1st and 3rd device from different mirror groups is fine.
2016-08-24 19:22:34 +03:00
lvchange --yes --rebuild " $dev1 " --rebuild " $dev3 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "aAaAAAAA"
2017-01-04 18:02:08 +03:00
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuild devices 1, 3, 6 from different mirror groups is fine.
lvchange --yes --rebuild " $dev1 " --rebuild " $dev3 " --rebuild " $dev6 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "aAaAAaAA"
2017-01-04 18:02:08 +03:00
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuild devices 1, 3, 5 and 6 with 5+6 being
# being a whole mirror group needs to be rejected.
not lvchange --yes --rebuild " $dev1 " --rebuild " $dev3 " --rebuild " $dev6 " --rebuild " $dev5 " $vg /$lv1
2016-09-12 16:44:09 +03:00
not check raid_leg_status $vg $lv1 "aAaAaaAA"
2017-01-04 18:02:08 +03:00
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuild devices 1, 3, 5 and 7 from different mirror groups is fine.
lvchange --yes --rebuild " $dev1 " --rebuild " $dev3 " --rebuild " $dev5 " --rebuild " $dev7 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "aAaAaAaA"
2017-01-04 18:02:08 +03:00
_sync
2016-08-24 19:22:34 +03:00
# Rebuild devices 2, 4, 6 and 8 from different mirror groups is fine.
lvchange --yes --rebuild " $dev2 " --rebuild " $dev4 " --rebuild " $dev6 " --rebuild " $dev8 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "AaAaAaAa"
2017-01-04 18:02:08 +03:00
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
##############################################
# Create an 8-legged raid1 and rebuild selected PVs
lvremove --yes $vg /$lv1
lvcreate --yes --type raid1 -m 7 -l 2 -n $lv1 $vg
2017-01-04 18:02:08 +03:00
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuilding all raid1 legs needs to be rejected.
not lvchange --yes --rebuild " $dev1 " --rebuild " $dev2 " --rebuild " $dev3 " --rebuild " $dev4 " \
--rebuild " $dev5 " --rebuild " $dev6 " --rebuild " $dev7 " --rebuild " $dev8 " $vg /$lv1
2016-09-12 16:44:09 +03:00
not check raid_leg_status $vg $lv1 "aaaaaaaa"
2017-01-04 18:02:08 +03:00
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuilding all but the raid1 master leg is fine.
lvchange --yes --rebuild " $dev2 " --rebuild " $dev3 " --rebuild " $dev4 " \
--rebuild " $dev5 " --rebuild " $dev6 " --rebuild " $dev7 " --rebuild " $dev8 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "Aaaaaaaa"
2017-01-04 18:02:08 +03:00
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuilding the raid1 master leg is fine.
lvchange --yes --rebuild " $dev1 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "aAAAAAAA"
2017-01-04 18:02:08 +03:00
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuild legs on devices 2, 4, 6 and 8 is fine.
lvchange --yes --rebuild " $dev2 " --rebuild " $dev4 " --rebuild " $dev6 " --rebuild " $dev8 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "AaAaAaAa"
2017-01-04 18:02:08 +03:00
_sync "AAAAAAAA"
2016-08-24 19:22:34 +03:00
##############################################
# Create an 6-legged raid6 and rebuild selected PVs
lvremove --yes $vg /$lv1
lvcreate --yes --type raid6 -i 4 -l 2 -n $lv1 $vg
2017-01-04 18:02:08 +03:00
_sync "AAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuilding all raid6 stripes needs to be rejected.
not lvchange --yes --rebuild " $dev1 " --rebuild " $dev2 " --rebuild " $dev3 " \
--rebuild " $dev4 " --rebuild " $dev5 " --rebuild " $dev6 " $vg /$lv1
2016-09-12 16:44:09 +03:00
not check raid_leg_status $vg $lv1 "aaaaaa"
2017-01-04 18:02:08 +03:00
_sync "AAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuilding more than 2 raid6 stripes needs to be rejected.
not lvchange --yes --rebuild " $dev2 " --rebuild " $dev4 " --rebuild " $dev6 " $vg /$lv1
2016-09-12 16:44:09 +03:00
not check raid_leg_status $vg $lv1 "AaAaAa"
2017-01-04 18:02:08 +03:00
_sync "AAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuilding any 1 raid6 stripe is fine.
lvchange --yes --rebuild " $dev2 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "AaAAAA"
2017-01-04 18:02:08 +03:00
_sync
2016-08-24 19:22:34 +03:00
lvchange --yes --rebuild " $dev5 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "AAAAaA"
2017-01-04 18:02:08 +03:00
_sync "AAAAAA"
2016-08-24 19:22:34 +03:00
# Rebuilding any 2 raid6 stripes is fine.
lvchange --yes --rebuild " $dev2 " --rebuild " $dev4 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "AaAaAA"
2017-01-04 18:02:08 +03:00
_sync "AAAAAA"
2016-08-24 19:22:34 +03:00
lvchange --yes --rebuild " $dev1 " --rebuild " $dev5 " $vg /$lv1
2017-11-14 16:15:09 +03:00
[ $v1_9_0 -eq 1 ] && check raid_leg_status $vg $lv1 "aAAAaA"
2017-01-04 18:02:08 +03:00
_sync "AAAAAA"
2016-08-24 19:22:34 +03:00
vgremove -ff $vg