nvme: add nvmet zone report and FC regression tests
Subsystems (2)
v2 cover nvme: add nvmet zone report and FC regression tests
Add regression tests for three nvmet bugs fixed by the kernel series [1]:
nvme/072 "nvmet-fc: only send read data for successful commands" nvme/073 "nvmet: zns: don't leak stale memory in zone management receive" nvme/074 "nvmet: zns: reject a NUMD whose byte count wraps"
The nvme/073 fix is already applied to nvme-7.4; the other two are still under review.
Patch 1 adds the zoned null_blk target setup, cleanup and zone report status check that nvme/073 and nvme/074 share. Patches 2-4 add one test each, with a small C helper for nvme/072 and nvme/073 where nvme-cli cannot express the check.
All three tests run on every configured transport. On a kernel without the fixes, nvme/073 and nvme/074 fail over loop, tcp, rdma and fc, and nvme/072 fails over fc, the only affected transport. All three pass with the fixes applied.
Tested in virtme-ng VMs over loop, tcp, rdma (rdma_rxe) and fc (fcloop), on v7.3-rc4-108-g551c722f4080 without the fixes and on nvme-7.4 with the v2 kernel series applied:
loop tcp rdma fc unpatched 072 pass pass pass FAIL failed Identify transferred
4096 bytes
073 FAIL FAIL FAIL FAIL stale report bytes, and an
8192-byte transfer for NUMD 1023 not rejected
074 FAIL FAIL FAIL FAIL NUMD 0x4000000f not rejected
patched all pass pass pass pass
Changes since v1:
- Renumbered nvme/071-073 to nvme/072-074, since nvme/071 is now taken.
- Patch 1: configure nullb1 instead of nullb0, and drop the _init_null_blk() call, so that the helpers also work with a built-in null_blk (Shin'ichiro).
- Patch 2: rename _identify() to issue_identify(), and drop the namespace read, which only served as a control, together with the file backing it needed (Shin'ichiro).
- Patches 3 and 4: use _have_null_blk instead of _have_module null_blk, and read the nullb1 attributes in patch 3 (Shin'ichiro).
- Rebased on current master.
v1: https://lore.kernel.org/r/[email protected]
[1] https://lore.kernel.org/r/[email protected]
Andrea Parri (4):
nvme/rc: add zoned null_blk target helpers
nvme/072: test that nvmet sends no data for a failed read nvme/073: test nvmet zone report initialization and length nvme/074: test that nvmet rejects a zone report NUMD that wraps
src/.gitignore | 2 + src/Makefile | 2 + src/nvme-sentinel-read.c | 89 +++++++++++++++++++++ src/nvme-zone-report.c | 165 +++++++++++++++++++++++++++++++++++++++ tests/nvme/072 | 72 +++++++++++++++++ tests/nvme/072.out | 2 + tests/nvme/073 | 68 ++++++++++++++++ tests/nvme/073.out | 2 + tests/nvme/074 | 46 +++++++++++ tests/nvme/074.out | 2 + tests/nvme/rc | 58 ++++++++++++++ 11 files changed, 508 insertions(+) create mode 100644 src/nvme-sentinel-read.c create mode 100644 src/nvme-zone-report.c create mode 100755 tests/nvme/072 create mode 100644 tests/nvme/072.out create mode 100755 tests/nvme/073 create mode 100644 tests/nvme/073.out create mode 100755 tests/nvme/074 create mode 100644 tests/nvme/074.out
base-commit: 9ad5a10fa8ed56f74c23fea2c35f4594a110b8b9
Signature · 1 line
2.53.0
PATCH v2 1/4 nvme/rc: add zoned null_blk target helpers
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.
--- tests/nvme/rc | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)
tests/nvme/rc +58 -0
@@ -408,6 +408,64 @@ _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 ! _configure_null_blk nullb1 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/nullb1 --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}
Signature · 1 line
2.53.0
PATCH v2 2/4 nvme/072: test that nvmet sends no data for a failed read
In reply to Andrea ParriIssue a failing Identify into a buffer filled with a sentinel and verify that the target transfers no data, with a successful Identify as a control. The test runs on every configured transport; only nvmet-fc failed it before the fix. Add a small helper because nvme-cli cannot prefill the data buffer.
The test fails over fc on the unpatched kernel and passes with the fix applied.
--- src/.gitignore | 1 + src/Makefile | 1 + src/nvme-sentinel-read.c | 89 ++++++++++++++++++++++++++++++++++++++++ tests/nvme/072 | 72 ++++++++++++++++++++++++++++++++ tests/nvme/072.out | 2 + 5 files changed, 165 insertions(+) create mode 100644 src/nvme-sentinel-read.c create mode 100755 tests/nvme/072 create mode 100644 tests/nvme/072.out
src/.gitignore +1 -0
@@ -19,3 +19,4 @@ /ioctl-lbmd-query /nvme-passthru-admin-uring /nvme-delay-ioctl +/nvme-sentinel-read
src/Makefile +1 -0
@@ -24,6 +24,7 @@ C_TARGETS := \ mount_clear_sock \ nvme-delay-ioctl \ nvme-passthrough-meta \ + nvme-sentinel-read \ ioctl-lbmd-query \ nbdsetsize \ openclose \
src/nvme-sentinel-read.c new file +89 -0
89 lines not on this page · raw message
tests/nvme/072 new file +72 -0
72 lines not on this page · raw message
tests/nvme/072.out new file +2 -0
@@ -0,0 +1,2 @@ +Running nvme/072 +Test complete
Signature · 1 line
2.53.0
PATCH v2 3/4 nvme/073: test nvmet zone report initialization and length
In reply to Andrea ParriExport a zoned null_blk device through the NVMe target and verify that Zone Management Receive zeroes reserved and unused report bytes and rejects a transfer length inconsistent with NUMD. The test runs on every configured transport, with RDMA restricted to 4 KiB page kernels so that the preparatory write exceeds the default inline-data limit. Add a small passthrough helper because nvme-cli does not expose the reserved report bytes.
The test fails on the unpatched kernel and passes with the fix applied.
--- src/.gitignore | 1 + src/Makefile | 1 + src/nvme-zone-report.c | 165 +++++++++++++++++++++++++++++++++++++++++ tests/nvme/073 | 68 +++++++++++++++++ tests/nvme/073.out | 2 + 5 files changed, 237 insertions(+) create mode 100644 src/nvme-zone-report.c create mode 100755 tests/nvme/073 create mode 100644 tests/nvme/073.out
src/.gitignore +1 -0
@@ -20,3 +20,4 @@ /nvme-passthru-admin-uring /nvme-delay-ioctl /nvme-sentinel-read +/nvme-zone-report
src/Makefile +1 -0
@@ -25,6 +25,7 @@ C_TARGETS := \ nvme-delay-ioctl \ nvme-passthrough-meta \ nvme-sentinel-read \ + nvme-zone-report \ ioctl-lbmd-query \ nbdsetsize \ openclose \
src/nvme-zone-report.c new file +165 -0
165 lines not on this page · raw message
tests/nvme/073 new file +68 -0
68 lines not on this page · raw message
tests/nvme/073.out new file +2 -0
@@ -0,0 +1,2 @@ +Running nvme/073 +Test complete
Signature · 1 line
2.53.0
PATCH v2 4/4 nvme/074: test that nvmet rejects a zone report NUMD that wraps
In reply to Andrea ParriVerify that Zone Management Receive rejects a NUMD whose byte count wraps a 32-bit calculation, while accepting an ordinary request. The test runs on every configured transport.
The test fails on the unpatched kernel and passes with the fix applied.
--- tests/nvme/074 | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tests/nvme/074.out | 2 ++ 2 files changed, 48 insertions(+) create mode 100755 tests/nvme/074 create mode 100644 tests/nvme/074.out
tests/nvme/074 new file +46 -0
@@ -0,0 +1,46 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2026 Andrea Parri +# +# Check that the NVMe target rejects a zone report NUMD whose byte count +# overflows a 32-bit value. +# +# Regression test for patch "nvmet: zns: reject a NUMD whose byte count wraps". + +. tests/nvme/rc +. common/null_blk + +DESCRIPTION="reject an NVMe target zone report NUMD that wraps" +QUICK=1 + +requires() { + _nvme_requires + _have_loop + _require_kernel_nvme_target + _have_null_blk + _have_kernel_options BLK_DEV_ZONED +} + +set_conditions() { + _set_nvme_trtype "$@" +} + +test() { + echo "Running ${TEST_NAME}" + + local dev + + _setup_nvmet + _register_test_cleanup _cleanup_nvmet_zoned_target + if ! _nvmet_zoned_target_setup; then + return 1 + fi + dev="/dev/$(_find_nvme_ns "$def_subsys_uuid")" + + _check_zone_report "$dev" 64 15 0 + _check_zone_report "$dev" 64 0x4000000f 2 + + _nvmet_zoned_target_cleanup + + echo "Test complete" +}
tests/nvme/074.out new file +2 -0
@@ -0,0 +1,2 @@ +Running nvme/074 +Test complete
Signature · 1 line
2.53.0
The kernel fixes that nvme/072 and nvme/074 test are now at v2:
https://lore.kernel.org/r/[email protected]
nvme/073 tests commit 31b8a6af19b7 ("nvmet: zns: don't leak stale memory in zone management receive"), already in nvme-7.4.
Andrea
Christoph Hellwig
maintainerStill not an expert at reviewing the actual blktests scripts, but the test contents looks sane to me, thanks!
Quoted 8 lines · Andrea Parri
Add regression tests for three nvmet bugs fixed by the kernel series [1]:
nvme/072 "nvmet-fc: only send read data for successful commands" nvme/073 "nvmet: zns: don't leak stale memory in zone management receive" nvme/074 "nvmet: zns: reject a NUMD whose byte count wraps"The nvme/073 fix is already applied to nvme-7.4; the other two are still under review.
...
Thanks. I applied this series. I confirmed nvme/072 and nvme/074 cause failures with the kernel at the block/for-next branch. Hope that they get fixed soon.