mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_03_10-test-repair-of-thin-pool-used-by-foreign-apps.patch

aa5752
 test/shell/thin-foreign-repair.sh | 72 +++++++++++++++++++++++++++++++++++++++
aa5752
 1 file changed, 72 insertions(+)
aa5752
 create mode 100644 test/shell/thin-foreign-repair.sh
aa5752
aa5752
diff --git a/test/shell/thin-foreign-repair.sh b/test/shell/thin-foreign-repair.sh
aa5752
new file mode 100644
aa5752
index 0000000..147a9a0
aa5752
--- /dev/null
aa5752
+++ b/test/shell/thin-foreign-repair.sh
aa5752
@@ -0,0 +1,72 @@
aa5752
+#!/usr/bin/env bash
aa5752
+
aa5752
+# Copyright (C) 2020 Red Hat, Inc. All rights reserved.
aa5752
+#
aa5752
+# This copyrighted material is made available to anyone wishing to use,
aa5752
+# modify, copy, or redistribute it subject to the terms and conditions
aa5752
+# of the GNU General Public License v.2.
aa5752
+#
aa5752
+# You should have received a copy of the GNU General Public License
aa5752
+# along with this program; if not, write to the Free Software Foundation,
aa5752
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
aa5752
+
aa5752
+# test foreing user of thin-pool
aa5752
+
aa5752
+
aa5752
+SKIP_WITH_LVMPOLLD=1
aa5752
+
aa5752
+. lib/inittest
aa5752
+
aa5752
+cleanup_mounted_and_teardown()
aa5752
+{
aa5752
+	dmsetup remove $THIN || true
aa5752
+	vgremove -ff $vg
aa5752
+	aux teardown
aa5752
+}
aa5752
+
aa5752
+#
aa5752
+# Main
aa5752
+#
aa5752
+aux have_thin 1 0 0 || skip
aa5752
+which mkfs.ext4 || skip
aa5752
+
aa5752
+# Use our mkfs config file to get approximately same results
aa5752
+# TODO: maybe use it for all test via some 'prepare' function
aa5752
+export MKE2FS_CONFIG="$TESTOLDPWD/lib/mke2fs.conf"
aa5752
+
aa5752
+aux prepare_vg 2 64
aa5752
+
aa5752
+# Create named pool only
aa5752
+lvcreate -L2 -T $vg/pool
aa5752
+
aa5752
+POOL="$vg-pool"
aa5752
+THIN="${PREFIX}_thin"
aa5752
+
aa5752
+# Foreing user is using own ioctl command to create thin devices
aa5752
+dmsetup message $POOL 0 "create_thin 0"
aa5752
+dmsetup message $POOL 0 "set_transaction_id 0 2"
aa5752
+
aa5752
+# Once the transaction id has changed, lvm2 shall not be able to create thinLV
aa5752
+fail lvcreate -V10 $vg/pool
aa5752
+
aa5752
+trap 'cleanup_mounted_and_teardown' EXIT
aa5752
+
aa5752
+# 20M thin device
aa5752
+dmsetup create "$THIN" --table "0 40960 thin $DM_DEV_DIR/mapper/$POOL 0"
aa5752
+
aa5752
+mkfs.ext4 "$DM_DEV_DIR/mapper/$THIN"
aa5752
+
aa5752
+dmsetup remove "$THIN"
aa5752
+
aa5752
+lvchange -an $vg/pool
aa5752
+
aa5752
+# Repair thin-pool used by 'foreing' apps (setting their own tid)
aa5752
+lvconvert --repair $vg/pool 2>&1 | tee out
aa5752
+
aa5752
+not grep "Transaction id" out
aa5752
+
aa5752
+lvchange -ay $vg/pool
aa5752
+
aa5752
+dmsetup create "$THIN" --table "0 40960 thin $DM_DEV_DIR/mapper/$POOL 0"
aa5752
+
aa5752
+fsck -n "$DM_DEV_DIR/mapper/$THIN"