From: Daniel Wagner <dwagner@suse.de>
To: linux-nvme@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
Chaitanya Kulkarni <kch@nvidia.com>,
Shin'ichiro Kawasaki <shinichiro@fastmail.com>,
Sagi Grimberg <sagi@grimberg.me>, Hannes Reinecke <hare@suse.de>,
James Smart <jsmart2021@gmail.com>,
Martin Belanger <Martin.Belanger@dell.com>,
Daniel Wagner <dwagner@suse.de>
Subject: [PATCH blktests v1 2/3] nvme/rc: Avoid triggering host nvme-cli autoconnect
Date: Tue, 20 Jun 2023 15:27:02 +0200 [thread overview]
Message-ID: <20230620132703.20648-3-dwagner@suse.de> (raw)
In-Reply-To: <20230620132703.20648-1-dwagner@suse.de>
When the host has enabled the udev/systemd autoconnect services for the
fc transport it interacts with blktests and make tests break.
nvme-cli learned to ignore connects attemps when using the
--context command line option paired with a volatile configuration. Thus
we can mark all the resources created by blktests and avoid any
interaction with the systemd autoconnect scripts.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
tests/nvme/rc | 73 ++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 63 insertions(+), 10 deletions(-)
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 191f3e2e0c43..00117d314a38 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -14,8 +14,8 @@ def_remote_wwnn="0x10001100aa000001"
def_remote_wwpn="0x20001100aa000001"
def_local_wwnn="0x10001100aa000002"
def_local_wwpn="0x20001100aa000002"
-def_hostnqn="$(cat /etc/nvme/hostnqn 2> /dev/null)"
-def_hostid="$(cat /etc/nvme/hostid 2> /dev/null)"
+def_hostnqn="nqn.2014-08.org.nvmexpress:uuid:242d4a24-2484-4a80-8234-d0169409c5e8"
+def_hostid="242d4a24-2484-4a80-8234-d0169409c5e8"
nvme_trtype=${nvme_trtype:-"loop"}
nvme_img_size=${nvme_img_size:-"1G"}
nvme_num_iter=${nvme_num_iter:-"1000"}
@@ -161,6 +161,50 @@ _nvme_calc_rand_io_size() {
echo "${io_size_kb}k"
}
+_nvme_cli_supports_context() {
+ if ! nvme connect --help 2>&1 | grep -q context > /dev/null; then
+ return 1
+ fi
+ return 0
+}
+
+_setup_nvme_cli() {
+ if ! _nvme_cli_supports_context; then
+ return
+ fi
+
+ mkdir -p /run/nvme
+ cat >> /run/nvme/blktests.json <<-EOF
+ [
+ {
+ "hostnqn": "${def_hostnqn}",
+ "hostid": "${def_hostid}",
+ "subsystems": [
+ {
+ "application": "blktests",
+ "nqn": "blktests-subsystem-1",
+ "ports": [
+ {
+ "transport": "fc",
+ "traddr": "nn-${def_remote_wwnn}:pn-${def_remote_wwpn}",
+ "host_traddr": "nn-${def_local_wwnn}:pn-${def_local_wwpn}"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ EOF
+}
+
+_cleanup_nvme_cli() {
+ if ! _nvme_cli_supports_context; then
+ return
+ fi
+
+ rm -f /run/nvme/blktests.json
+}
+
_nvme_fcloop_add_rport() {
local local_wwnn="$1"
local local_wwpn="$2"
@@ -235,6 +279,8 @@ _cleanup_fcloop() {
_nvme_fcloop_del_lport "${local_wwnn}" "${local_wwpn}"
_nvme_fcloop_del_rport "${local_wwnn}" "${local_wwpn}" \
"${remote_wwnn}" "${remote_wwpn}"
+
+ _cleanup_nvme_cli
}
_cleanup_nvmet() {
@@ -337,6 +383,8 @@ _setup_nvmet() {
def_host_traddr=$(printf "nn-%s:pn-%s" \
"${def_local_wwnn}" \
"${def_local_wwpn}")
+
+ _setup_nvme_cli
fi
}
@@ -436,18 +484,18 @@ _nvme_connect_subsys() {
trtype="$1"
subsysnqn="$2"
- ARGS=(-t "${trtype}" -n "${subsysnqn}")
+ ARGS=(-t "${trtype}"
+ -n "${subsysnqn}"
+ --hostnqn="${hostnqn}"
+ --hostid="${hostid}")
+ if _nvme_cli_supports_context; then
+ ARGS+=(--context="blktests")
+ fi
if [[ "${trtype}" == "fc" ]] ; then
ARGS+=(-a "${traddr}" -w "${host_traddr}")
elif [[ "${trtype}" != "loop" ]]; then
ARGS+=(-a "${traddr}" -s "${trsvcid}")
fi
- if [[ "${hostnqn}" != "$def_hostnqn" ]]; then
- ARGS+=(--hostnqn="${hostnqn}")
- fi
- if [[ "${hostid}" != "$def_hostid" ]]; then
- ARGS+=(--hostid="${hostid}")
- fi
if [[ -n "${hostkey}" ]]; then
ARGS+=(--dhchap-secret="${hostkey}")
fi
@@ -482,7 +530,12 @@ _nvme_discover() {
local host_traddr="${3:-$def_host_traddr}"
local trsvcid="${3:-$def_trsvcid}"
- ARGS=(-t "${trtype}")
+ ARGS=(-t "${trtype}"
+ --hostnqn="${def_hostnqn}"
+ --hostid="${def_hostid}")
+ if _nvme_cli_supports_context; then
+ ARGS+=(--context="blktests")
+ fi
if [[ "${trtype}" = "fc" ]]; then
ARGS+=(-a "${traddr}" -w "${host_traddr}")
elif [[ "${trtype}" != "loop" ]]; then
--
2.41.0
next prev parent reply other threads:[~2023-06-20 13:27 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 13:27 [PATCH blktests v1 0/3] More fixes for FC enabling Daniel Wagner
2023-06-20 13:27 ` [PATCH blktests v1 1/3] nvme/048: Check for queue count check directly Daniel Wagner
2023-06-20 13:49 ` Sagi Grimberg
2023-06-20 17:37 ` Daniel Wagner
2023-06-21 9:50 ` Sagi Grimberg
2023-06-21 11:19 ` Daniel Wagner
2023-06-27 10:13 ` Shinichiro Kawasaki
2023-06-28 5:52 ` Daniel Wagner
2023-06-20 13:27 ` Daniel Wagner [this message]
2023-06-20 14:07 ` [PATCH blktests v1 2/3] nvme/rc: Avoid triggering host nvme-cli autoconnect Sagi Grimberg
2023-06-20 17:43 ` Daniel Wagner
2023-06-21 9:02 ` Daniel Wagner
2023-06-27 10:22 ` Shinichiro Kawasaki
2023-06-28 6:09 ` Daniel Wagner
2023-06-28 10:04 ` Shinichiro Kawasaki
2023-06-28 15:00 ` Daniel Wagner
2023-07-06 16:11 ` Max Gurtovoy
2023-07-10 8:27 ` Daniel Wagner
2023-07-10 9:53 ` Max Gurtovoy
2023-07-10 10:19 ` Daniel Wagner
2023-07-10 12:31 ` Max Gurtovoy
2023-07-10 15:03 ` Daniel Wagner
2023-07-10 16:30 ` Max Gurtovoy
2023-07-12 12:04 ` Daniel Wagner
2023-07-13 0:12 ` Max Gurtovoy
2023-07-13 6:00 ` Hannes Reinecke
2023-07-13 8:49 ` Max Gurtovoy
2023-07-13 10:14 ` Hannes Reinecke
2023-07-13 10:30 ` Daniel Wagner
2023-07-13 10:44 ` Daniel Wagner
2023-07-13 10:50 ` Max Gurtovoy
2023-06-20 13:27 ` [PATCH blktests v1 3/3] nvme/{041,042,043,044,045}: Use default hostnqn and hostid Daniel Wagner
2023-06-27 10:24 ` Shinichiro Kawasaki
2023-07-06 16:06 ` Max Gurtovoy
2023-07-10 8:32 ` Daniel Wagner
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=20230620132703.20648-3-dwagner@suse.de \
--to=dwagner@suse.de \
--cc=Martin.Belanger@dell.com \
--cc=hare@suse.de \
--cc=jsmart2021@gmail.com \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=shinichiro@fastmail.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).