2018-05-24 12:21:49 +03:00
#!/usr/bin/env bash
2021-03-23 00:23:53 +03:00
# Copyright (C) 2018-2021 Red Hat, Inc. All rights reserved.
2018-05-24 12:21:49 +03: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,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
# TODO: once code get fixed, add matching 'check' calls
2018-06-01 00:18:53 +03:00
2018-05-24 12:21:49 +03:00
SKIP_WITH_LVMPOLLD = 1
. lib/inittest
test -f /proc/mdstat && grep -q raid1 /proc/mdstat || \
modprobe raid1 || skip
aux lvmconf 'devices/md_component_detection = 1'
aux extend_filter_LVMTEST "a|/dev/md|"
aux prepare_devs 4
2018-06-05 19:45:08 +03:00
pvcreate " $dev2 "
2021-03-23 00:23:53 +03:00
aux mdadm_create --metadata= 1.0 --level= 0 --chunk= 64 --raid-devices= 2 " $dev1 " " $dev2 "
pvs | tee out
not grep pv2 out
2018-06-05 19:45:08 +03:00
2018-06-01 00:18:53 +03:00
vgcreate $SHARED $vg " $dev3 " " $dev4 "
2018-05-24 12:21:49 +03:00
# create 2 disk MD raid1 array
# by default using metadata format 1.0 with data at the end of device
2021-03-23 00:23:53 +03:00
aux mdadm_create --metadata= 1.0 --level= 1 --chunk= 64 --raid-devices= 2 " $dev1 " " $dev2 "
2018-05-24 12:21:49 +03:00
mddev = $( < MD_DEV)
pvdev = $( < MD_DEV_PV)
2018-05-24 16:20:22 +03:00
sleep 3
2018-05-24 12:21:49 +03:00
mdadm --stop " $mddev "
# copy fake PV/VG header PV3 -> PV2 (which is however md raid1 leg)
dd if = " $dev3 " of = " $dev2 " bs = 64k count = 1 conv = fdatasync
# remove VG on PV3 & PV4
vgremove -f $vg
aux udev_wait
# too bad 'dd' wakes up md array reassembling
2021-03-23 00:23:53 +03:00
mdadm --detail " $mddev " || true
mdadm --stop " $mddev " || true
2021-03-28 13:18:40 +03:00
sleep 1
2018-05-24 12:21:49 +03:00
# print what blkid thinks about each PV
for i in " $dev1 " " $dev2 " " $dev3 " " $dev4 "
do
2021-03-26 18:12:47 +03:00
blkid -c /dev/null " $i " || echo "Unknown signature"
2018-05-24 12:21:49 +03:00
done
# expect open count for each PV to be 0
dmsetup info -c
2021-03-23 00:23:53 +03:00
pvs " $dev2 " " $dev3 " || true
2018-05-24 12:21:49 +03:00
# still expect open count for each PV to be 0
dmsetup info -c
2021-03-23 00:23:53 +03:00
pvs " $dev3 " " $dev2 " || true
2018-05-24 12:21:49 +03:00
# and again we expect open count for each PV to be 0
dmsetup info -c
dmsetup table
# even after 3 second of possible hidden raid array assembling
sleep 3
dmsetup info -c
# if for any reason array went up - stop it again
2018-05-24 16:20:22 +03:00
if mdadm --detail " $mddev " ; then
2018-05-24 12:21:49 +03:00
mdadm --stop " $mddev "
aux udev_wait
should not mdadm --detail " $mddev "
2018-05-24 16:20:22 +03:00
fi
2018-05-24 12:21:49 +03:00
2018-05-24 16:20:22 +03:00
# now reassemble array from PV1 & PV2
2021-03-26 18:07:24 +03:00
aux mdadm_assemble --verbose " $mddev " " $dev1 " " $dev2 "
2018-05-24 12:21:49 +03:00
sleep 1
# and let 'fake hdr' to be fixed from master/primary leg
2018-05-24 16:20:22 +03:00
# (when mdadm supports repair)
if mdadm --action= repair " $mddev " ; then
sleep 1
2018-06-15 19:42:10 +03:00
pvscan -vvvv
2018-05-24 16:20:22 +03:00
# should be showing correctly PV3 & PV4
2021-03-23 00:23:53 +03:00
pvs " $dev3 " " $dev4 "
2018-05-24 16:20:22 +03:00
fi