File bug-1158628_02-tests-fix-ra-checking.patch of Package lvm2.16878
From d3903d94e910b7ca673ef090c6fe9f79b04b7dd5 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Tue, 18 Jun 2019 13:20:27 +0200
Subject: [PATCH] tests: fix ra checking
Since with some installed package like 'tuned' the value of 'RA' on
PV origin device can be different, adapting tests to count with this.
---
test/shell/lvcreate-usage.sh | 14 ++++++++++----
test/shell/read-ahead.sh | 6 +++++-
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/test/shell/lvcreate-usage.sh b/test/shell/lvcreate-usage.sh
index 6d424014e2..ca8694e8e6 100644
--- a/test/shell/lvcreate-usage.sh
+++ b/test/shell/lvcreate-usage.sh
@@ -175,15 +175,21 @@ check lv_field $vg/$lv2 lv_kernel_read_ahead "0"
lvcreate -L 8 -n $lv3 --readahead 8k $vg
check lv_field $vg/$lv3 lv_read_ahead "8.00k"
check lv_field $vg/$lv3 lv_kernel_read_ahead "8.00k"
-lvcreate -L 8 -n $lv4 --readahead auto $vg
+lvcreate -L 8 -n $lv4 --readahead auto $vg "$dev1"
check lv_field $vg/$lv4 lv_read_ahead "auto"
-check lv_field $vg/$lv4 lv_kernel_read_ahead "128.00k"
+# figure RA value of a PV origin device
+DEVICE=$(dmsetup deps -o blkdevname "$dev1" | sed -e "s,.*:\ (\(.*\)),/dev/\1,")
+RASZ=$(( $(blockdev --getra "$DEVICE" ) / 2 ))
+SZ="$RASZ.00k"
+test "$RASZ" -ge 128 || SZ="128.00k"
+check lv_field $vg/$lv4 lv_kernel_read_ahead "$SZ" --units k
lvcreate -L 8 -n $lv5 -i2 --stripesize 16k --readahead auto $vg
check lv_field $vg/$lv5 lv_read_ahead "auto"
-check lv_field $vg/$lv5 lv_kernel_read_ahead "128.00k"
+check lv_field $vg/$lv5 lv_kernel_read_ahead "$SZ" --units k
lvcreate -L 8 -n $lv6 -i2 --stripesize 128k --readahead auto $vg
check lv_field $vg/$lv6 lv_read_ahead "auto"
-check lv_field $vg/$lv6 lv_kernel_read_ahead "512.00k"
+test "$RASZ" -ge 512 || SZ="512.00k"
+check lv_field $vg/$lv6 lv_kernel_read_ahead "$SZ" --units k
lvremove -ff $vg
#
diff --git a/test/shell/read-ahead.sh b/test/shell/read-ahead.sh
index 60e5912f2f..53cc572b9a 100644
--- a/test/shell/read-ahead.sh
+++ b/test/shell/read-ahead.sh
@@ -35,8 +35,12 @@ lvremove -ff $vg
#COMM "read ahead is properly inherited from underlying PV"
blockdev --setra 768 "$dev1"
vgscan
+DEVICE=$(dmsetup deps -o blkdevname "$dev1" | sed -e "s,.*:\ (\(.*\)),/dev/\1,")
+RASZ=$(blockdev --getra "$DEVICE")
+SZ=$RASZ
+test "$RASZ" -ge 768 || SZ=768
lvcreate -n $lv -L4m $vg "$dev1"
-test "$(blockdev --getra "$DM_DEV_DIR/$vg/$lv")" -eq 768
+test "$(blockdev --getra "$DM_DEV_DIR/$vg/$lv")" -eq "$SZ"
lvremove -ff $vg
# Check default, active/inactive values for read_ahead / kernel_read_ahead
--
2.24.0