mdadm/0081-mdadm-tests-names_template-enhance.patch
Xiao Ni aba27b5983 Update to latest upstream
Fix coverity issue 34533 and  /dev/md symlink not created for second RAID container
issue 50776

Resolves: RHEL-34533, RHEL50776

Signed-off-by: Xiao Ni <xni@redhat.com>
2024-08-10 23:06:32 -04:00

110 lines
3.0 KiB
Diff

From 41706a91568472d10153bf4ada3c3f0d93ef327a Mon Sep 17 00:00:00 2001
From: Xiao Ni <xni@redhat.com>
Date: Wed, 22 May 2024 16:50:43 +0800
Subject: [PATCH 081/157] mdadm/tests: names_template enhance
For super1, if the length of hostname is >= 32, it doesn't add hostname
in metadata name. Fix this problem by checking the length of hostname.
Because other cases may use need to check this, so do the check in
do_setup.
And this patch adds a check if link /dev/md/name exists.
Signed-off-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
---
test | 5 +++++
tests/func.sh | 13 +++++++++++++
tests/templates/names_template | 14 ++++++++++++--
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/test b/test
index 3da53f87..814ce199 100755
--- a/test
+++ b/test
@@ -11,6 +11,11 @@ system_speed_limit_min=0
test_speed_limit_min=100
test_speed_limit_max=500
devlist=
+# If super1 metadata name doesn't have the same hostname with machine,
+# it's treated as foreign.
+# For example, /dev/md0 is created, stops it, then assemble it, the
+# device node will be /dev/md127 (127 is choosed by mdadm autumatically)
+is_foreign="no"
savelogs=0
exitonerror=1
diff --git a/tests/func.sh b/tests/func.sh
index 221cff15..cfe83e55 100644
--- a/tests/func.sh
+++ b/tests/func.sh
@@ -153,6 +153,18 @@ restore_system_speed_limit() {
echo $system_speed_limit_max > /proc/sys/dev/raid/speed_limit_max
}
+is_raid_foreign() {
+
+ # If the length of hostname is >= 32, super1 doesn't use
+ # hostname in metadata
+ hostname=$(hostname)
+ if [ `expr length $(hostname)` -lt 32 ]; then
+ is_foreign="no"
+ else
+ is_foreign="yes"
+ fi
+}
+
do_setup() {
trap cleanup 0 1 3 15
trap ctrl_c 2
@@ -232,6 +244,7 @@ do_setup() {
[ -f /proc/mdstat ] || modprobe md_mod
echo 0 > /sys/module/md_mod/parameters/start_ro
record_system_speed_limit
+ is_raid_foreign
}
# check various things
diff --git a/tests/templates/names_template b/tests/templates/names_template
index 1b6cd14b..88ad5b8c 100644
--- a/tests/templates/names_template
+++ b/tests/templates/names_template
@@ -30,6 +30,7 @@ function names_verify() {
local DEVNODE_NAME="$1"
local WANTED_LINK="$2"
local WANTED_NAME="$3"
+ local EXPECTED=""
local RES="$(mdadm -D --export $DEVNODE_NAME | grep MD_DEVNAME)"
if [[ "$?" != "0" ]]; then
@@ -38,7 +39,12 @@ function names_verify() {
fi
if [[ "$WANTED_LINK" != "empty" ]]; then
- local EXPECTED="MD_DEVNAME=$WANTED_LINK"
+ EXPECTED="MD_DEVNAME=$WANTED_LINK"
+
+ if [ ! -b /dev/md/$WANTED_LINK ]; then
+ echo "/dev/md/$WANTED_LINK doesn't exit"
+ exit 1
+ fi
fi
if [[ "$RES" != "$EXPECTED" ]]; then
@@ -52,7 +58,11 @@ function names_verify() {
exit 1
fi
- local EXPECTED="MD_NAME=$(hostname):$WANTED_NAME"
+ if [ $is_foreign == "no" ]; then
+ EXPECTED="MD_NAME=$(hostname):$WANTED_NAME"
+ else
+ EXPECTED="MD_NAME=$WANTED_NAME"
+ fi
if [[ "$RES" != "$EXPECTED" ]]; then
echo "$RES doesn't match $EXPECTED."
exit 1
--
2.41.0