From: Logan Gunthorpe <logang@deltatee.com>
To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org,
linux-block@vger.kernel.org, Omar Sandoval <osandov@osandov.com>
Cc: Sagi Grimberg <sagi@grimberg.me>,
Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>,
Stephen Bates <sbates@raithlin.com>,
Logan Gunthorpe <logang@deltatee.com>
Subject: [PATCH blktests v3 05/11] nvme: Add common helpers for passthru tests
Date: Thu, 8 Oct 2020 10:40:18 -0600 [thread overview]
Message-ID: <20201008164024.12546-6-logang@deltatee.com> (raw)
In-Reply-To: <20201008164024.12546-1-logang@deltatee.com>
Add some simple helpers to setup a passthru target that passes through
to a nvme test device.
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
tests/nvme/rc | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/tests/nvme/rc b/tests/nvme/rc
index dfa57a299625..f0b6f360da8c 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -73,6 +73,16 @@ _require_nvme_trtype_is_fabrics() {
return 0
}
+_test_dev_nvme_ctrl() {
+ local dev=$(cat "${TEST_DEV_SYSFS}/device/dev")
+
+ echo "/dev/char/${dev}"
+}
+
+_test_dev_nvme_nsid() {
+ cat "${TEST_DEV_SYSFS}/nsid"
+}
+
_cleanup_nvmet() {
local dev
local port
@@ -257,6 +267,27 @@ _remove_nvmet_subsystem() {
rmdir "${subsys_path}"
}
+_create_nvmet_passthru() {
+ local nvmet_subsystem="$1"
+ local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}"
+ local passthru_path="${subsys_path}/passthru"
+
+ mkdir -p "${subsys_path}"
+ echo 1 > "${subsys_path}/attr_allow_any_host"
+
+ echo "$(_test_dev_nvme_ctrl)" > "${passthru_path}/device_path"
+ echo 1 > "${passthru_path}/enable"
+}
+
+_remove_nvmet_passhtru() {
+ local nvmet_subsystem="$1"
+ local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}"
+ local passthru_path="${subsys_path}/passthru"
+
+ echo 0 > "${passthru_path}/enable"
+ rmdir "${subsys_path}"
+}
+
_add_nvmet_subsys_to_port() {
local port="$1"
local nvmet_subsystem="$2"
@@ -292,6 +323,50 @@ _find_nvme_dev() {
done
}
+_find_nvme_passthru_loop_dev() {
+ local subsys=$1
+ local nsid
+ local dev
+
+ dev=$(_find_nvme_dev "${subsys}")
+ nsid=$(_test_dev_nvme_nsid)
+ echo "/dev/${dev}n${nsid}"
+}
+
+_nvmet_passthru_target_setup() {
+ local subsys_name=$1
+
+ _create_nvmet_passthru "${subsys_name}"
+ port="$(_create_nvmet_port "loop")"
+ _add_nvmet_subsys_to_port "${port}" "${subsys_name}"
+
+ echo "$port"
+}
+
+_nvmet_passthru_target_connect() {
+ local trtype=$1
+ local subsys_name=$2
+
+ _nvme_connect_subsys "${trtype}" "${subsys_name}"
+ nsdev=$(_find_nvme_passthru_loop_dev "${subsys_name}")
+
+ # The following tests can race with the creation
+ # of the device so ensure the block device exists
+ # before continuing
+ while [ ! -b "${nsdev}" ]; do sleep 1; done
+
+ echo "${nsdev}"
+}
+
+_nvmet_passthru_target_cleanup() {
+ local port=$1
+ local subsys_name=$2
+
+ _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
+ _remove_nvmet_port "${port}"
+ _remove_nvmet_passhtru "${subsys_name}"
+}
+
_filter_discovery() {
sed -n -r -e "s/Generation counter [0-9]+/Generation counter X/" \
-e '/Discovery Log Number|Log Entry|trtype|subnqn/p'
--
2.20.1
next prev parent reply other threads:[~2020-10-08 16:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 16:40 [PATCH blktests v3 00/11] NVMe Target Passthru Block Tests Logan Gunthorpe
2020-10-08 16:40 ` [PATCH blktests v3 01/11] common/fio: Remove state file in common helper Logan Gunthorpe
2020-10-08 16:40 ` [PATCH blktests v3 02/11] common/xfs: Create common helper to check for XFS support Logan Gunthorpe
2020-10-08 16:40 ` [PATCH blktests v3 03/11] common/xfs: Create common helper to verify block device with xfs Logan Gunthorpe
2020-10-08 16:40 ` [PATCH blktests v3 04/11] nvme: Search for specific subsysnqn in _find_nvme_loop_dev Logan Gunthorpe
2020-10-08 16:40 ` Logan Gunthorpe [this message]
2020-10-08 16:40 ` [PATCH blktests v3 06/11] nvme/033: Simple test to create and connect to a passthru target Logan Gunthorpe
2020-10-08 16:40 ` [PATCH blktests v3 07/11] nvme/034: Add test for passthru data verification Logan Gunthorpe
2020-10-08 16:40 ` [PATCH blktests v3 08/11] nvme/035: Add test to verify passthru controller with a filesystem Logan Gunthorpe
2020-10-08 16:40 ` [PATCH blktests v3 09/11] nvme/036: Add test for testing reset command on nvme-passthru Logan Gunthorpe
2020-10-08 16:40 ` [PATCH blktests v3 10/11] nvme/037: Add test which loops passthru connect and disconnect Logan Gunthorpe
2020-10-08 16:40 ` [PATCH blktests v3 11/11] nvme/038: Test removal of un-enabled subsystem and ports Logan Gunthorpe
2020-10-22 18:45 ` [PATCH blktests v3 00/11] NVMe Target Passthru Block Tests Logan Gunthorpe
2020-10-22 22:04 ` Omar Sandoval
2020-10-22 22:25 ` Logan Gunthorpe
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=20201008164024.12546-6-logang@deltatee.com \
--to=logang@deltatee.com \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=osandov@osandov.com \
--cc=sagi@grimberg.me \
--cc=sbates@raithlin.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).