mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_03_12-tests-check-full-zeroing-of-thin-pool-metadata.patch

abb29f
 test/shell/thin-zero-meta.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++
abb29f
 1 file changed, 68 insertions(+)
abb29f
 create mode 100644 test/shell/thin-zero-meta.sh
abb29f
abb29f
diff --git a/test/shell/thin-zero-meta.sh b/test/shell/thin-zero-meta.sh
abb29f
new file mode 100644
abb29f
index 0000000..6a15a73
abb29f
--- /dev/null
abb29f
+++ b/test/shell/thin-zero-meta.sh
abb29f
@@ -0,0 +1,68 @@
abb29f
+#!/usr/bin/env bash
abb29f
+
abb29f
+# Copyright (C) 2021 Red Hat, Inc. All rights reserved.
abb29f
+#
abb29f
+# This copyrighted material is made available to anyone wishing to use,
abb29f
+# modify, copy, or redistribute it subject to the terms and conditions
abb29f
+# of the GNU General Public License v.2.
abb29f
+#
abb29f
+# You should have received a copy of the GNU General Public License
abb29f
+# along with this program; if not, write to the Free Software Foundation,
abb29f
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
abb29f
+
abb29f
+# Test how zeroing of thin-pool metadata works
abb29f
+
abb29f
+SKIP_WITH_LVMLOCKD=1
abb29f
+SKIP_WITH_LVMPOLLD=1
abb29f
+
abb29f
+export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
abb29f
+
abb29f
+. lib/inittest
abb29f
+
abb29f
+#
abb29f
+# Main
abb29f
+#
abb29f
+aux have_thin 1 3 0 || skip
abb29f
+aux have_cache 1 3 0 || skip
abb29f
+
abb29f
+aux prepare_vg 3 40000
abb29f
+
abb29f
+# Create mostly-zero devs only front of it has some 'real' back-end
abb29f
+aux zero_dev "$dev1" "$(( $(get first_extent_sector "$dev1") + 8192 )):"
abb29f
+aux zero_dev "$dev2" "$(( $(get first_extent_sector "$dev2") + 8192 )):"
abb29f
+aux zero_dev "$dev3" "$(( $(get first_extent_sector "$dev3") + 8192 )):"
abb29f
+
abb29f
+# Prepare randomly filled 4M LV on dev2
abb29f
+lvcreate -L16G -n $lv1 $vg "$dev2"
abb29f
+dd if=/dev/urandom of="$DM_DEV_DIR/$vg/$lv1" bs=1M count=4 oflag=direct  || true
abb29f
+lvremove -f $vg
abb29f
+
abb29f
+for i in 0 1
abb29f
+do
abb29f
+	aux lvmconf "allocation/zero_metadata = $i"
abb29f
+
abb29f
+	# Lvm2 should allocate metadata on dev2
abb29f
+	lvcreate -T -L10G --poolmetadatasize 16G $vg/pool "$dev1" "$dev2"
abb29f
+	lvchange -an $vg
abb29f
+
abb29f
+	lvs -ao+seg_pe_ranges $vg
abb29f
+	lvchange -ay $vg/pool_tmeta --yes
abb29f
+
abb29f
+	# Skip past 1.2M which is 'created' by  thin-pool initialization
abb29f
+	hexdump -C -n 200 -s 2000000 "$DM_DEV_DIR/$vg/pool_tmeta" | tee out
abb29f
+
abb29f
+	# When fully zeroed, it should be zero - so almost no output from hexdump
abb29f
+	case "$i" in
abb29f
+	0) test $(wc -l < out) -ge 10 ;; # should not be zeroed
abb29f
+	1) test $(wc -l < out) -le 10 ;; # should be zeroed
abb29f
+	esac
abb29f
+
abb29f
+	lvremove -f $vg/pool
abb29f
+done
abb29f
+
abb29f
+# Check lvm2 spots error during full zeroing of metadata device
abb29f
+aux error_dev "$dev2" "$(( $(get first_extent_sector "$dev2") + 32 )):"
abb29f
+not lvcreate -T -L10G --poolmetadatasize 16G $vg/pool "$dev1" "$dev2" |& tee err
abb29f
+grep "Failed to initialize logical volume" err
abb29f
+
abb29f
+vgremove -ff $vg