From: Xiao Ni <xni@redhat.com>
To: linux-raid@vger.kernel.org
Cc: jes@trained-monkey.org, song@kernel.org, yukuai1@huaweicloud.com,
ncroxon@redhat.com, colyli@suse.de,
mariusz.tkaczyk@linux.intel.com
Subject: [PATCH 2/5] tests/00createnames enhance
Date: Thu, 18 Apr 2024 18:23:18 +0800 [thread overview]
Message-ID: <20240418102321.95384-3-xni@redhat.com> (raw)
In-Reply-To: <20240418102321.95384-1-xni@redhat.com>
Now 00createnames doesn't check Create names=yes config. Without this
config, mdadm creates /dev/md127 device node when mdadm --create
/dev/md/test. With this config, it creates /dev/md_test. This patch
only adds the check. If it has this config, it returns directly
without error.
And this case has an error. 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.
And this patch adds a check if device node exists.
Signed-off-by: Xiao Ni <xni@redhat.com>
---
tests/00createnames | 9 +++++++++
tests/templates/names_template | 15 ++++++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/tests/00createnames b/tests/00createnames
index a95e7d2bb085..2eb3d9331dda 100644
--- a/tests/00createnames
+++ b/tests/00createnames
@@ -3,6 +3,15 @@ set -x -e
# Test how <devname> and --name= are handled for create mode.
+create_with_name=`cat /etc/mdadm.conf | grep "^Create*.names=yes"`
+
+if [ -n "$create_with_name" ]; then
+ exit 0
+fi
+
+#The following cases don't consider the names=yes setting in mdadm.conf
+#It needs to add the respecting cases which consider names=yes config
+
# The most trivial case.
names_create "/dev/md/name"
names_verify "/dev/md127" "name" "name"
diff --git a/tests/templates/names_template b/tests/templates/names_template
index 1b6cd14bf51d..4c7ff8c27f73 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
@@ -46,13 +47,25 @@ function names_verify() {
exit 1
fi
+ if [ -b /dev/md/$WANTED_LINK ]; then
+ echo "/dev/md/$WANTED_LINK doesn't exit"
+ fi
+
local RES="$(mdadm -D --export $DEVNODE_NAME | grep MD_NAME)"
if [[ "$?" != "0" ]]; then
echo "Cannot get metadata from $dev0."
exit 1
fi
- local EXPECTED="MD_NAME=$(hostname):$WANTED_NAME"
+ #If the lenght of hostname is >= 32, super1 doesn't use hostname
+ #in metadata
+ local is_super1="$(mdadm -D --export $DEVNODE_NAME | grep MD_METADATA=1.2)"
+ hostname=$(hostname)
+ if [ -n "$is_super1" -a `expr length $(hostname)` -lt 32 ]; 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.32.0 (Apple Git-132)
next prev parent reply other threads:[~2024-04-18 10:23 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-18 10:23 [PATCH RFC 0/5] mdadm tests fix and enhance Xiao Ni
2024-04-18 10:23 ` [PATCH 1/5] tests/test enhance Xiao Ni
2024-04-19 7:16 ` Mateusz Kusiak
2024-04-19 7:30 ` Mateusz Kusiak
2024-04-21 2:46 ` Xiao Ni
2024-04-18 10:23 ` Xiao Ni [this message]
2024-04-19 7:20 ` [PATCH 2/5] tests/00createnames enhance Mariusz Tkaczyk
2024-04-22 6:56 ` Xiao Ni
2024-04-22 7:23 ` Mariusz Tkaczyk
2024-04-19 9:47 ` Mariusz Tkaczyk
2024-04-22 6:57 ` Xiao Ni
2024-04-22 10:15 ` Mariusz Tkaczyk
2024-04-22 13:31 ` Xiao Ni
2024-04-18 10:23 ` [PATCH 3/5] tests/01r5fail enhance Xiao Ni
2024-04-19 9:57 ` Mariusz Tkaczyk
2024-05-08 8:35 ` Mariusz Tkaczyk
2024-04-18 10:23 ` [PATCH 4/5] tests/01r5integ.broken Xiao Ni
2024-05-08 8:36 ` Mariusz Tkaczyk
2024-04-18 10:23 ` [PATCH 5/5] tests/01raid6integ.broken can be removed Xiao Ni
2024-04-19 10:05 ` Mariusz Tkaczyk
2024-04-19 15:57 ` Song Liu
2024-04-22 13:54 ` Xiao Ni
2024-05-08 8:37 ` Mariusz Tkaczyk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240418102321.95384-3-xni@redhat.com \
--to=xni@redhat.com \
--cc=colyli@suse.de \
--cc=jes@trained-monkey.org \
--cc=linux-raid@vger.kernel.org \
--cc=mariusz.tkaczyk@linux.intel.com \
--cc=ncroxon@redhat.com \
--cc=song@kernel.org \
--cc=yukuai1@huaweicloud.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).