2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2017-06-24 00:20:01 +03:00
# Copyright (C) 2013-2017 Red Hat, Inc. All rights reserved.
2013-05-31 19:35:24 +04:00
#
# 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,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2013-05-31 19:35:24 +04:00
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2013-05-31 19:35:24 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2014-05-24 00:35:05 +04:00
aux have_raid 1 3 0 || skip
2014-05-22 14:00:46 +04:00
aux raid456_replace_works || skip
2013-05-31 19:35:24 +04:00
2015-04-08 23:44:16 +03:00
aux lvmconf 'allocation/maximise_cling = 0' \
2017-06-24 00:20:01 +03:00
'allocation/mirror_logs_require_separate_pvs = 1' \
'activation/raid_fault_policy = "allocate"'
2013-05-31 19:35:24 +04:00
2017-02-10 00:41:28 +03:00
aux prepare_vg 8 80
2017-07-15 01:13:33 +03:00
get_devs
2013-05-31 19:35:24 +04:00
2017-12-01 20:59:55 +03:00
offset = $( get first_extent_sector $dev1 )
2016-09-21 01:38:38 +03:00
function delay
{
2017-07-15 01:13:33 +03:00
for d in " ${ DEVICES [@] } " ; do
2017-12-01 20:59:55 +03:00
aux delay_dev " $d " 0 $1 " $offset "
2016-09-21 01:38:38 +03:00
done
}
2016-04-19 00:09:17 +03:00
# It's possible small raid arrays do have problems with reporting in-sync.
# So try bigger size
2016-09-21 01:38:38 +03:00
RAID_SIZE = 32
# Fast sync and repair afterwards
delay 0
2017-06-24 00:20:01 +03:00
# RAID1 transient failure check
lvcreate --type raid1 -m 1 -L $RAID_SIZE -n $lv1 $vg " $dev1 " " $dev2 "
aux wait_for_sync $vg $lv1
# enforce replacing live rimage leg with error target
dmsetup remove -f $vg -${ lv1 } _rimage_1 || true
# let it notice there is problem
echo a > " $DM_DEV_DIR / $vg / $lv1 "
check grep_dmsetup status $vg -$lv1 AD
lvconvert -y --repair $vg /$lv1 " $dev3 "
lvs -a -o+devices $vg
aux wait_for_sync $vg $lv1
# Raid should have fixed device
check grep_dmsetup status $vg -$lv1 AA
check lv_on $vg ${ lv1 } _rimage_1 " $dev3 "
lvremove -ff $vg /$lv1
2016-09-21 01:38:38 +03:00
# RAID1 dual-leg single replace after initial sync
lvcreate --type raid1 -m 1 -L $RAID_SIZE -n $lv1 $vg " $dev1 " " $dev2 "
aux wait_for_sync $vg $lv1
aux disable_dev " $dev2 "
lvconvert -y --repair $vg /$lv1
vgreduce --removemissing $vg
aux enable_dev " $dev2 "
vgextend $vg " $dev2 "
lvremove -ff $vg /$lv1
# Delayed sync to allow for repair during rebuild
delay 50
# RAID1 triple-leg single replace during initial sync
lvcreate --type raid1 -m 2 -L $RAID_SIZE -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 "
aux disable_dev " $dev2 " " $dev3 "
2016-11-04 03:23:08 +03:00
# FIXME 2016/11/04 AGK: Disabled next line as it fails to guarantee it is not already in sync.
#not lvconvert -y --repair $vg/$lv1
2016-09-21 01:38:38 +03:00
aux wait_for_sync $vg $lv1
lvconvert -y --repair $vg /$lv1
vgreduce --removemissing $vg
aux enable_dev " $dev2 " " $dev3 "
vgextend $vg " $dev2 " " $dev3 "
lvremove -ff $vg /$lv1
# Larger RAID size possible for striped RAID
2016-04-19 00:09:17 +03:00
RAID_SIZE = 64
2016-09-21 01:38:38 +03:00
# Fast sync and repair afterwards
delay 0
# RAID5 single replace after initial sync
2016-04-19 00:09:17 +03:00
lvcreate --type raid5 -i 2 -L $RAID_SIZE -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 "
2013-05-31 19:35:24 +04:00
aux wait_for_sync $vg $lv1
aux disable_dev " $dev3 "
2017-03-09 04:35:57 +03:00
vgreduce --removemissing -f $vg
2013-05-31 19:35:24 +04:00
lvconvert -y --repair $vg /$lv1
aux enable_dev " $dev3 "
2017-03-09 04:35:57 +03:00
pvcreate -yff " $dev3 "
2013-05-31 19:35:24 +04:00
vgextend $vg " $dev3 "
2016-09-21 01:38:38 +03:00
lvremove -ff $vg /$lv1
2013-05-31 19:35:24 +04:00
2016-09-21 01:38:38 +03:00
# Delayed sync to allow for repair during rebuild
2017-01-07 01:37:46 +03:00
delay 60
2016-09-21 01:38:38 +03:00
# RAID5 single replace during initial sync
lvcreate --type raid5 -i 2 -L $RAID_SIZE -n $lv1 $vg " $dev1 " " $dev2 " " $dev3 "
aux disable_dev " $dev3 "
2017-01-07 01:37:46 +03:00
# FIXME: there is quite big sleep on several 'status' read retries
# so over 3sec - it may actually finish full sync
# Use 'should' for this test result.
should not lvconvert -y --repair $vg /$lv1
2016-09-21 01:38:38 +03:00
aux wait_for_sync $vg $lv1
lvconvert -y --repair $vg /$lv1
vgreduce --removemissing $vg
aux enable_dev " $dev3 "
vgextend $vg " $dev3 "
lvremove -ff $vg /$lv1
# Fast sync and repair afterwards
delay 0
# RAID6 double replace after initial sync
2016-04-19 00:09:17 +03:00
lvcreate --type raid6 -i 3 -L $RAID_SIZE -n $lv1 $vg \
2013-05-31 19:35:24 +04:00
" $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 "
aux wait_for_sync $vg $lv1
aux disable_dev " $dev4 " " $dev5 "
lvconvert -y --repair $vg /$lv1
vgreduce --removemissing $vg
2016-09-21 01:38:38 +03:00
aux enable_dev " $dev4 " " $dev5 "
2013-05-31 19:35:24 +04:00
vgextend $vg " $dev4 " " $dev5 "
2016-09-21 01:38:38 +03:00
lvremove -ff $vg /$lv1
# Delayed sync to allow for repair during rebuild
delay 50
# RAID6 single replace after initial sync
lvcreate --type raid6 -i 3 -L $RAID_SIZE -n $lv1 $vg \
" $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 "
aux disable_dev " $dev4 "
not lvconvert -y --repair $vg /$lv1
delay 0 # Fast sync and repair afterwards
aux disable_dev " $dev4 " # Need to disable again after changing delay
aux wait_for_sync $vg $lv1
lvconvert -y --repair $vg /$lv1
vgreduce --removemissing $vg
aux enable_dev " $dev4 "
vgextend $vg " $dev4 "
lvremove -ff $vg /$lv1
# Delayed sync to allow for repair during rebuild
delay 50
# RAID10 single replace after initial sync
lvcreate --type raid10 -m 1 -i 2 -L $RAID_SIZE -n $lv1 $vg \
" $dev1 " " $dev2 " " $dev3 " " $dev4 "
aux disable_dev " $dev4 "
not lvconvert -y --repair $vg /$lv1
delay 0 # Fast sync and repair afterwards
aux disable_dev " $dev4 " # Need to disable again after changing delay
aux disable_dev " $dev1 "
aux wait_for_sync $vg $lv1
lvconvert -y --repair $vg /$lv1
vgreduce --removemissing $vg
aux enable_dev " $dev4 "
vgextend $vg " $dev4 "
lvremove -ff $vg /$lv1
2013-05-31 19:35:24 +04:00
vgremove -ff $vg