2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2016-08-08 14:52:35 +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-08 14:52:35 +03:00
SKIP_WITH_LVMPOLLD = 1
. lib/inittest
aux have_raid 1 7 0 || skip
2017-02-06 15:15:39 +03:00
segtypes = "raid5"
aux have_raid4 && segtypes = " raid4 $segtypes "
2016-10-28 22:54:10 +03:00
2016-08-08 14:52:35 +03:00
aux prepare_vg 6
2017-01-06 23:46:58 +03:00
_sync( ) {
aux enable_dev " $dev1 "
aux wait_for_sync $vg $lv1
test -z " $1 " || check raid_leg_status $vg $lv1 $1
lvremove --yes $vg /$lv1
# restore to delay_dev tables for all devices
aux restore_from_devtable " $dev1 "
}
2021-03-17 00:53:23 +03:00
# Workaround for raid targets returning 'a' shortly after initialization
# TODO: maybe there is some workaround to be made on lvm side
_check_raid_in_loop( ) {
local vg = $1
local lv = $2
local A = $3
local B = $( echo $A | tr A a)
for i in { 1..10} ; do
check raid_leg_status $vg $lv ${ A } && return 0
# Only when there is initial 'a..a' we will wait for a while
check raid_leg_status $vg $lv ${ B } || break
sleep .05
done
die " Cannot get $A status for $vg / $lv " ;
}
2016-08-08 14:52:35 +03:00
# Delay 1st leg so that rebuilding status characters
# can be read before resync finished too quick.
2017-07-10 11:40:09 +03:00
aux delay_dev " $dev1 " 0 100 " $( get first_extent_sector " $dev1 " ) "
2016-08-08 14:52:35 +03:00
# raid0/raid0_meta don't support resynchronization
for r in raid0 raid0_meta
do
2017-02-06 15:15:39 +03:00
lvcreate --type $r -Zn -i 3 -l 1 -n $lv1 $vg
2021-03-17 00:53:23 +03:00
_check_raid_in_loop $vg $lv1 "AAA"
2016-08-08 14:52:35 +03:00
lvremove --yes $vg /$lv1
done
# raid1 supports resynchronization
2017-02-06 15:15:39 +03:00
lvcreate --type raid1 -m 2 -Zn -l 4 -n $lv1 $vg
2016-09-13 12:27:36 +03:00
check raid_leg_status $vg $lv1 "aaa"
2017-01-06 23:46:58 +03:00
_sync "AAA"
2016-08-08 14:52:35 +03:00
# raid1 supports --nosync
2017-02-06 15:15:39 +03:00
lvcreate --type raid1 --nosync -Zn -m 2 -l 1 -n $lv1 $vg
2021-03-17 00:53:23 +03:00
_check_raid_in_loop $vg $lv1 "AAA"
2016-08-08 14:52:35 +03:00
lvremove --yes $vg /$lv1
2016-10-28 22:54:10 +03:00
for r in $segtypes
2016-11-07 13:05:50 +03:00
do
2016-08-08 14:52:35 +03:00
# raid4/5 support resynchronization
2017-05-31 14:58:19 +03:00
lvcreate --type $r -Zn -i 3 -L10 -n $lv1 $vg
2016-09-13 12:27:36 +03:00
check raid_leg_status $vg $lv1 "aaaa"
2017-01-06 23:46:58 +03:00
_sync "AAAA"
2016-08-08 14:52:35 +03:00
# raid4/5 support --nosync
2017-02-06 15:15:39 +03:00
lvcreate --type $r -Zn --nosync -i 3 -l 1 -n $lv2 $vg
2021-03-17 00:53:23 +03:00
_check_raid_in_loop $vg $lv2 "AAAA"
2016-09-13 13:23:46 +03:00
lvremove --yes $vg
2016-08-08 14:52:35 +03:00
done
# raid6 supports resynchronization
2017-02-06 15:15:39 +03:00
lvcreate --type raid6 -Zn -i 3 -l 4 -n $lv1 $vg
2016-09-13 12:27:36 +03:00
check raid_leg_status $vg $lv1 "aaaaa"
2017-01-06 23:46:58 +03:00
_sync "AAAAA"
2016-08-08 14:52:35 +03:00
# raid6 rejects --nosync; it has to initialize P- and Q-Syndromes
2017-02-06 15:15:39 +03:00
not lvcreate --type raid6 --nosync -Zn -i 3 -l 1 -n $lv1 $vg
2016-08-08 14:52:35 +03:00
# raid10 supports resynchronization
2017-05-31 14:58:19 +03:00
lvcreate --type raid10 -m 1 -Zn -i 3 -L10 -n $lv1 $vg
2016-09-13 12:27:36 +03:00
check raid_leg_status $vg $lv1 "aaaaaa"
2017-01-06 23:46:58 +03:00
_sync "AAAAAA"
2016-08-08 14:52:35 +03:00
# raid10 supports --nosync
2017-02-06 15:15:39 +03:00
lvcreate --type raid10 --nosync -m 1 -Zn -i 3 -l 1 -n $lv1 $vg
2021-03-17 00:53:23 +03:00
_check_raid_in_loop $vg $lv1 "AAAAAA"
2016-08-08 14:52:35 +03:00
vgremove -ff $vg