main - tests: Add testing for lvmlockd failure
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=874001ee6e0e7812e4e...
Commit: 874001ee6e0e7812e4e8d19994a1fd7de43d3249
Parent: 8c7b2df41fdddcd1b1c504522ab79300882eb72f
Author: Leo Yan <leo.yan(a)linaro.org>
AuthorDate: Thu Jun 3 17:59:17 2021 +0800
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 3 09:39:32 2021 -0500
tests: Add testing for lvmlockd failure
After the lvmlockd abnormally exits and relaunch the daemon, if LVM
commands continue to run, lvmlockd and the backend lock manager (e.g.
sanlock lock manager or IDM lock manager) should can continue to serve
the requests from LVM commands.
This patch adds a test to emulate lvmlockd failure, and verify the LVM
commands after lvmlockd recovers back. Below is an example for testing
the case:
# make check_lvmlockd_idm \
LVM_TEST_BACKING_DEVICE=/dev/sdo3,/dev/sdp3,/dev/sdp4 \
LVM_TEST_FAILURE=1 T=lvmlockd_failure.sh
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
test/lib/inittest.sh | 3 ++-
test/shell/lvmlockd_failure.sh | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 6b4bcb348..98a916ca6 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -31,6 +31,7 @@ LVM_TEST_BACKING_DEVICE=${LVM_TEST_BACKING_DEVICE-}
LVM_TEST_DEVDIR=${LVM_TEST_DEVDIR-}
LVM_TEST_NODEBUG=${LVM_TEST_NODEBUG-}
LVM_TEST_LVM1=${LVM_TEST_LVM1-}
+LVM_TEST_FAILURE=${LVM_TEST_FAILURE-}
# TODO: LVM_TEST_SHARED
SHARED=${SHARED-}
@@ -63,7 +64,7 @@ test -n "$SKIP_WITH_LVMLOCKD" && test -n "$LVM_TEST_LVMLOCKD" && initskip
unset CDPATH
-export LVM_TEST_BACKING_DEVICE LVM_TEST_DEVDIR LVM_TEST_NODEBUG
+export LVM_TEST_BACKING_DEVICE LVM_TEST_DEVDIR LVM_TEST_NODEBUG LVM_TEST_FAILURE
export LVM_TEST_LVMLOCKD LVM_TEST_LVMLOCKD_TEST
export LVM_TEST_LVMPOLLD LVM_TEST_LOCK_TYPE_DLM LVM_TEST_LOCK_TYPE_SANLOCK LVM_TEST_LOCK_TYPE_IDM
export LVM_TEST_DEVICES_FILE
diff --git a/test/shell/lvmlockd_failure.sh b/test/shell/lvmlockd_failure.sh
new file mode 100644
index 000000000..e0fccfb83
--- /dev/null
+++ b/test/shell/lvmlockd_failure.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2020~2021 Seagate, 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
+
+[ -z "$LVM_TEST_FAILURE" ] && skip;
+
+aux prepare_vg 3
+
+# Create new logic volume
+lvcreate -a ey --zero n -l 1 -n $lv1 $vg
+
+# Emulate lvmlockd abnormally exiting
+killall -9 lvmlockd
+
+systemctl start lvm2-lvmlockd
+
+vgchange --lock-start $vg
+
+lvchange -a n $vg/$lv1
+lvchange -a sy $vg/$lv1
+
+lvcreate -a ey --zero n -l 1 -n $lv2 $vg
+lvchange -a n $vg/$lv2
+
+vgremove -ff $vg
2 years, 10 months
main - tests: Support idm failure injection
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8c7b2df41fdddcd1b1c...
Commit: 8c7b2df41fdddcd1b1c504522ab79300882eb72f
Parent: f83e11ff4332ce7ca24f6bfede4fe60c48123700
Author: Leo Yan <leo.yan(a)linaro.org>
AuthorDate: Thu Jun 3 17:59:16 2021 +0800
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 3 09:39:32 2021 -0500
tests: Support idm failure injection
When the drive failure occurs, the IDM lock manager and lvmlockd should
handle this case properly. E.g. when the IDM lock manager detects the
lease renewal failure caused by I/O errors, it should invoke the kill
path which is predefined by lvmlockd, so that the kill path program
(like lvmlockctl) can send requests to lvmlockd to stop and drop lock
for the relevant VG/LVs.
To verify the failure handling flow, this patch introduces an idm
failure injection program, it can input the "percentage" for drive
failures so that can emulate different failure cases.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
test/Makefile.in | 5 ++++
test/lib/idm_inject_failure.c | 55 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/test/Makefile.in b/test/Makefile.in
index 662974be6..573df77a7 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -171,6 +171,7 @@ endif
ifeq ("@BUILD_LVMLOCKD@", "yes")
check_lvmlockd_idm: .tests-stamp
+ $(INSTALL_PROGRAM) lib/idm_inject_failure $(EXECDIR)
VERBOSE=$(VERBOSE) ./lib/runner \
--testdir . --outdir $(LVM_TEST_RESULTS) \
--flavours udev-lvmlockd-idm --only shell/aa-lvmlockd-idm-prepare.sh,$(T),shell/zz-lvmlockd-idm-remove.sh --skip $(S)
@@ -269,6 +270,10 @@ lib/securetest: lib/dmsecuretest.o .lib-dir-stamp
@echo " [CC] $@"
$(Q) $(CC) -g $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $< -L$(interfacebuilddir) -ldevmapper $(LIBS)
+lib/idm_inject_failure: lib/idm_inject_failure.o .lib-dir-stamp
+ @echo " [CC] $@"
+ $(Q) $(CC) -g $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $< $(INTERNAL_LIBS) $(LIBS) -lseagate_ilm
+
lib/runner.o: $(wildcard $(srcdir)/lib/*.h)
CFLAGS_runner.o += $(EXTRA_EXEC_CFLAGS)
diff --git a/test/lib/idm_inject_failure.c b/test/lib/idm_inject_failure.c
new file mode 100644
index 000000000..4998b585a
--- /dev/null
+++ b/test/lib/idm_inject_failure.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2020-2021 Seagate Ltd.
+ *
+ * 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 Lesser General Public License v.2.1.
+ */
+
+#include <errno.h>
+#include <limits.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/inotify.h>
+#include <uuid/uuid.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <ilm.h>
+
+int main(int argc, char *argv[])
+{
+ int pecent = atoi(argv[1]);
+ int ret, s;
+
+ ret = ilm_connect(&s);
+ if (ret == 0) {
+ printf("ilm_connect: SUCCESS\n");
+ } else {
+ printf("ilm_connect: FAIL\n");
+ exit(-1);
+ }
+
+ ret = ilm_inject_fault(s, pecent);
+ if (ret == 0) {
+ printf("ilm_inject_fault (100): SUCCESS\n");
+ } else {
+ printf("ilm_inject_fault (100): FAIL\n");
+ exit(-1);
+ }
+
+ ret = ilm_disconnect(s);
+ if (ret == 0) {
+ printf("ilm_disconnect: SUCCESS\n");
+ } else {
+ printf("ilm_disconnect: FAIL\n");
+ exit(-1);
+ }
+
+ return 0;
+}
2 years, 10 months
main - tests: stress: Add multi-threads stress testing for PV/VG/LV
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f83e11ff4332ce7ca24...
Commit: f83e11ff4332ce7ca24f6bfede4fe60c48123700
Parent: 692fe7bb31b6682151601f196e6274a3e8b772d5
Author: Leo Yan <leo.yan(a)linaro.org>
AuthorDate: Thu Jun 3 17:59:15 2021 +0800
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 3 09:39:32 2021 -0500
tests: stress: Add multi-threads stress testing for PV/VG/LV
This patch is to add the stress testing, which launches three threads,
one thread is for creating/removing PV, one thread is for
creating/removing VG, and the last one thread is for LV operations.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
test/shell/stress_multi_threads_2.sh | 93 ++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/test/shell/stress_multi_threads_2.sh b/test/shell/stress_multi_threads_2.sh
new file mode 100644
index 000000000..a035b5727
--- /dev/null
+++ b/test/shell/stress_multi_threads_2.sh
@@ -0,0 +1,93 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate, 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 v2.
+#
+# 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
+
+aux prepare_devs 8
+get_devs
+
+pvcreate -M2 "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6"
+
+test_vg_thread1()
+{
+ for i in {1..1000}
+ do
+ vgcreate --shared -M2 "$vg1" "$dev1" "$dev2" "$dev3"
+ vgremove -ff $vg1
+ done
+}
+
+test_vg_thread2()
+{
+ vgcreate --shared -M2 "$vg2" "$dev4" "$dev5" "$dev6"
+
+ for i in {1..1000}
+ do
+ # Create new logic volume and deactivate it
+ lvcreate -a n --zero n -l 1 -n foo $vg2
+
+ # Set minor number
+ lvchange $vg2/foo -My --major=255 --minor=124
+
+ # Activate logic volume
+ lvchange $vg2/foo -a y
+
+ # Extend logic volume with 10%
+ lvextend -l+10 $vg2/foo
+
+ # Deactivate logic volume
+ lvchange $vg2/foo -a n
+
+ # Deactivate volume group
+ vgchange $vg2 -a n
+
+ # Activate volume group with shareable mode
+ vgchange $vg2 -a sy
+
+ # lvextend fails due to mismatched lock mode
+ not lvextend -l+10 $vg2/foo
+
+ # Promote volume group to exclusive mode
+ vgchange $vg2 -a ey
+
+ lvreduce -f -l-4 $vg2/foo
+
+ lvchange -an $vg2/foo
+ lvremove $vg2/foo
+ done
+
+ vgremove -ff $vg2
+}
+
+test_vg_thread3()
+{
+ for i in {1..1000}
+ do
+ pvcreate -M2 "$dev7" "$dev8"
+ pvremove "$dev7"
+ pvremove "$dev8"
+ done
+}
+
+test_vg_thread1 &
+WAITPID=$!
+
+test_vg_thread2 &
+WAITPID="$WAITPID "$!
+
+test_vg_thread3 &
+WAITPID="$WAITPID "$!
+
+wait $WAITPID
2 years, 10 months
main - tests: stress: Add multi-threads stress testing for VG/LV
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=692fe7bb31b66821516...
Commit: 692fe7bb31b6682151601f196e6274a3e8b772d5
Parent: fe660467fa4c943bb0ce928e7af65572e2ddeddc
Author: Leo Yan <leo.yan(a)linaro.org>
AuthorDate: Thu Jun 3 17:59:14 2021 +0800
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 3 09:39:32 2021 -0500
tests: stress: Add multi-threads stress testing for VG/LV
This patch is to add the stress testing, which launches two threads,
each thread creates LV, activate and deactivate LV in the loop; so this
can test for multi-threading in lvmlockd and its backend lock manager.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
test/shell/stress_multi_threads_1.sh | 111 +++++++++++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
diff --git a/test/shell/stress_multi_threads_1.sh b/test/shell/stress_multi_threads_1.sh
new file mode 100644
index 000000000..c96fa244b
--- /dev/null
+++ b/test/shell/stress_multi_threads_1.sh
@@ -0,0 +1,111 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate, 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 v2.
+#
+# 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
+
+aux prepare_devs 6
+get_devs
+
+pvcreate -M2 "${DEVICES[@]}"
+
+vgcreate --shared -M2 "$vg1" "$dev1" "$dev2" "$dev3"
+vgcreate --shared -M2 "$vg2" "$dev4" "$dev5" "$dev6"
+
+test_vg_thread1()
+{
+ for i in {1..1000}
+ do
+ # Create new logic volume and deactivate it
+ lvcreate -a n --zero n -l 1 -n foo $vg1
+
+ # Set minor number
+ lvchange $vg1/foo -My --major=255 --minor=123
+
+ # Activate logic volume
+ lvchange $vg1/foo -a y
+
+ # Extend logic volume with 10%
+ lvextend -l+10 $vg1/foo
+
+ # Deactivate logic volume
+ lvchange $vg1/foo -a n
+
+ # Deactivate volume group
+ vgchange $vg1 -a n
+
+ # Activate volume group with shareable mode
+ vgchange $vg1 -a sy
+
+ # lvextend fails due to mismatched lock mode
+ not lvextend -l+10 $vg1/foo
+
+ # Promote volume group to exclusive mode
+ vgchange $vg1 -a ey
+
+ lvreduce -f -l-4 $vg1/foo
+
+ lvchange -an $vg1/foo
+ lvremove $vg1/foo
+ done
+}
+
+test_vg_thread2()
+{
+ for i in {1..1000}
+ do
+ # Create new logic volume and deactivate it
+ lvcreate -a n --zero n -l 1 -n foo $vg2
+
+ # Set minor number
+ lvchange $vg2/foo -My --major=255 --minor=124
+
+ # Activate logic volume
+ lvchange $vg2/foo -a y
+
+ # Extend logic volume with 10%
+ lvextend -l+10 $vg2/foo
+
+ # Deactivate logic volume
+ lvchange $vg2/foo -a n
+
+ # Deactivate volume group
+ vgchange $vg2 -a n
+
+ # Activate volume group with shareable mode
+ vgchange $vg2 -a sy
+
+ # lvextend fails due to mismatched lock mode
+ not lvextend -l+10 $vg2/foo
+
+ # Promote volume group to exclusive mode
+ vgchange $vg2 -a ey
+
+ lvreduce -f -l-4 $vg2/foo
+
+ lvchange -an $vg2/foo
+ lvremove $vg2/foo
+ done
+}
+
+test_vg_thread1 &
+WAITPID=$!
+
+test_vg_thread2 &
+WAITPID="$WAITPID "$!
+
+wait $WAITPID
+
+vgremove -ff $vg1
+vgremove -ff $vg2
2 years, 10 months
main - tests: stress: Add single thread stress testing
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fe660467fa4c943bb0c...
Commit: fe660467fa4c943bb0ce928e7af65572e2ddeddc
Parent: 5b361b197e1a3fbbc5419b9c46f19539c2b7305c
Author: Leo Yan <leo.yan(a)linaro.org>
AuthorDate: Thu Jun 3 17:59:13 2021 +0800
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 3 09:39:32 2021 -0500
tests: stress: Add single thread stress testing
This patch is to add the stress testing, which loops to create LV,
activate and deactivate LV in the single thread.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
test/shell/stress_single_thread.sh | 59 ++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/test/shell/stress_single_thread.sh b/test/shell/stress_single_thread.sh
new file mode 100644
index 000000000..e18d4900b
--- /dev/null
+++ b/test/shell/stress_single_thread.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate, 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 v2.
+#
+# 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
+
+aux prepare_vg 3
+
+for i in {1..1000}
+do
+ # Create new logic volume and deactivate it
+ lvcreate -a n --zero n -l 1 -n foo $vg
+
+ # Set minor number
+ lvchange $vg/foo -My --major=255 --minor=123
+
+ # Activate logic volume
+ lvchange $vg/foo -a y
+
+ # Check device mapper
+ dmsetup info $vg-foo | tee info
+ grep -E "^Major, minor: *[0-9]+, 123" info
+
+ # Extend logic volume with 10%
+ lvextend -l+10 $vg/foo
+
+ # Deactivate logic volume
+ lvchange $vg/foo -a n
+
+ # Deactivate volume group
+ vgchange $vg -a n
+
+ # Activate volume group with shareable mode
+ vgchange $vg -a sy
+
+ # lvextend fails due to mismatched lock mode
+ not lvextend -l+10 $vg/foo
+
+ # Promote volume group to exclusive mode
+ vgchange $vg -a ey
+
+ lvreduce -f -l-4 $vg/foo
+
+ lvchange -an $vg/foo
+ lvremove $vg/foo
+done
+
+vgremove -ff $vg
2 years, 10 months
main - tests: Add checking for lvmlockd log
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5b361b197e1a3fbbc54...
Commit: 5b361b197e1a3fbbc5419b9c46f19539c2b7305c
Parent: 2097c27c05de30003850eb667b9cf21b3181fddf
Author: Leo Yan <leo.yan(a)linaro.org>
AuthorDate: Thu Jun 3 17:59:12 2021 +0800
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 3 09:39:32 2021 -0500
tests: Add checking for lvmlockd log
Add checking for lvmlockd log, this can be used for the test cases which
are interested in the interaction with lvmlockd.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
test/lib/check.sh | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index 8493bde83..1f261940a 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -456,6 +456,11 @@ grep_dmsetup() {
grep -q "${@:3}" out || die "Expected output \"" "${@:3}" "\" from dmsetup $1 not found!"
}
+grep_lvmlockd_dump() {
+ lvmlockctl --dump | tee out
+ grep -q "${@:1}" out || die "Expected output \"" "${@:1}" "\" from lvmlockctl --dump not found!"
+}
+
#set -x
unset LVM_VALGRIND
"$@"
2 years, 10 months
main - tests: Cleanup idm context when prepare devices
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2097c27c05de3000385...
Commit: 2097c27c05de30003850eb667b9cf21b3181fddf
Parent: 759b0392d5f0f15e7e503ae1b3ef82ea7b4df0c1
Author: Leo Yan <leo.yan(a)linaro.org>
AuthorDate: Thu Jun 3 17:59:11 2021 +0800
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 3 09:39:32 2021 -0500
tests: Cleanup idm context when prepare devices
For testing idm locking scheme, it's good to cleanup the idm context
before run the test cases. This can give a clean environment for the
testing.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
test/lib/aux.sh | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index a592dad81..bb189f466 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -897,6 +897,20 @@ wipefs_a() {
udev_wait
}
+cleanup_idm_context() {
+ local dev=$1
+
+ if [ -n "$LVM_TEST_LOCK_TYPE_IDM" ]; then
+ sg_dev=`sg_map26 ${dev}`
+ echo "Cleanup IDM context for drive ${dev} ($sg_dev)"
+ sg_raw -v -r 512 -o /tmp/idm_tmp_data.bin $sg_dev \
+ 88 00 01 00 00 00 00 20 FF 01 00 00 00 01 00 00
+ sg_raw -v -s 512 -i /tmp/idm_tmp_data.bin $sg_dev \
+ 8E 00 FF 00 00 00 00 00 00 00 00 00 00 01 00 00
+ rm /tmp/idm_tmp_data.bin
+ fi
+}
+
prepare_backing_dev() {
local size=${1=32}
shift
@@ -989,12 +1003,15 @@ prepare_devs() {
return $?
fi
- for d in "${BACKING_DEVICE_ARRAY[@]}"; do
- cnt=$((`blockdev --getsize64 $d` / 1024 / 1024))
- cnt=$(( cnt < 1000 ? cnt : 1000 ))
- dd if=/dev/zero of="$d" bs=1MB count=$cnt
- wipefs -a "$d" 2>/dev/null || true
- done
+ if [ -n "$LVM_TEST_BACKING_DEVICE" ]; then
+ for d in "${BACKING_DEVICE_ARRAY[@]}"; do
+ cnt=$((`blockdev --getsize64 $d` / 1024 / 1024))
+ cnt=$(( cnt < 1000 ? cnt : 1000 ))
+ dd if=/dev/zero of="$d" bs=1MB count=$cnt
+ wipefs -a "$d" 2>/dev/null || true
+ cleanup_idm_context "$d"
+ done
+ fi
# non-ephemeral devices need to be cleared between tests
test -f LOOP -o -f RAMDISK || for d in "${DEVICES[@]}"; do
2 years, 10 months
main - tests: Support multiple backing devices
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=759b0392d5f0f15e7e5...
Commit: 759b0392d5f0f15e7e503ae1b3ef82ea7b4df0c1
Parent: c64dbc7ee80963a02f82f3257963f90b471fa90e
Author: Leo Yan <leo.yan(a)linaro.org>
AuthorDate: Thu Jun 3 17:59:10 2021 +0800
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 3 09:39:32 2021 -0500
tests: Support multiple backing devices
In current implementation, the option "LVM_TEST_BACKING_DEVICE" only
supports to specify one backing device; this patch is to extend the
option to support multiple backing devices by using comma as separator,
e.g. below command specifies two backing devices:
make check_lvmlockd_idm LVM_TEST_BACKING_DEVICE=/dev/sdj3,/dev/sdk3
This can allow the testing works on multiple drives and verify the
locking scheme if can work as expected for multiple drives case. For
example, for Seagate IDM locking scheme, if a VG uses two PVs, every PV
is resident on a drive, thus the locking operations will be sent to two
drives respectively; so the extension for "LVM_TEST_BACKING_DEVICE" can
help to verify different drive configurations for locking.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
test/lib/aux.sh | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 97c7ac68b..a592dad81 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -901,11 +901,22 @@ prepare_backing_dev() {
local size=${1=32}
shift
+ if test -n "$LVM_TEST_BACKING_DEVICE"; then
+ IFS=',' read -r -a BACKING_DEVICE_ARRAY <<< "$LVM_TEST_BACKING_DEVICE"
+
+ for d in "${BACKING_DEVICE_ARRAY[@]}"; do
+ if test ! -b "$d"; then
+ echo "Device $d doesn't exist!"
+ return 1
+ fi
+ done
+ fi
+
if test -f BACKING_DEV; then
BACKING_DEV=$(< BACKING_DEV)
return 0
- elif test -b "$LVM_TEST_BACKING_DEVICE"; then
- BACKING_DEV=$LVM_TEST_BACKING_DEVICE
+ elif test -n "$LVM_TEST_BACKING_DEVICE"; then
+ BACKING_DEV=${BACKING_DEVICE_ARRAY[0]}
echo "$BACKING_DEV" > BACKING_DEV
return 0
elif test "${LVM_TEST_PREFER_BRD-1}" = "1" && \
@@ -953,7 +964,14 @@ prepare_devs() {
local dev="$DM_DEV_DIR/mapper/$name"
DEVICES[$count]=$dev
count=$(( count + 1 ))
- echo 0 $size linear "$BACKING_DEV" $(( ( i - 1 ) * size + ( header_shift * 2048 ) )) > "$name.table"
+ # If the backing device number can meet the requirement for PV devices,
+ # then allocate a dedicated backing device for PV; otherwise, rollback
+ # to use single backing device for device-mapper.
+ if [ -n "$LVM_TEST_BACKING_DEVICE" ] && [ $n -le ${#BACKING_DEVICE_ARRAY[@]} ]; then
+ echo 0 $size linear "${BACKING_DEVICE_ARRAY[$(( count - 1 ))]}" $(( header_shift * 2048 )) > "$name.table"
+ else
+ echo 0 $size linear "$BACKING_DEV" $(( ( i - 1 ) * size + ( header_shift * 2048 ) )) > "$name.table"
+ fi
dmsetup create -u "TEST-$name" "$name" "$name.table" || touch CREATE_FAILED &
test -f CREATE_FAILED && break;
done
@@ -971,6 +989,13 @@ prepare_devs() {
return $?
fi
+ for d in "${BACKING_DEVICE_ARRAY[@]}"; do
+ cnt=$((`blockdev --getsize64 $d` / 1024 / 1024))
+ cnt=$(( cnt < 1000 ? cnt : 1000 ))
+ dd if=/dev/zero of="$d" bs=1MB count=$cnt
+ wipefs -a "$d" 2>/dev/null || true
+ done
+
# non-ephemeral devices need to be cleared between tests
test -f LOOP -o -f RAMDISK || for d in "${DEVICES[@]}"; do
# ensure disk header is always zeroed
2 years, 10 months
main - tests: Enable the testing for IDM locking scheme
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c64dbc7ee80963a02f8...
Commit: c64dbc7ee80963a02f82f3257963f90b471fa90e
Parent: 2bce6faed017df8da3e659eff3f42f39d25c7f09
Author: Leo Yan <leo.yan(a)linaro.org>
AuthorDate: Thu Jun 3 17:59:09 2021 +0800
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 3 09:39:32 2021 -0500
tests: Enable the testing for IDM locking scheme
This patch is to introduce testing option LVM_TEST_LOCK_TYPE_IDM, with
specifying this option, the Seagate IDM lock manager will be launched as
backend for testing. Also add the prepare and remove shell scripts for
IDM.
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
test/Makefile.in | 9 +++++++++
test/lib/aux.sh | 25 +++++++++++++++++++++++++
test/lib/flavour-udev-lvmlockd-idm.sh | 5 +++++
test/lib/inittest.sh | 3 ++-
test/shell/aa-lvmlockd-idm-prepare.sh | 20 ++++++++++++++++++++
test/shell/lvmlockd-lv-types.sh | 6 ++++++
test/shell/zz-lvmlockd-idm-remove.sh | 29 +++++++++++++++++++++++++++++
7 files changed, 96 insertions(+), 1 deletion(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index e4cd3aac5..662974be6 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -85,6 +85,7 @@ help:
@echo " check_all_lvmpolld Run all tests with lvmpolld daemon."
@echo " check_lvmlockd_sanlock Run tests with lvmlockd and sanlock."
@echo " check_lvmlockd_dlm Run tests with lvmlockd and dlm."
+ @echo " check_lvmlockd_idm Run tests with lvmlockd and idm."
@echo " check_lvmlockd_test Run tests with lvmlockd --test."
@echo " run-unit-test Run only unit tests (root not needed)."
@echo " clean Clean dir."
@@ -168,6 +169,13 @@ check_lvmlockd_dlm: .tests-stamp
--flavours udev-lvmlockd-dlm --only shell/aa-lvmlockd-dlm-prepare.sh,$(T),shell/zz-lvmlockd-dlm-remove.sh --skip $(S)
endif
+ifeq ("@BUILD_LVMLOCKD@", "yes")
+check_lvmlockd_idm: .tests-stamp
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir $(LVM_TEST_RESULTS) \
+ --flavours udev-lvmlockd-idm --only shell/aa-lvmlockd-idm-prepare.sh,$(T),shell/zz-lvmlockd-idm-remove.sh --skip $(S)
+endif
+
ifeq ("@BUILD_LVMLOCKD@", "yes")
check_lvmlockd_test: .tests-stamp
VERBOSE=$(VERBOSE) ./lib/runner \
@@ -189,6 +197,7 @@ LIB_FLAVOURS = \
flavour-udev-lvmpolld\
flavour-udev-lvmlockd-sanlock\
flavour-udev-lvmlockd-dlm\
+ flavour-udev-lvmlockd-idm\
flavour-udev-lvmlockd-test\
flavour-udev-vanilla
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 1a1f11a1d..97c7ac68b 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -119,6 +119,20 @@ prepare_sanlock() {
fi
}
+prepare_idm() {
+ if pgrep seagate_ilm; then
+ echo "Cannot run while existing seagate_ilm process exists"
+ exit 1
+ fi
+
+ seagate_ilm -D 0 -l 0 -L 7 -E 7 -S 7
+
+ if ! pgrep seagate_ilm; then
+ echo "Failed to start seagate_ilm"
+ exit 1
+ fi
+}
+
prepare_lvmlockd() {
if pgrep lvmlockd ; then
echo "Cannot run while existing lvmlockd process exists"
@@ -135,6 +149,11 @@ prepare_lvmlockd() {
echo "starting lvmlockd for dlm"
lvmlockd
+ elif test -n "$LVM_TEST_LOCK_TYPE_IDM"; then
+ # make check_lvmlockd_idm
+ echo "starting lvmlockd for idm"
+ lvmlockd -g idm
+
elif test -n "$LVM_TEST_LVMLOCKD_TEST_DLM"; then
# make check_lvmlockd_test
echo "starting lvmlockd --test (dlm)"
@@ -144,6 +163,12 @@ prepare_lvmlockd() {
# FIXME: add option for this combination of --test and sanlock
echo "starting lvmlockd --test (sanlock)"
lvmlockd --test -g sanlock -o 2
+
+ elif test -n "$LVM_TEST_LVMLOCKD_TEST_IDM"; then
+ # make check_lvmlockd_test
+ echo "starting lvmlockd --test (idm)"
+ lvmlockd --test -g idm
+
else
echo "not starting lvmlockd"
exit 0
diff --git a/test/lib/flavour-udev-lvmlockd-idm.sh b/test/lib/flavour-udev-lvmlockd-idm.sh
new file mode 100644
index 000000000..e9f8908df
--- /dev/null
+++ b/test/lib/flavour-udev-lvmlockd-idm.sh
@@ -0,0 +1,5 @@
+export LVM_TEST_LOCKING=1
+export LVM_TEST_LVMPOLLD=1
+export LVM_TEST_LVMLOCKD=1
+export LVM_TEST_LOCK_TYPE_IDM=1
+export LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 0fd651710..6b4bcb348 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -40,6 +40,7 @@ LVM_TEST_LVMPOLLD=${LVM_TEST_LVMPOLLD-}
LVM_TEST_DEVICES_FILE=${LVM_TEST_DEVICES_FILE-}
LVM_TEST_LOCK_TYPE_DLM=${LVM_TEST_LOCK_TYPE_DLM-}
LVM_TEST_LOCK_TYPE_SANLOCK=${LVM_TEST_LOCK_TYPE_SANLOCK-}
+LVM_TEST_LOCK_TYPE_IDM=${LVM_TEST_LOCK_TYPE_IDM-}
SKIP_WITHOUT_CLVMD=${SKIP_WITHOUT_CLVMD-}
SKIP_WITH_CLVMD=${SKIP_WITH_CLVMD-}
@@ -64,7 +65,7 @@ unset CDPATH
export LVM_TEST_BACKING_DEVICE LVM_TEST_DEVDIR LVM_TEST_NODEBUG
export LVM_TEST_LVMLOCKD LVM_TEST_LVMLOCKD_TEST
-export LVM_TEST_LVMPOLLD LVM_TEST_LOCK_TYPE_DLM LVM_TEST_LOCK_TYPE_SANLOCK
+export LVM_TEST_LVMPOLLD LVM_TEST_LOCK_TYPE_DLM LVM_TEST_LOCK_TYPE_SANLOCK LVM_TEST_LOCK_TYPE_IDM
export LVM_TEST_DEVICES_FILE
# grab some common utilities
. lib/utils
diff --git a/test/shell/aa-lvmlockd-idm-prepare.sh b/test/shell/aa-lvmlockd-idm-prepare.sh
new file mode 100644
index 000000000..8faff3bc2
--- /dev/null
+++ b/test/shell/aa-lvmlockd-idm-prepare.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate. 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 v2.
+#
+# 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
+
+test_description='Set up things to run tests with idm'
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip;
+
+aux prepare_idm
+aux prepare_lvmlockd
diff --git a/test/shell/lvmlockd-lv-types.sh b/test/shell/lvmlockd-lv-types.sh
index 6138e5623..ee350b1c6 100644
--- a/test/shell/lvmlockd-lv-types.sh
+++ b/test/shell/lvmlockd-lv-types.sh
@@ -36,6 +36,12 @@ LOCKARGS2="dlm"
LOCKARGS3="dlm"
fi
+if test -n "$LVM_TEST_LOCK_TYPE_IDM" ; then
+LOCKARGS1="idm"
+LOCKARGS2="idm"
+LOCKARGS3="idm"
+fi
+
aux prepare_devs 5
vgcreate --shared $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5"
diff --git a/test/shell/zz-lvmlockd-idm-remove.sh b/test/shell/zz-lvmlockd-idm-remove.sh
new file mode 100644
index 000000000..25943a579
--- /dev/null
+++ b/test/shell/zz-lvmlockd-idm-remove.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2021 Seagate. 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 v2.
+#
+# 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
+
+test_description='Remove the idm test setup'
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LOCK_TYPE_IDM" ] && skip;
+
+# FIXME: collect debug logs (only if a test failed?)
+# lvmlockctl -d > lvmlockd-debug.txt
+# dlm_tool dump > dlm-debug.txt
+
+lvmlockctl --stop-lockspaces
+sleep 1
+killall lvmlockd
+sleep 1
+killall lvmlockd || true
+sleep 1
+killall seagate_ilm
2 years, 10 months
main - pvchange: fix file locking deadlock
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2bce6faed017df8da3e...
Commit: 2bce6faed017df8da3e659eff3f42f39d25c7f09
Parent: e7f107c24666c8577f30e530b74f1ce0347e459b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 2 16:29:54 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 2 16:29:54 2021 -0500
pvchange: fix file locking deadlock
Calling clear_hint_file() to invalidate hints would acquire
the hints flock before the global flock which could cause deadlock.
The lock order requires the global lock to be taken first.
pvchange was always invalidating hints, which was unnecessary;
only invalidate hints when changing a PV uuid. Because of the
lock ordering, take the global lock before clear_hint_file which
locks the hints file.
---
tools/pvchange.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/tools/pvchange.c b/tools/pvchange.c
index d6e35d66f..04cbb428d 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -248,7 +248,32 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
set_pv_notify(cmd);
- clear_hint_file(cmd);
+ /*
+ * Changing a PV uuid is the only pvchange that invalidates hints.
+ * Invalidating hints (clear_hint_file) is called at the start of
+ * the command and takes the hints lock.
+ * The global lock must always be taken first, then the hints lock
+ * (the required lock ordering.)
+ *
+ * Because of these constraints, the global lock is taken ex here
+ * for any PV uuid change, even though the global lock is technically
+ * required only for changing an orphan PV (we don't know until later
+ * if the PV is an orphan). The VG lock is used when changing
+ * non-orphan PVs.
+ *
+ * For changes other than uuid on an orphan PV, the global lock is
+ * taken sh by process_each, then converted to ex in pvchange_single,
+ * which works because the hints lock is not held.
+ *
+ * (Eventually, perhaps always do lock_global(ex) here to simplify.)
+ */
+ if (arg_is_set(cmd, uuid_ARG)) {
+ if (!lock_global(cmd, "ex")) {
+ ret = ECMD_FAILED;
+ goto out;
+ }
+ clear_hint_file(cmd);
+ }
ret = process_each_pv(cmd, argc, argv, NULL, 0, READ_FOR_UPDATE, handle, _pvchange_single);
2 years, 10 months