summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Yan <leo.yan@linaro.org>2021-06-03 17:59:10 +0800
committerDavid Teigland <teigland@redhat.com>2021-06-03 09:39:32 -0500
commit759b0392d5f0f15e7e503ae1b3ef82ea7b4df0c1 (patch)
tree1d0822e3cf7c0bf88cfe0c9d429640167a3cfa61
parentc64dbc7ee80963a02f82f3257963f90b471fa90e (diff)
downloadlvm2-759b0392d5f0f15e7e503ae1b3ef82ea7b4df0c1.tar.gz
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@linaro.org>
-rw-r--r--test/lib/aux.sh31
1 files 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