From: Andrea Parri <parri.andrea@gmail.com>
To: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
linux-block@vger.kernel.org
Cc: Andrea Parri <parri.andrea@gmail.com>,
Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>,
Sagi Grimberg <sagi@grimberg.me>,
Chaitanya Kulkarni <kch@nvidia.com>,
Daniel Wagner <dwagner@suse.de>,
linux-nvme@lists.infradead.org
Subject: [PATCH blktests 1/4] nvme/rc: add zoned null_blk target helpers
Date: Wed, 14 Oct 2026 19:00:38 +0200 [thread overview]
Message-ID: <20261014170046.2516-2-parri.andrea@gmail.com> (raw)
In-Reply-To: <20261014170046.2516-1-parri.andrea@gmail.com>
Add helpers that export a zoned null_blk device as a namespace of the
default subsystem and connect to it, tear that setup down again, and
issue a partial Zone Management Receive and check its completion status.
The zone report tests added next share them.
Assisted-by: LLM
Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
---
tests/nvme/rc | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/tests/nvme/rc b/tests/nvme/rc
index c415ca1234407..270fad19d61f1 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -408,6 +408,67 @@ _nvmet_passthru_target_cleanup() {
_remove_nvmet_host "${def_hostnqn}"
}
+# Export a zoned null_blk device as a namespace of the default subsystem and
+# connect to it. Callers must source common/null_blk.
+_nvmet_zoned_target_setup() {
+ if ! _init_null_blk nr_devices=0; then
+ return 1
+ fi
+ if ! _configure_null_blk nullb0 blocksize=512 size=1024 zoned=1 \
+ zone_size=1 power=1 >>"$FULL" 2>&1; then
+ echo "could not configure zoned null_blk device"
+ return 1
+ fi
+
+ _nvmet_target_setup --blkdev none
+ _create_nvmet_ns --blkdev /dev/nullb0 --uuid "$def_subsys_uuid" \
+ >/dev/null
+ _nvme_connect_subsys
+}
+
+_nvmet_zoned_target_cleanup() {
+ _nvme_disconnect_subsys
+ _nvmet_target_cleanup
+ _exit_null_blk
+}
+
+# Test cleanup handler to register with _nvmet_zoned_target_setup().
+_cleanup_nvmet_zoned_target() {
+ _cleanup_nvmet
+ _exit_null_blk
+}
+
+# Issue a partial zone report from zone 0 of namespace device $1 with a
+# $2-byte data buffer and NUMD $3, and check that it completes with status
+# code $4, or succeeds if $4 is 0.
+_check_zone_report() {
+ local dev=$1 data_len=$2 numd=$3 expected=$4 desc err rc status
+
+ desc="zone report with $data_len bytes and NUMD $numd"
+ err=$(nvme io-passthru "$dev" --namespace-id=1 --opcode=0x7a --read \
+ --data-len="$data_len" --cdw10=0 --cdw11=0 --cdw12="$numd" \
+ --cdw13=0x10000 2>&1 >/dev/null)
+ rc=$?
+ status=$(sed -n \
+ 's/^NVMe status:.*(\(0x[[:xdigit:]][[:xdigit:]]*\)).*/\1/p' \
+ <<<"$err")
+ printf '%s: exit=%d status=%s\n' "$desc" "$rc" "${status:-none}" \
+ >>"$FULL"
+
+ if ((expected == 0)); then
+ if ((rc != 0)); then
+ echo "$desc failed"
+ fi
+ elif ((rc == 0)); then
+ echo "$desc was not rejected"
+ elif [[ -z "$status" ]]; then
+ echo "$desc returned no NVMe status"
+ elif (((status & 0x7ff) != expected)); then
+ printf '%s returned status %s, expected %#x\n' "$desc" \
+ "$status" "$expected"
+ fi
+}
+
_discovery_genctr() {
local port=${1}
--
2.53.0
next prev parent reply other threads:[~2026-10-14 17:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 17:00 [PATCH blktests 0/4] nvme: add nvmet zone report and FC regression tests Andrea Parri
2026-10-14 17:00 ` Andrea Parri [this message]
2026-10-14 17:00 ` [PATCH blktests 2/4] nvme/071: test that nvmet sends no data for a failed read Andrea Parri
2026-10-14 17:00 ` [PATCH blktests 3/4] nvme/072: test nvmet zone report initialization and length Andrea Parri
2026-10-14 17:00 ` [PATCH blktests 4/4] nvme/073: test that nvmet rejects a zone report NUMD that wraps Andrea Parri
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=20261014170046.2516-2-parri.andrea@gmail.com \
--to=parri.andrea@gmail.com \
--cc=dwagner@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-block@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