2020-11-24 02:15:25 +03:00
#!/usr/bin/env bash
# Copyright (C) 2020 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
test_description = 'devices file with devnames'
2023-04-23 20:17:08 +03:00
SKIP_WITH_LVMPOLLD = 1
2020-11-24 02:15:25 +03:00
. lib/inittest
aux prepare_devs 7
RUNDIR = "/run"
test -d " $RUNDIR " || RUNDIR = "/var/run"
PVS_ONLINE_DIR = " $RUNDIR /lvm/pvs_online "
VGS_ONLINE_DIR = " $RUNDIR /lvm/vgs_online "
PVS_LOOKUP_DIR = " $RUNDIR /lvm/pvs_lookup "
_clear_online_files( ) {
# wait till udev is finished
aux udev_wait
rm -f " $PVS_ONLINE_DIR " /*
rm -f " $VGS_ONLINE_DIR " /*
rm -f " $PVS_LOOKUP_DIR " /*
}
DFDIR = " $LVM_SYSTEM_DIR /devices "
2021-03-28 03:09:42 +03:00
mkdir " $DFDIR " || true
2020-11-24 02:15:25 +03:00
DF = " $DFDIR /system.devices "
ORIG = " $DFDIR /orig.devices "
2024-04-11 17:21:11 +03:00
aux lvmconf "devices/use_devicesfile = 1" \
"global/event_activation = 1"
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
pvcreate " $dev1 "
ls " $DF "
grep " $dev1 " " $DF "
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
pvcreate " $dev2 "
grep " $dev2 " " $DF "
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
pvcreate " $dev3 "
grep " $dev3 " " $DF "
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
vgcreate $vg1 " $dev1 " " $dev2 "
2020-11-24 02:15:25 +03:00
# PVID with dashes for matching pvs -o+uuid output
2021-03-28 03:09:42 +03:00
OPVID1 = ` pvs " $dev1 " --noheading -o uuid | awk '{print $1}' `
OPVID2 = ` pvs " $dev2 " --noheading -o uuid | awk '{print $1}' `
OPVID3 = ` pvs " $dev3 " --noheading -o uuid | awk '{print $1}' `
2020-11-24 02:15:25 +03:00
# PVID without dashes for matching devices file fields
2021-03-28 03:09:42 +03:00
PVID1 = ` pvs " $dev1 " --noheading -o uuid | tr -d - | awk '{print $1}' `
PVID2 = ` pvs " $dev2 " --noheading -o uuid | tr -d - | awk '{print $1}' `
PVID3 = ` pvs " $dev3 " --noheading -o uuid | tr -d - | awk '{print $1}' `
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
lvmdevices --deldev " $dev3 "
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
not grep " $dev3 " " $DF "
not grep " $PVID3 " " $DF "
not pvs " $dev3 "
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
cp " $DF " " $ORIG "
2020-11-24 02:15:25 +03:00
lvcreate -l4 -an -i2 -n $lv1 $vg1
#
# when wrong idname devname is outside DF it's corrected if search_for=1
# by a general cmd, or by lvmdevices --addpvid
#
# when wrong idname devname is outside DF it's not found or corrected if
# search_for=0 by a general cmd, but will be by lvmdevices --addpvid
#
# when wrong idname devname is inside DF it's corrected if search_for=0|1
# by a general cmd, or by lvmdevices --addpvid
#
# pvscan --cache -aay does not update DF when devname= is wrong
#
# pvscan --cache -aay when idname devname is wrong:
# every dev is read and then skipped if pvid is not in DF
#
# commands still work with incorrect devname=
# . and they automatically correct the devname=
#
#
# idname changes to become incorrect, devname remains unchanged and correct
# . change idname to something outside DF
# . change idname to match another DF entry
# . swap idname of two DF entries
#
# edit DF idname, s/dev1/dev3/, where new dev is not in DF
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME= $dev1 |IDNAME= $dev3 | " " $ORIG " > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
not grep " $OPVID3 " out
not grep " $dev3 " out
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
2020-11-24 02:15:25 +03:00
# pvs fixed the DF
2021-03-28 03:09:42 +03:00
not grep " $PVID3 " " $DF "
not grep " $dev3 " " $DF "
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
cat " $DF "
sed -e " s|IDNAME= $dev1 |IDNAME= $dev3 | " " $ORIG " > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvcreate uses correct dev
2021-03-28 03:09:42 +03:00
lvcreate -l1 -n $lv2 -an $vg1 " $dev1 "
2020-11-24 02:15:25 +03:00
# lvcreate fixed the DF
2021-03-28 03:09:42 +03:00
not grep " $PVID3 " " $DF "
not grep " $dev3 " " $DF "
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
2020-11-24 02:15:25 +03:00
# pvs reports correct dev
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
not grep " $OPVID3 " out
not grep " $dev3 " out
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
2020-11-24 02:15:25 +03:00
lvremove $vg1 /$lv2
2021-03-28 03:09:42 +03:00
cat " $DF "
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME= $dev1 |IDNAME= $dev3 | " " $ORIG " > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvmdevices fixes the DF
lvmdevices --update
2021-03-28 03:09:42 +03:00
not grep " $PVID3 " " $DF "
not grep " $dev3 " " $DF "
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
# edit DF idname, s/dev1/dev2/, creating two entries with same idname
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME= $dev1 |IDNAME= $dev2 | " " $ORIG " > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
grep " $OPVID2 " out | tee out2
grep " $dev2 " out2
2020-11-24 02:15:25 +03:00
# pvs fixed the DF
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " IDNAME= $dev2 " out
cat " $DF "
sed -e " s|IDNAME= $dev1 |IDNAME= $dev2 | " " $ORIG " > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvcreate uses correct dev
2021-03-28 03:09:42 +03:00
lvcreate -l1 -n $lv2 -an $vg1 " $dev1 "
2020-11-24 02:15:25 +03:00
# lvcreate fixed the DF
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " IDNAME= $dev2 " out
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
grep " $OPVID2 " out | tee out2
grep " $dev2 " out2
2020-11-24 02:15:25 +03:00
lvremove $vg1 /$lv2
2021-03-28 03:09:42 +03:00
cat " $DF "
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME= $dev1 |IDNAME= $dev2 | " " $ORIG " > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvmdevices fixes the DF
lvmdevices --update
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " IDNAME= $dev2 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
# edit DF idname, swap dev1 and dev2
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME= $dev1 |IDNAME=tmpname| " " $ORIG " > tmp1.devices
2020-11-24 02:15:25 +03:00
sed -e " s|IDNAME= $dev2 |IDNAME= $dev1 | " tmp1.devices > tmp2.devices
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME=tmpname|IDNAME= $dev2 | " tmp2.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
grep " $OPVID2 " out | tee out2
grep " $dev2 " out2
2020-11-24 02:15:25 +03:00
# pvs fixed the DF
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " IDNAME= $dev2 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME= $dev1 |IDNAME=tmpname| " " $ORIG " > tmp1.devices
2020-11-24 02:15:25 +03:00
sed -e " s|IDNAME= $dev2 |IDNAME= $dev1 | " tmp1.devices > tmp2.devices
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME=tmpname|IDNAME= $dev2 | " tmp2.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvcreate uses correct dev
2021-03-28 03:09:42 +03:00
lvcreate -l1 -n $lv2 -an $vg1 " $dev1 "
2020-11-24 02:15:25 +03:00
# lvcreate fixed the DF
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " IDNAME= $dev2 " out
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
grep " $OPVID2 " out | tee out2
grep " $dev2 " out2
2020-11-24 02:15:25 +03:00
lvremove $vg1 /$lv2
2021-03-28 03:09:42 +03:00
cat " $DF "
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME= $dev1 |IDNAME=tmpname| " " $ORIG " > tmp1.devices
2020-11-24 02:15:25 +03:00
sed -e " s|IDNAME= $dev2 |IDNAME= $dev1 | " tmp1.devices > tmp2.devices
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME=tmpname|IDNAME= $dev2 | " tmp2.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvmdevices fixes the DF
lvmdevices --update
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " IDNAME= $dev2 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
#
# idname remains correct, devname changes to become incorrect
# . change devname to something outside DF
# . change devname to match another DF entry
# . swap devname of two DF entries
#
# edit DF devname, s/dev1/dev3/, where new dev is not in DF
2021-03-28 03:09:42 +03:00
sed -e " s|DEVNAME= $dev1 |DEVNAME= $dev3 | " " $ORIG " > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
not grep " $OPVID3 " out
not grep " $dev3 " out
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
2020-11-24 02:15:25 +03:00
# pvs fixed the DF
2021-03-28 03:09:42 +03:00
not grep " $PVID3 " " $DF "
not grep " $dev3 " " $DF "
grep " $PVID1 " " $DF " | tee out
grep " DEVNAME= $dev1 " out
cat " $DF "
sed -e " s|DEVNAME= $dev1 |DEVNAME= $dev3 | " " $ORIG " > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvmdevices fixes the DF
lvmdevices --update
2021-03-28 03:09:42 +03:00
not grep " $PVID3 " " $DF "
not grep " $dev3 " " $DF "
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
# edit DF devname, s/dev1/dev2/, creating two entries with same devname
2021-03-28 03:09:42 +03:00
sed -e " s|DEVNAME= $dev1 |DEVNAME= $dev2 | " " $ORIG " > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
grep " $OPVID2 " out | tee out2
grep " $dev2 " out2
2020-11-24 02:15:25 +03:00
# pvs fixed the DF
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " DEVNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " DEVNAME= $dev2 " out
cat " $DF "
sed -e " s|DEVNAME= $dev1 |DEVNAME= $dev2 | " " $ORIG " > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvmdevices fixes the DF
lvmdevices --update
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " IDNAME= $dev2 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
# edit DF devname, swap dev1 and dev2
2021-03-28 03:09:42 +03:00
sed -e " s|DEVNAME= $dev1 |DEVNAME=tmpname| " " $ORIG " > tmp1.devices
2020-11-24 02:15:25 +03:00
sed -e " s|DEVNAME= $dev2 |DEVNAME= $dev1 | " tmp1.devices > tmp2.devices
2021-03-28 03:09:42 +03:00
sed -e " s|DEVNAME=tmpname|DEVNAME= $dev2 | " tmp2.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
grep " $OPVID2 " out | tee out2
grep " $dev2 " out2
2020-11-24 02:15:25 +03:00
# pvs fixed the DF
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " DEVNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " DEVNAME= $dev2 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
2021-03-28 03:09:42 +03:00
sed -e " s|DEVNAME= $dev1 |DEVNAME=tmpname| " " $ORIG " > tmp1.devices
2020-11-24 02:15:25 +03:00
sed -e " s|DEVNAME= $dev2 |DEVNAME= $dev1 | " tmp1.devices > tmp2.devices
2021-03-28 03:09:42 +03:00
sed -e " s|DEVNAME=tmpname|DEVNAME= $dev2 | " tmp2.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvmdevices fixes the DF
lvmdevices --update
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " IDNAME= $dev2 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
#
# idname and devname change, both become incorrect
# . change idname&devname to something outside DF
# . change idname&devname to match another DF entry
# . swap idname&devname of two DF entries
#
# edit DF idname&devname, s/dev1/dev3/, where new dev is not in DF
2021-03-28 03:09:42 +03:00
sed -e " s|DEVNAME= $dev1 |DEVNAME= $dev3 | " " $ORIG " > tmp1.devices
sed -e " s|IDNAME= $dev1 |IDNAME= $dev3 | " tmp1.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
not grep " $OPVID3 " out
not grep " $dev3 " out
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
2020-11-24 02:15:25 +03:00
# pvs fixed the DF
2021-03-28 03:09:42 +03:00
not grep " $PVID3 " " $DF "
not grep " $dev3 " " $DF "
grep " $PVID1 " " $DF " | tee out
grep " DEVNAME= $dev1 " out
grep " IDNAME= $dev1 " out
cat " $DF "
sed -e " s|DEVNAME= $dev1 |DEVNAME= $dev3 | " " $ORIG " > tmp1.devices
sed -e " s|IDNAME= $dev1 |IDNAME= $dev3 | " tmp1.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvmdevices fixes the DF
lvmdevices --update
2021-03-28 03:09:42 +03:00
not grep " $PVID3 " " $DF "
not grep " $dev3 " " $DF "
grep " $PVID1 " " $DF " | tee out
grep " DEVNAME= $dev1 " out
grep " IDNAME= $dev1 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
# edit DF idname&devname, s/dev1/dev2/, creating two entries with same devname
2021-03-28 03:09:42 +03:00
sed -e " s|DEVNAME= $dev1 |DEVNAME= $dev2 | " tmp1.devices > " $DF "
sed -e " s|IDNAME= $dev1 |IDNAME= $dev2 | " tmp1.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
grep " $OPVID2 " out | tee out2
grep " $dev2 " out2
2020-11-24 02:15:25 +03:00
# pvs fixed the DF
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " DEVNAME= $dev1 " out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " DEVNAME= $dev2 " out
grep " IDNAME= $dev2 " out
cat " $DF "
sed -e " s|DEVNAME= $dev1 |DEVNAME= $dev2 | " tmp1.devices > " $DF "
sed -e " s|IDNAME= $dev1 |IDNAME= $dev2 | " tmp1.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvmdevices fixes the DF
lvmdevices --update
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " DEVNAME= $dev1 " out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " DEVNAME= $dev2 " out
grep " IDNAME= $dev2 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
# edit DF devname, swap dev1 and dev2
2021-03-28 03:09:42 +03:00
sed -e " s|DEVNAME= $dev1 |DEVNAME=tmpname| " " $ORIG " > tmp1.devices
2020-11-24 02:15:25 +03:00
sed -e " s|DEVNAME= $dev2 |DEVNAME= $dev1 | " tmp1.devices > tmp2.devices
sed -e " s|DEVNAME=tmpname|DEVNAME= $dev2 | " tmp2.devices > tmp3.devices
sed -e " s|IDNAME= $dev1 |IDNAME=tmpname| " tmp3.devices > tmp4.devices
sed -e " s|IDNAME= $dev2 |IDNAME= $dev1 | " tmp4.devices > tmp5.devices
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME=tmpname|IDNAME= $dev2 | " tmp5.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# pvs reports correct info
pvs -o+uuid | tee pvs.out
grep $vg1 pvs.out > out
2021-03-28 03:09:42 +03:00
grep " $OPVID1 " out | tee out2
grep " $dev1 " out2
grep " $OPVID2 " out | tee out2
grep " $dev2 " out2
2020-11-24 02:15:25 +03:00
# pvs fixed the DF
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " DEVNAME= $dev1 " out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " DEVNAME= $dev2 " out
grep " IDNAME= $dev2 " out
cat " $DF "
sed -e " s|DEVNAME= $dev1 |DEVNAME=tmpname| " " $ORIG " > tmp1.devices
2020-11-24 02:15:25 +03:00
sed -e " s|DEVNAME= $dev2 |DEVNAME= $dev1 | " tmp1.devices > tmp2.devices
sed -e " s|DEVNAME=tmpname|DEVNAME= $dev2 | " tmp2.devices > tmp3.devices
sed -e " s|IDNAME= $dev1 |IDNAME=tmpname| " tmp3.devices > tmp4.devices
sed -e " s|IDNAME= $dev2 |IDNAME= $dev1 | " tmp4.devices > tmp5.devices
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME=tmpname|IDNAME= $dev2 | " tmp5.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
# lvmdevices fixes the DF
lvmdevices --update
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " DEVNAME= $dev1 " out
grep " IDNAME= $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " DEVNAME= $dev2 " out
grep " IDNAME= $dev2 " out
cat " $DF "
2020-11-24 02:15:25 +03:00
#
# check that pvscan --cache -aay does the right thing:
#
# idname and devname change, both become incorrect
# . change idname&devname to something outside DF
# . swap idname&devname of two DF entries
#
# edit DF idname&devname, s/dev1/dev3/, where new dev is not in DF
2021-03-28 03:09:42 +03:00
sed -e " s|DEVNAME= $dev1 |DEVNAME= $dev3 | " " $ORIG " > tmp1.devices
sed -e " s|IDNAME= $dev1 |IDNAME= $dev3 | " tmp1.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
_clear_online_files
2021-03-28 03:09:42 +03:00
pvscan --cache -aay " $dev1 "
pvscan --cache -aay " $dev2 "
pvscan --cache -aay " $dev3 "
cat " $DF "
2020-11-24 02:15:25 +03:00
# pvscan does not fix DF
2021-03-28 03:09:42 +03:00
grep " $dev3 " " $DF "
not grep " $dev1 " " $DF "
2021-09-21 19:02:50 +03:00
ls " $RUNDIR /lvm/pvs_online/ $PVID1 "
2020-11-24 02:15:25 +03:00
ls " $RUNDIR /lvm/pvs_online/ $PVID2 "
2021-09-21 19:02:50 +03:00
not ls " $RUNDIR /lvm/pvs_online/ $PVID3 "
2023-09-13 20:28:47 +03:00
lvs -qq -o active $vg1 /$lv1 | grep active
2020-11-24 02:15:25 +03:00
# pvs updates the DF
pvs | tee out
2021-03-28 03:09:42 +03:00
grep " $dev1 " out
grep " $dev2 " out
not grep " $dev3 " out
grep " $dev1 " " $DF "
grep " $dev2 " " $DF "
not grep " $dev3 " " $DF "
2020-11-24 02:15:25 +03:00
vgchange -an $vg1
# edit DF idname&devname, swap dev1 and dev2
vgremove -y $vg1
2021-03-28 03:09:42 +03:00
vgcreate $vg1 " $dev1 "
2020-11-24 02:15:25 +03:00
lvcreate -n $lv1 -l1 -an $vg1
2021-03-28 03:09:42 +03:00
vgcreate $vg2 " $dev2 "
2020-11-24 02:15:25 +03:00
lvcreate -n $lv2 -l1 -an $vg2
2021-03-28 03:09:42 +03:00
cat " $DF "
sed -e " s|DEVNAME= $dev1 |DEVNAME=tmpname| " " $ORIG " > tmp1.devices
2020-11-24 02:15:25 +03:00
sed -e " s|DEVNAME= $dev2 |DEVNAME= $dev1 | " tmp1.devices > tmp2.devices
sed -e " s|DEVNAME=tmpname|DEVNAME= $dev2 | " tmp2.devices > tmp3.devices
sed -e " s|IDNAME= $dev1 |IDNAME=tmpname| " tmp3.devices > tmp4.devices
sed -e " s|IDNAME= $dev2 |IDNAME= $dev1 | " tmp4.devices > tmp5.devices
2021-03-28 03:09:42 +03:00
sed -e " s|IDNAME=tmpname|IDNAME= $dev2 | " tmp5.devices > " $DF "
cat " $DF "
2020-11-24 02:15:25 +03:00
_clear_online_files
# pvscan creates the correct online files and activates correct vg
2021-03-28 03:09:42 +03:00
pvscan --cache -aay " $dev1 "
2020-11-24 02:15:25 +03:00
ls " $RUNDIR /lvm/pvs_online/ $PVID1 "
ls " $RUNDIR /lvm/vgs_online/ $vg1 "
not ls " $RUNDIR /lvm/pvs_online/ $PVID2 "
not ls " $RUNDIR /lvm/vgs_online/ $vg2 "
# don't use lvs because it would fix DF before we check it
dmsetup status $vg1 -$lv1
not dmsetup status $vg2 -$lv2
2021-03-28 03:09:42 +03:00
pvscan --cache -aay " $dev2 "
2020-11-24 02:15:25 +03:00
ls " $RUNDIR /lvm/pvs_online/ $PVID2 "
ls " $RUNDIR /lvm/vgs_online/ $vg2 "
dmsetup status $vg2 -$lv2
2021-03-28 03:09:42 +03:00
pvscan --cache -aay " $dev3 "
2020-11-24 02:15:25 +03:00
not ls " $RUNDIR /lvm/pvs_online/ $PVID3 "
# pvscan did not correct DF
2021-03-28 03:09:42 +03:00
cat " $DF "
grep " $PVID1 " " $DF " | tee out
grep " $dev2 " out
not grep " $dev1 " out
grep " $PVID2 " " $DF " | tee out
grep " $dev1 " out
not grep " $dev2 " out
2020-11-24 02:15:25 +03:00
# pvs corrects DF
pvs
2021-03-28 03:09:42 +03:00
grep " $PVID1 " " $DF " | tee out
grep " $dev1 " out
not grep " $dev2 " out
grep " $PVID2 " " $DF " | tee out
grep " $dev2 " out
not grep " $dev1 " out
2020-11-24 02:15:25 +03:00
2021-11-16 18:29:24 +03:00
vgchange -an $vg1
vgchange -an $vg2
vgremove -ff $vg1
vgremove -ff $vg2
2023-08-04 00:20:43 +03:00
# bz 2225419
touch " $DF "
vgcreate $vg1 " $dev1 "
vgcreate $vg2 " $dev2 "
# PVID with dashes for matching pvs -o+uuid output
OPVID1 = ` pvs " $dev1 " --noheading -o uuid | awk '{print $1}' `
OPVID2 = ` pvs " $dev2 " --noheading -o uuid | awk '{print $1}' `
# PVID without dashes for matching devices file fields
PVID1 = ` pvs " $dev1 " --noheading -o uuid | tr -d - | awk '{print $1}' `
PVID2 = ` pvs " $dev2 " --noheading -o uuid | tr -d - | awk '{print $1}' `
NODEV = ${ dev1 } 12345
lvmdevices --deldev " $dev1 "
lvmdevices --deldev " $dev2 "
# dev1 is correct
echo " IDTYPE=devname IDNAME= $dev1 DEVNAME= $dev1 PVID= $PVID1 " >> " $DF "
# dev2 has no PVID
echo " IDTYPE=devname IDNAME= $dev2 DEVNAME= $dev2 PVID=. " >> " $DF "
# Non-existant device has PVID for dev2
echo " IDTYPE=devname IDNAME= $NODEV DEVNAME= $NODEV PVID= $PVID2 " >> " $DF "
cat " $DF "
pvs -o name,uuid | tee out
grep " $dev1 " out | tee out1
grep " $dev2 " out | tee out2
grep " $OPVID1 " out1
grep " $OPVID2 " out2
not grep " $NODEV " out
not grep " $NODEV " " $DF "
grep " IDNAME= $dev1 " " $DF " | tee out1
grep " IDNAME= $dev2 " " $DF " | tee out2
grep " $PVID1 " out1
grep " $PVID2 " out2
grep " DEVNAME= $dev1 " out1
grep " DEVNAME= $dev2 " out2
rm " $DF "
aux wipefs_a " $dev1 " " $dev2 "
2022-08-19 21:31:22 +03:00
# bz 2119473
aux lvmconf "devices/search_for_devnames = \"none\""
sed -e " s|DEVNAME= $dev1 |DEVNAME=.| " " $ORIG " > tmp1.devices
sed -e " s|IDNAME= $dev1 |IDNAME=.| " tmp1.devices > " $DF "
pvs
lvmdevices
pvcreate -ff --yes --uuid " $PVID1 " --norestorefile $dev1
grep " $PVID1 " " $DF " | tee out
grep " DEVNAME= $dev1 " out
grep " IDNAME= $dev1 " out
aux lvmconf "devices/search_for_devnames = \"auto\""
2021-11-16 18:29:24 +03:00
# devnames change so the new devname now refers to a filtered device,
# e.g. an mpath or md component, which is not scanned
wait_md_create( ) {
local md = $1
while :; do
if ! grep " $( basename $md ) " /proc/mdstat; then
echo " $md not ready "
cat /proc/mdstat
sleep 2
else
break
fi
done
echo " $md " > WAIT_MD_DEV
}
2023-07-15 11:39:56 +03:00
aux wipefs_a " $dev1 " " $dev2 " " $dev3 " " $dev4 "
2021-11-16 18:29:24 +03:00
rm " $DF "
touch " $DF "
vgcreate $vg1 " $dev1 " " $dev2 "
cat " $DF "
cp " $DF " " $ORIG "
# PVID with dashes for matching pvs -o+uuid output
OPVID1 = ` pvs " $dev1 " --noheading -o uuid | awk '{print $1}' `
OPVID2 = ` pvs " $dev2 " --noheading -o uuid | awk '{print $1}' `
# PVID without dashes for matching devices file fields
PVID1 = ` pvs " $dev1 " --noheading -o uuid | tr -d - | awk '{print $1}' `
PVID2 = ` pvs " $dev2 " --noheading -o uuid | tr -d - | awk '{print $1}' `
2023-02-23 17:37:39 +03:00
aux mdadm_create --metadata= 1.0 --level 1 --raid-devices= 2 " $dev3 " " $dev4 "
mddev = $( < MD_DEV)
2021-11-16 18:29:24 +03:00
wait_md_create " $mddev "
sed -e " s|DEVNAME= $dev1 |DEVNAME= $dev3 | " " $ORIG " > tmp1.devices
sed -e " s|IDNAME= $dev1 |IDNAME= $dev3 | " tmp1.devices > " $DF "
cat " $DF "
pvs -o+uuid | tee out
grep " $dev1 " out
grep " $dev2 " out
grep " $OPVID1 " out
grep " $OPVID2 " out
not grep " $dev3 " out
not grep " $dev4 " out
grep " $dev1 " " $DF "
grep " $dev2 " " $DF "
grep " $PVID1 " " $DF "
grep " $PVID2 " " $DF "
not grep " $dev3 " " $DF "
not grep " $dev4 " " $DF "
mdadm --stop " $mddev "
aux udev_wait
2020-11-24 02:15:25 +03:00
vgremove -ff $vg1