2019-07-12 22:08:22 +03:00
#!/usr/bin/env bash
# Copyright (C) 2008 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
SKIP_WITH_LVMPOLLD = 1
. lib/inittest
2019-09-11 21:59:16 +03:00
xxd -v || skip
2019-07-12 22:08:22 +03:00
aux prepare_devs 1 256
get_devs
# Fill with random data so if the space between metadata
# copies are not zeroed the grep for zeros will fail.
2019-10-09 16:11:03 +03:00
dd if = /dev/urandom of = " $dev1 " bs = 1M count = 1 || true
dd if = /dev/urandom of = " $dev1 " bs = 1M skip = 15 count = 1 || true
2019-07-12 22:08:22 +03:00
pvcreate --pvmetadatacopies 2 " $dev1 "
vgcreate $SHARED " $vg " " $dev1 "
2023-02-09 18:05:40 +03:00
for i in $( seq 1 50) ; do lvcreate -l1 -an $vg ; done
2019-07-12 22:08:22 +03:00
# Check metadata copies are separated by zeroes in the first mda
dd if = " $dev1 " of = meta.raw bs = 1M count = 1
xxd meta.raw > meta.txt
2019-09-11 22:20:59 +03:00
# to help debug if the next grep fails
2019-09-12 19:19:44 +03:00
ls -l meta.txt
head -n 100 meta.txt
2019-10-16 17:46:48 +03:00
grep -A4 -B4 '01200:' meta.txt
2019-09-11 22:20:59 +03:00
2019-10-24 14:55:23 +03:00
_vg = " $vg "
_vg = " ${ _vg : 0 : 16 } "
grep -B1 " $_vg " meta.txt > meta.vg
2019-07-12 22:08:22 +03:00
cat meta.vg
2019-10-24 14:55:23 +03:00
grep -v " $_vg " meta.vg > meta.zeros
2019-07-12 22:08:22 +03:00
cat meta.zeros
grep '0000 0000 0000 0000 0000 0000 0000 0000' meta.zeros > meta.count
# wc will often equal 51, but some natural variability in
# metadata locations/content mean that some lines do not
# require a full line of zero padding, and will not match
# the grep for a full row of zeros. So, check that more
# than 20 lines match the full row of zeros (this is a
# random choice, and this isn't a perfect way to test for
# zero padding.)
2023-02-09 18:05:40 +03:00
test " $( wc -l < meta.count) " -gt 20
2019-07-12 22:08:22 +03:00
rm meta.raw meta.txt meta.vg meta.zeros meta.count
#
# Check metadata copies are separated by zeroes in the second mda
#
dd if = " $dev1 " of = meta.raw bs = 1M seek = 15 count = 1
xxd meta.raw > meta.txt
2019-10-24 14:55:23 +03:00
grep -B1 " $_vg " meta.txt > meta.vg
2019-07-12 22:08:22 +03:00
cat meta.vg
2019-10-24 14:55:23 +03:00
grep -v " $_vg " meta.vg > meta.zeros
2019-07-12 22:08:22 +03:00
cat meta.zeros
grep '0000 0000 0000 0000 0000 0000 0000 0000' meta.zeros > meta.count
2023-02-09 18:05:40 +03:00
test " $( wc -l < meta.count) " -gt 20
2019-07-12 22:08:22 +03:00
vgremove -ff $vg