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.kawasaki@wdc.com>,
Sagi Grimberg <sagi@grimberg.me>, Hannes Reinecke <hare@suse.de>,
James Smart <jsmart2021@gmail.com>,
Daniel Wagner <dwagner@suse.de>
Subject: [PATCH blktests v3 2/3] nvme/rc: Avoid triggering host nvme-cli autoconnect
Date: Mon, 3 Jul 2023 11:16:46 +0200 [thread overview]
Message-ID: <20230703091647.800-3-dwagner@suse.de> (raw)
In-Reply-To: <20230703091647.800-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.
Only enabled this for the fc transport.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
tests/nvme/rc | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 1c2c2fab62c1..9b5442b2c07b 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -176,6 +176,57 @@ _nvme_calc_rand_io_size() {
echo "${io_size_kb}k"
}
+_have_nvme_cli_context() {
+ # ignore all non-fc transports for now
+ if [[ "${nvme_trtype}" != "fc" ]] ||
+ ! nvme connect --help 2>&1 | grep -q -- '--context=<STR>' > /dev/null; then
+ return 1
+ fi
+ return 0
+}
+
+_setup_nvme_cli() {
+ local local_wwnn="${1}"
+ local local_wwpn="${2}"
+ local remote_wwnn="${3}"
+ local remote_wwpn="${4}"
+
+ if ! _have_nvme_cli_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-${remote_wwnn}:pn-${remote_wwpn}",
+ "host_traddr": "nn-${local_wwnn}:pn-${local_wwpn}"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ EOF
+}
+
+_cleanup_nvme_cli() {
+ if ! _have_nvme_cli_context; then
+ return
+ fi
+
+ rm -f /run/nvme/blktests.json
+}
+
_nvme_fcloop_add_rport() {
local local_wwnn="$1"
local local_wwpn="$2"
@@ -208,6 +259,9 @@ _setup_fcloop() {
local remote_wwnn="${3:-$def_remote_wwnn}"
local remote_wwpn="${4:-$def_remote_wwpn}"
+ _setup_nvme_cli "${local_wwnn}" "${local_wwpn}" \
+ "${remote_wwnn}" "${remote_wwpn}"
+
_nvme_fcloop_add_tport "${remote_wwnn}" "${remote_wwpn}"
_nvme_fcloop_add_lport "${local_wwnn}" "${local_wwpn}"
_nvme_fcloop_add_rport "${local_wwnn}" "${local_wwpn}" \
@@ -250,6 +304,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() {
@@ -452,6 +508,9 @@ _nvme_connect_subsys() {
subsysnqn="$2"
ARGS=(-t "${trtype}" -n "${subsysnqn}")
+ if _have_nvme_cli_context; then
+ ARGS+=(--context="blktests")
+ fi
if [[ "${trtype}" == "fc" ]] ; then
ARGS+=(-a "${traddr}" -w "${host_traddr}")
elif [[ "${trtype}" != "loop" ]]; then
@@ -496,6 +555,9 @@ _nvme_discover() {
ARGS=(-t "${trtype}")
ARGS+=(--hostnqn="${def_hostnqn}")
ARGS+=(--hostid="${def_hostid}")
+ if _have_nvme_cli_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-07-03 9:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-03 9:16 [PATCH blktests v3 0/3] More fixes for FC enabling Daniel Wagner
2023-07-03 9:16 ` [PATCH blktests v3 1/3] nvme/048: Check for queue count check directly Daniel Wagner
2023-07-03 9:16 ` Daniel Wagner [this message]
2023-07-03 9:16 ` [PATCH blktests v3 3/3] nvme/{041,042,043,044,045,048}: Use default hostnqn and hostid Daniel Wagner
2023-07-04 7:08 ` [PATCH blktests v3 0/3] More fixes for FC enabling Shinichiro Kawasaki
2023-07-06 6:51 ` Chaitanya Kulkarni
2023-07-10 3:52 ` Shinichiro Kawasaki
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=20230703091647.800-3-dwagner@suse.de \
--to=dwagner@suse.de \
--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.kawasaki@wdc.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