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

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