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

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