Add support to run against arbitrary targets
Subsystems (3)
v4 cover Add support to run against arbitrary targets
This series is based off Daniel's patches. It is rebased to work on current blktests. It is also available on github:
https://github.com/aaptel/blktests.git branch remote-target-v4
The last patch adds a test making explicit use of the remote target support by testing the new nvme-tcp offloading.
I've added a 'blkdev' setting under [subsys_0] in the control script config to specify the backing block device on the target, instead of hardcoding '/dev/vdc'.
changes:
v4:
- added nvme test 055 for nvme-tcp offload
- added 'blkdev' setting under [subsys_0] in the control script config
- added workaround for older python versions
v3:
- added support for previous configured target
- renamed nvme_nvme_target to _require_kernel_nvme_target
- use shorter redirect operator
- https://lore.kernel.org/all/[email protected]/
v2:
- many of the preperation patches have been merged, drop them
- added a python script which implements the blktests API
- add some documentation how to use it
- changed the casing of the environment variables to upper case
- https://lore.kernel.org/all/[email protected]/
v1:
- initial version
- https://lore.kernel.org/linux-nvme/[email protected]/
Aurelien Aptel (2):
common/nvme: add digest options to __nvme_connect_subsys() nvme/055: add test for nvme-tcp zero-copy offload
Daniel Wagner (3):
nvme/rc: introduce remote target support
nvme/030: only run against kernel soft target
contrib: add remote target setup/cleanup script
Documentation/running-tests.md | 42 +++++ README.md | 1 + check | 4 + common/nvme | 87 +++++++++- common/rc | 8 + contrib/nvme_target_control.py | 190 ++++++++++++++++++++++ contrib/nvmet-subsys.jinja2 | 71 ++++++++ tests/nvme/030 | 1 + tests/nvme/055 | 285 +++++++++++++++++++++++++++++++++ tests/nvme/055.out | 44 +++++ tests/nvme/rc | 30 ++++ 11 files changed, 755 insertions(+), 8 deletions(-) create mode 100755 contrib/nvme_target_control.py create mode 100644 contrib/nvmet-subsys.jinja2 create mode 100755 tests/nvme/055 create mode 100644 tests/nvme/055.out
Signature · 1 line
2.34.1
PATCH v4 1/5 nvme/rc: introduce remote target support
From: Daniel Wagner <[email protected]>
Most of the NVMEeoF tests are exercising the host code of the nvme subsystem. There is no real reason not to run these against an arbitrary target. We just have to skip the soft target setup and make it possible to setup a remote target.
Because all tests use now the common setup/cleanup helpers we just need to intercept this call and forward it to an external component.
As we already have various nvme variables to setup the target which we should allow to overwrite. Also introduce a NVME_TARGET_CONTROL variable which points to a script which gets executed whenever a targets needs to be created/destroyed.
--- Documentation/running-tests.md | 33 ++++++++++++++++ check | 4 ++ common/nvme | 71 ++++++++++++++++++++++++++++++---- tests/nvme/rc | 14 +++++++ 4 files changed, 114 insertions(+), 8 deletions(-)
Documentation/running-tests.md +33 -0
@@ -120,6 +120,9 @@ The NVMe tests can be additionally parameterized via environment variables. - NVME_NUM_ITER: 1000 (default) The number of iterations a test should do. This parameter had an old name 'nvme_num_iter'. The old name is still usable, but not recommended. +- NVME_TARGET_CONTROL: When defined, the generic target setup/cleanup code will + be skipped and this script gets called. This makes it possible to run + the fabric nvme tests against a real target. ### Running nvme-rdma and SRP tests
@@ -167,3 +170,33 @@ if ! findmnt -t configfs /sys/kernel/config > /dev/null; then mount -t configfs configfs /sys/kernel/config fi ``` +### NVME_TARGET_CONTROL + +When NVME_TARGET_CONTROL is set, blktests will call the script which the +environment variable points to, to fetch the configuration values to be used for +the runs, e.g subsysnqn or hostnqn. This allows the blktest to be run against +external configured/setup targets. + +The blktests expects that the script interface implements following +commands: + +config: + --show-blkdev-type + --show-trtype + --show-hostnqn + --show-hostid + --show-host-traddr + --show-traddr + --show-trsvid + --show-subsys-uuid + --show-subsysnqn + +setup: + --subsysnqn SUBSYSNQN + --subsys-uuid SUBSYS_UUID + --hostnqn HOSTNQN + --ctrlkey CTRLKEY + --hostkey HOSTKEY + +cleanup: + --subsysnqn SUBSYSNQN
check +4 -0
@@ -603,6 +603,10 @@ _run_group() { # shellcheck disable=SC1090 . "tests/${group}/rc" + if declare -fF group_setup >/dev/null; then + group_setup + fi + if declare -fF group_requires >/dev/null; then group_requires if [[ -v SKIP_REASONS ]]; then
common/nvme +63 -8
121 lines not on this page · raw message
tests/nvme/rc +14 -0
@@ -113,6 +113,13 @@ _nvme_requires() { return 0 } +group_setup() { + if [[ -n "${nvme_target_control}" ]]; then + NVMET_TRTYPES="$(${nvme_target_control} config --show-trtype)" + NVMET_BLKDEV_TYPES="$(${nvme_target_control} config --show-blkdev-type)" + fi +} + group_requires() { _have_root _NVMET_TRTYPES_is_valid
@@ -392,6 +399,13 @@ _nvmet_passthru_target_cleanup() { esac done + if [[ -n "${nvme_target_control}" ]]; then + eval "${nvme_target_control}" cleanup \ + --subsysnqn "${subsysnqn}" \ + > /dev/null + return + fi + _get_nvmet_ports "${subsysnqn}" ports for port in "${ports[@]}"; do
Signature · 1 line
2.34.1
PATCH v4 2/5 common/nvme: add digest options to __nvme_connect_subsys()
In reply to Aurelien AptelThis commit lets tests connect nvme subsystems with data and header digest.
--- common/nvme | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
common/nvme +16 -0
@@ -272,6 +272,8 @@ _nvme_connect_subsys() { local reconnect_delay="" local ctrl_loss_tmo="" local no_wait=false + local hdr_digest=false + local data_digest=false local port local i local -a ARGS
@@ -330,6 +332,14 @@ _nvme_connect_subsys() { no_wait=true shift 1 ;; + --hdr-digest) + hdr_digest=true + shift 1 + ;; + --data-digest) + data_digest=true + shift 1 + ;; *) echo "WARNING: unknown argument: $1" shift
@@ -381,6 +391,12 @@ _nvme_connect_subsys() { if [[ -n "${ctrl_loss_tmo}" ]]; then ARGS+=(--ctrl-loss-tmo="${ctrl_loss_tmo}") fi + if [[ ${hdr_digest} = true ]]; then + ARGS+=(--hdr-digest) + fi + if [[ ${data_digest} = true ]]; then + ARGS+=(--data-digest) + fi ARGS+=(-o json) connect=$(nvme connect "${ARGS[@]}" 2> /dev/null)
Signature · 1 line
2.34.1
PATCH v4 3/5 nvme/030: only run against kernel soft target
In reply to Aurelien AptelFrom: Daniel Wagner <[email protected]>
This tests is exercising the target code and not so much the host side. The problem with nvme/030 is that it depends on interface to interact with the target which is not covered by the standard. Thus we can't run it against an arbitrary target. Just skip it when we run against a arbitrary target.
--- tests/nvme/030 | 1 + tests/nvme/rc | 8 ++++++++ 2 files changed, 9 insertions(+)
tests/nvme/030 +1 -0
@@ -13,6 +13,7 @@ requires() { _nvme_requires _have_loop _require_nvme_trtype_is_fabrics + _require_kernel_nvme_target } set_conditions() {
tests/nvme/rc +8 -0
@@ -191,6 +191,14 @@ _require_kernel_nvme_fabrics_feature() { return 0 } +_require_kernel_nvme_target() { + if [[ -n "${nvme_target_control}" ]]; then + SKIP_REASONS+=("Linux kernel soft target not available") + return 1; + fi + return 0 +} + _test_dev_nvme_ctrl() { echo "/dev/char/$(cat "${TEST_DEV_SYSFS}/device/dev")" }
Signature · 1 line
2.34.1
PATCH v4 4/5 contrib: add remote target setup/cleanup script
In reply to Aurelien AptelFrom: Daniel Wagner <[email protected]>
Use nvmetcli to setup/cleanup a remote soft target.
--- contrib/nvme_target_control.py | 190 +++++++++++++++++++++++++++++++++ contrib/nvmet-subsys.jinja2 | 71 ++++++++++++ 2 files changed, 261 insertions(+) create mode 100755 contrib/nvme_target_control.py create mode 100644 contrib/nvmet-subsys.jinja2
contrib/nvme_target_control.py new file +190 -0
@@ -0,0 +1,190 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0+ + +# blktests calls this script to setup/teardown remote targets. blktests passes +# all relevant information via the command line, e.g. --hostnqn. +# +# This script uses nvmetcli to setup the remote target (it depends on the REST +# API feature [1]). There is not technical need for nvmetcli to use but it makes +# it simple to setup a remote Linux box. If you want to setup someting else +# you should to replace this part. +# +# There are couple of global configuration options which need to be set. +# Add ~/.config/blktests/nvme_target_control.toml file with something like: +# +# [main] +# skip_setup_cleanup=false +# nvmetcli='/usr/bin/nvmetcli' +# remote='http://nvmet.local:5000' +# +# [host] +# blkdev_type='device' +# trtype='tcp' +# hostnqn='nqn.2014-08.org.nvmexpress:uuid:0f01fb42-9f7f-4856-b0b3-51e60b8de349' +# hostid='0f01fb42-9f7f-4856-b0b3-51e60b8de349' +# host_traddr='192.168.154.187' +# +# [subsys_0] +# traddr='192.168.19.189' +# trsvid='4420' +# subsysnqn='blktests-subsystem-1' +# subsys_uuid='91fdba0d-f87b-4c25-b80f-db7be1418b9e' +# +# This expects nvmetcli with the restapi service running on target. +# +# Alternatively, you can skip the the target setup/cleanup completely +# (skip_setup_cleanup) and run against a previously configured target. +# +# [main] +# skip_setup_cleanup=true +# nvmetcli='/usr/bin/nvmetcli' +# remote='http://nvmet.local:5000' +# +# [host] +# blkdev_type='device' +# trtype='tcp' +# hostnqn='nqn.2014-08.org.nvmexpress:uuid:1a9e23dd-466e-45ca-9f43-a29aaf47cb21' +# hostid='1a9e23dd-466e-45ca-9f43-a29aaf47cb21' +# host_traddr='10.161.16.48' +# +# [subsys_0] +# traddr='10.162.198.45' +# trsvid='4420' +# subsysnqn='nqn.1988-11.com.dell:powerstore:00:f03028e73ef7D032D81E' +# subsys_uuid='3a5c104c-ee41-38a1-8ccf-0968003d54e7' +# blkdev='/dev/nullb0' +# +# nvmetcli uses JSON configuration, thus this script creates a JSON configuration +# using a jinja2 template. After this step we simple have to set the blktests +# variable correctly and start blktests. +# +# NVME_TARGET_CONTROL=~/blktests/contrib/nvme_target_control.py ./check nvme +# +# [1] https://github.com/hreinecke/nvmetcli/tree/restapi + +import os + +# workaround for python<3.11 +TOML_OPEN_MODE="rb" +try: + import tomllib +except ModuleNotFoundError: + import pip._vendor.tomli as tomllib + TOML_OPEN_MODE="r" + +import argparse +import subprocess +from jinja2 import Environment, FileSystemLoader + + +XDG_CONFIG_HOME = os.environ.get("XDG_CONFIG_HOME") +if not XDG_CONFIG_HOME: + XDG_CONFIG_HOME = os.environ.get('HOME') + '/.config' + + +with open(f'{XDG_CONFIG_HOME}/blktests/nvme_target_control.toml', TOML_OPEN_MODE) as f: + config = tomllib.load(f) + nvmetcli = config['main']['nvmetcli'] + remote = config['main']['remote'] + + +def gen_conf(conf): + basepath = os.path.dirname(__file__) + environment = Environment(loader=FileSystemLoader(basepath)) + template = environment.get_template('nvmet-subsys.jinja2') + filename = f'{conf["subsysnqn"]}.json' + content = template.render(conf) + with open(filename, mode='w', encoding='utf-8') as outfile: + outfile.write(content) + + +def target_setup(args): + if config['main']['skip_setup_cleanup']: + return + + conf = { + 'subsysnqn': args.subsysnqn, + 'subsys_uuid': args.subsys_uuid, + 'hostnqn': args.hostnqn, + 'allowed_hosts': args.hostnqn, + 'ctrlkey': args.ctrlkey, + 'hostkey': args.hostkey, + 'blkdev': config['subsys_0']['blkdev'], + } + + gen_conf(conf) + + subprocess.call(['python3', nvmetcli, '--remote=' + remote, + 'restore', args.subsysnqn + '.json']) + + +def target_cleanup(args): + if config['main']['skip_setup_cleanup']: + return + + subprocess.call(['python3', nvmetcli, '--remote=' + remote, + 'clear', args.subsysnqn + '.json']) + + +def target_config(args): + if args.show_blkdev_type: + print(config['host']['blkdev_type']) + elif args.show_trtype: + print(config['host']['trtype']) + elif args.show_hostnqn: + print(config['host']['hostnqn']) + elif args.show_hostid: + print(config['host']['hostid']) + elif args.show_host_traddr: + print(config['host']['host_traddr']) + elif args.show_traddr: + print(config['subsys_0']['traddr']) + elif args.show_trsvid: + print(config['subsys_0']['trsvid']) + elif args.show_subsysnqn: + print(config['subsys_0']['subsysnqn']) + elif args.show_subsys_uuid: + print(config['subsys_0']['subsys_uuid']) + + +def build_parser(): + parser = argparse.ArgumentParser() + sub = parser.add_subparsers(required=True) + + setup = sub.add_parser('setup') + setup.add_argument('--subsysnqn', required=True) + setup.add_argument('--subsys-uuid', required=True) + setup.add_argument('--hostnqn', required=True) + setup.add_argument('--ctrlkey', default='') + setup.add_argument('--hostkey', default='') + setup.set_defaults(func=target_setup) + + cleanup = sub.add_parser('cleanup') + cleanup.add_argument('--subsysnqn', required=True) + cleanup.set_defaults(func=target_cleanup) + + config = sub.add_parser('config') + config.add_argument('--show-blkdev-type', action='store_true') + config.add_argument('--show-trtype', action='store_true') + config.add_argument('--show-hostnqn', action='store_true') + config.add_argument('--show-hostid', action='store_true') + config.add_argument('--show-host-traddr', action='store_true') + config.add_argument('--show-traddr', action='store_true') + config.add_argument('--show-trsvid', action='store_true') + config.add_argument('--show-subsys-uuid', action='store_true') + config.add_argument('--show-subsysnqn', action='store_true') + config.set_defaults(func=target_config) + + return parser + + +def main(): + import sys + + parser = build_parser() + args = parser.parse_args() + args.func(args) + + +if __name__ == '__main__': + main()
contrib/nvmet-subsys.jinja2 new file +71 -0
71 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v4 5/5 nvme/055: add test for nvme-tcp zero-copy offload
In reply to Aurelien AptelThis commit adds a new test for the kernel ULP DDP (Direct Data Placement) feature with NVMe-TCP.
Configuration of DDP is per NIC and is done through a script in the kernel source. For this reason we add 2 new config vars:
- KERNELSRC: path to the running kernel sources
- NVME_IFACE: name of the network interface to configure the offload on
--- Documentation/running-tests.md | 9 ++ README.md | 1 + common/rc | 8 + tests/nvme/055 | 285 +++++++++++++++++++++++++++++++++ tests/nvme/055.out | 44 +++++ tests/nvme/rc | 8 + 6 files changed, 355 insertions(+) create mode 100755 tests/nvme/055 create mode 100644 tests/nvme/055.out
Documentation/running-tests.md +9 -0
@@ -124,6 +124,15 @@ The NVMe tests can be additionally parameterized via environment variables. be skipped and this script gets called. This makes it possible to run the fabric nvme tests against a real target. +#### NVMe-TCP zero-copy offload + +The NVMe-TCP ZC offload tests use a couple more variables. + +- KERNELSRC: Path to running kernel sources. + Needed for the script to configure the offload. +- NVME_IFACE: Name of the interface the offload should be enabled on. + This should be the same interface the NVMe connection is made with. + ### Running nvme-rdma and SRP tests These tests will use the siw (soft-iWARP) driver by default. The rdma_rxe
README.md +1 -0
@@ -30,6 +30,7 @@ Some tests require the following: - nbd-client and nbd-server (Debian) or nbd (Fedora, openSUSE, Arch Linux) - dmsetup (Debian) or device-mapper (Fedora, openSUSE, Arch Linux) - rublk (`cargo install --version=^0.1 rublk`) for ublk test +- python3, ethtool, iproute2 for nvme-tcp zero-copy offload test Build blktests with `make`. Optionally, install it to a known location with `make install` (`/usr/local/blktests` by default, but this can be changed by
common/rc +8 -0
@@ -148,6 +148,14 @@ _have_loop() { _have_driver loop && _have_program losetup } +_have_kernel_source() { + if [ -z "${KERNELSRC}" ]; then + SKIP_REASONS+=("KERNELSRC not set") + return 1 + fi + return 0 +} + _have_blktrace() { # CONFIG_BLK_DEV_IO_TRACE might still be disabled, but this is easier # to check. We can fix it if someone complains.
tests/nvme/055 new file +285 -0
285 lines not on this page · raw message
tests/nvme/055.out new file +44 -0
44 lines not on this page · raw message
tests/nvme/rc +8 -0
@@ -199,6 +199,14 @@ _require_kernel_nvme_target() { return 0 } +_require_remote_nvme_target() { + if [ -z "${nvme_target_control}" ]; then + SKIP_REASONS+=("Remote target required but NVME_TARGET_CONTROL is not set") + return 1 + fi + return 0 +} + _test_dev_nvme_ctrl() { echo "/dev/char/$(cat "${TEST_DEV_SYSFS}/device/dev")" }
Signature · 1 line
2.34.1
Re: [PATCH blktests v4 1/5] nvme/rc: introduce remote target support
In reply to Aurelien AptelHello Aurelien,
Thank you for rebasing the series. Please find my comments in line.
When I ran "make check", I observed some ShellCheck warnings. This check before posts will be appreciated. As for the two ShellCheck warnings, please find my comments below. This patch also triggered ShellCheck warnings in other files. For those warnings, I created a fix patch and attached for your reference.
On Nov 26, 2024 / 22:38, Aurelien Aptel wrote:
[...]
Quoted 4 lines
common/nvme +0
-0
[...]
common/nvme _cleanup_nvmet() { · line 220
Quoted 9 lines
common/nvme +5
-0@@ -208,6 +213,18 @@ _cleanup_nvmet() { _setup_nvmet() { _register_test_cleanup _cleanup_nvmet + + if [[ -n "${nvme_target_control}" ]]; then + def_hostnqn="$(${nvme_target_control} config --show-hostnqn)" + def_hostid="$(${nvme_target_control} config --show-hostid)" + def_host_traddr="$(${nvme_target_control} config --show-host-traddr)"
I suggest to remove the line above. It caused ShellCheck warning SC2034. I think def_host_traddr is not used anywhere.
Quoted 10 lines
common/nvme +7
-0+ def_traddr="$(${nvme_target_control} config --show-traddr)" + def_trsvcid="$(${nvme_target_control} config --show-trsvid)" + def_subsys_uuid="$(${nvme_target_control} config --show-subsys-uuid)" + def_subsysnqn="$(${nvme_target_control} config --show-subsysnqn)" + return + fi + modprobe -q nvmet if [[ "${nvme_trtype}" != "loop" ]]; then modprobe -q nvmet-"${nvme_trtype}"
[...]
common/nvme _nvmet_target_setup() { · line 844
Quoted 10 lines
common/nvme +6
-0@@ -811,6 +836,29 @@ _nvmet_target_setup() { fi fi + if [[ -n "${hostkey}" ]]; then + ARGS+=(--hostkey "${hostkey}") + fi + if [[ -n "${ctrlkey}" ]]; then + ARGS+=(--ctrkey "${ctrlkey}") + fi
This part above sets arguments --hostkey and --ctrkey in ARGS to pass to _create_nvmet_subsystem(), but I find that _create_nvmet_subsystem() does not refer to the arguments. Though I know this part was in v3 also, I suggest drop this part.
common/nvme _nvmet_target_setup() { · line 851
Quoted 7 lines
common/nvme +7
-0+ + if [[ -n "${nvme_target_control}" ]]; then + eval "${nvme_target_control}" setup \ + --subsysnqn "${subsysnqn}" \ + --subsys-uuid "${subsys_uuid:-$def_subsys_uuid}" \ + --hostnqn "${def_hostnqn}" \ + "${ARGS[@]}" &> /dev/null
The line above causes the ShellCheck warning SC 2294. Let's replace ${ARGS[@]} with ${ARGS[*]}.
common/nvme _nvmet_target_setup() { · line 860
Quoted 9 lines
common/nvme +9
-0+ return + fi + + truncate -s "${NVME_IMG_SIZE}" "$(_nvme_def_file_path)" + if [[ "${blkdev_type}" == "device" ]]; then + blkdev="$(losetup -f --show "$(_nvme_def_file_path)")" + else + blkdev="$(_nvme_def_file_path)" + fi
This truncate and blkdev setup part causes failure of nvme/052:
nvme/052 (tr=loop) (Test file-ns creation/deletion under one subsystem) [failed]
runtime 5.728s ... 5.267s
--- tests/nvme/052.out 2024-11-05 17:04:40.596903603 +0900
+++ /home/shin/Blktests/blktests/results/nodev_tr_loop/nvme/052.out.bad 2024-11-29 14:45:23.065861316 +0900
@@ -1,2 +1,4 @@
Running nvme/052
+mkdir: cannot create directory ‘/sys/kernel/config/nvmet//subsystems/blktests-subsystem-1/namespaces/1’: File exists
+common/nvme: line 554: printf: write error: Device or resource busy
Test completeAlso, this part looks duplicated with the other part in _nvmet_target_setup(). Please see the 'if [[ "${blkdev_type}" != "none" ]]' block.
I guess this is the part you added "to specify the backing block device on the target, instead of hardcoding '/dev/vdc'". If so, I think such changes should be done under 'if [[ -n "${nvme_target_control}" ]]' condition.
From b86f26b4772ef5a458685fbf7dca14a50551a815 Mon Sep 17 00:00:00 2001
From: Shin'ichiro Kawasaki <[email protected]>
Date: Fri, 29 Nov 2024 10:48:31 +0900
Subject: [PATCH] nvme/{041-045,051}: double quote def_* variable references
The following commit will add the code to set nvme command output to def_* variables. This will trigger the ShellCheck warning SC2086. To prepare for the change, double quote the references to the def_* variables. As for nvme/051, the local variable ns is initialized with def_subsysnqn, then it requires double quote also.
--- tests/nvme/041 | 2 +- tests/nvme/042 | 4 ++-- tests/nvme/043 | 2 +- tests/nvme/044 | 4 ++-- tests/nvme/045 | 8 ++++---- tests/nvme/051 | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-)
tests/nvme/041 +1 -1
@@ -31,7 +31,7 @@ test() { local hostkey local ctrldev - hostkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)" + hostkey="$(nvme gen-dhchap-key -n "${def_subsysnqn}" 2> /dev/null)" if [ -z "$hostkey" ] ; then echo "nvme gen-dhchap-key failed" return 1
tests/nvme/042 +2 -2
@@ -37,7 +37,7 @@ test() { for hmac in 0 1 2 3; do echo "Testing hmac ${hmac}" - hostkey="$(nvme gen-dhchap-key --hmac=${hmac} -n ${def_subsysnqn} 2> /dev/null)" + hostkey="$(nvme gen-dhchap-key --hmac=${hmac} -n "${def_subsysnqn}" 2> /dev/null)" if [ -z "$hostkey" ] ; then echo "couldn't generate host key for hmac ${hmac}" return 1
@@ -51,7 +51,7 @@ test() { for key_len in 32 48 64; do echo "Testing key length ${key_len}" - hostkey="$(nvme gen-dhchap-key --key-length=${key_len} -n ${def_subsysnqn} 2> /dev/null)" + hostkey="$(nvme gen-dhchap-key --key-length=${key_len} -n "${def_subsysnqn}" 2> /dev/null)" if [ -z "$hostkey" ] ; then echo "couldn't generate host key for length ${key_len}" return 1
tests/nvme/043 +1 -1
@@ -34,7 +34,7 @@ test() { local hostkey local ctrldev - hostkey="$(nvme gen-dhchap-key -n ${def_hostnqn} 2> /dev/null)" + hostkey="$(nvme gen-dhchap-key -n "${def_hostnqn}" 2> /dev/null)" if [ -z "$hostkey" ] ; then echo "nvme gen-dhchap-key failed" return 1
tests/nvme/044 +2 -2
@@ -33,13 +33,13 @@ test() { local ctrlkey local ctrldev - hostkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)" + hostkey="$(nvme gen-dhchap-key -n "${def_subsysnqn}" 2> /dev/null)" if [ -z "$hostkey" ] ; then echo "failed to generate host key" return 1 fi - ctrlkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)" + ctrlkey="$(nvme gen-dhchap-key -n "${def_subsysnqn}" 2> /dev/null)" if [ -z "$ctrlkey" ] ; then echo "failed to generate ctrl key" return 1
tests/nvme/045 +4 -4
@@ -38,13 +38,13 @@ test() { local rand_io_size local ns - hostkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)" + hostkey="$(nvme gen-dhchap-key -n "${def_subsysnqn}" 2> /dev/null)" if [ -z "$hostkey" ] ; then echo "failed to generate host key" return 1 fi - ctrlkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)" + ctrlkey="$(nvme gen-dhchap-key -n "${def_subsysnqn}" 2> /dev/null)" if [ -z "$ctrlkey" ] ; then echo "failed to generate ctrl key" return 1
@@ -69,7 +69,7 @@ test() { echo "Renew host key on the controller" - new_hostkey="$(nvme gen-dhchap-key --nqn ${def_subsysnqn} 2> /dev/null)" + new_hostkey="$(nvme gen-dhchap-key --nqn "${def_subsysnqn}" 2> /dev/null)" _set_nvmet_hostkey "${def_hostnqn}" "${new_hostkey}"
@@ -79,7 +79,7 @@ test() { echo "Renew ctrl key on the controller" - new_ctrlkey="$(nvme gen-dhchap-key --nqn ${def_subsysnqn} 2> /dev/null)" + new_ctrlkey="$(nvme gen-dhchap-key --nqn "${def_subsysnqn}" 2> /dev/null)" _set_nvmet_ctrlkey "${def_hostnqn}" "${new_ctrlkey}"
tests/nvme/051 +2 -2
@@ -37,8 +37,8 @@ test() { # fire off two enable/disable loops concurrently and wait # for them to complete... - ns_enable_disable_loop $ns & - ns_enable_disable_loop $ns & + ns_enable_disable_loop "$ns" & + ns_enable_disable_loop "$ns" & wait _nvmet_target_cleanup
Signature · 1 line
2.46.2
Re: [PATCH blktests v4 5/5] nvme/055: add test for nvme-tcp zero-copy offload
In reply to Aurelien AptelQuoted 11 lines · Aurelien Aptel
This commit adds a new test for the kernel ULP DDP (Direct Data Placement) feature with NVMe-TCP.
Configuration of DDP is per NIC and is done through a script in the kernel source. For this reason we add 2 new config vars:
- KERNELSRC: path to the running kernel sources
-NVME_IFACE: name of the network interface to configure the offload onSigned-off-by Aurelien Aptel <[email protected]>Signed-off-by Shai Malin [email protected]Reviewed-by Daniel Wagner <[email protected]>
This test is interesting!
[...]
tests/nvme/055 line 5
Quoted 11 lines
tests/nvme/055 new file +5
-0@@ -0,0 +1,285 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2024 Aurelien Aptel <[email protected]> +# +# zero-copy offload
My understanding is that this test case requires the target set up by NVME_TARGET_CONTROL. Is it beneficial to explain what kind of target set up is required here?
Does this test case require specific hardware for nvme-tcp and zero-copy? If so, it can be described here also, probably.
Quoted 13 lines
tests/nvme/055 new file +13
-0+ +. tests/nvme/rc + +DESCRIPTION="enable zero copy offload and run rw traffic" +TIMED=1 + +iface_idx="" + +# these vars get updated after each call to connect_run_disconnect() +nb_packets=0 +nb_bytes=0 +nb_offload_packets=0 +nb_offload_bytes=0
tests/nvme/055 line 28
Quoted 10 lines
tests/nvme/055 new file +10
-0+offload_bytes_ratio=0 +offload_packets_ratio=0 + +requires() { + _nvme_requires + _require_remote_nvme_target + _require_nvme_trtype tcp + _have_kernel_option ULP_DDP + # require nvme-tcp as a module to be able to change the ddp_offload param + _have_module nvme_tcp && _have_module_param nvme_tcp ddp_offload
I checked the latest kernel source code but could not find the ddp_offload parameter. Do I miss anything? or Do you plan to post kernel patches for it?
Quoted 7 lines
tests/nvme/055 new file +7
-0+ _have_fio + _have_program ip + _have_program ethtool + _have_kernel_source && have_netlink_cli && _have_program python3 + have_iface +} +
[...]
tests/nvme/055 line 112
Quoted 8 lines
tests/nvme/055 new file +8
-0+ +connect_run_disconnect() { + local io_size + local nvme_dev + local nb_drop + local drop_ratio + local nb_resync + local resync_ratio
Nit: some local variables misses declarations here: nb_packets, nb_offload_packets, etc. It might be good to declare multiple variables in one line, like "local nb_drop nb_resync nb_packets ..." to reduce number of lines.
Re: [PATCH blktests v4 5/5] nvme/055: add test for nvme-tcp zero-copy offload
Quoted 3 lines · Shinichiro Kawasaki
My understanding is that this test case requires the target set up by
NVME_TARGET_CONTROL. Is it beneficial to explain what kind of target set up is required here?
Any target should do, but the host needs to use a NIC that supports DDP offload. This means the loop/localhost target cannot be used.
Quoted 2 lines
Does this test case require specific hardware for nvme-tcp and zero-copy? If so, it can be described here also, probably.
It requires hardware that supports the ULP DDP infrastructure (specifically nvme-tcp). This includes ConnectX 7 NIC and above or BlueField 3 DPU and above.
Quoted 10 lines
tests/nvme/055 line 28
Quoted 7 lines
tests/nvme/055 new file +7
-0+requires() { + _nvme_requires + _require_remote_nvme_target + _require_nvme_trtype tcp + _have_kernel_option ULP_DDP + # require nvme-tcp as a module to be able to change the ddp_offload param + _have_module nvme_tcp && _have_module_param nvme_tcp ddp_offloadI checked the latest kernel source code but could not find the
ddp_offloadparameter. Do I miss anything? or Do you plan to post kernel patches for it?
The DDP offload is part of the nvme-tcp offload series [1], and the only missing part is the netdev maintainer (Jakub) request of including the tests for the feature. We agreed to have those tests as part of blktests, which we will then run in a CI.
Quoted 8 lines
Quoted 7 lines
tests/nvme/055 new file +7
-0+ _have_fio + _have_program ip + _have_program ethtool + _have_kernel_source && have_netlink_cli && _have_program python3 + have_iface +} +[...]
Quoted 13 lines
tests/nvme/055 line 112
Quoted 8 lines
tests/nvme/055 new file +8
-0+ +connect_run_disconnect() { + local io_size + local nvme_dev + local nb_drop + local drop_ratio + local nb_resync + local resync_ratioNit: some local variables misses declarations here:
nb_packets,nb_offload_packets, etc. It might be good to declare multiple variables in one line, like "localnb_dropnb_resyncnb_packets..." to reduce number of lines.
These are not declared as local because they are global, see the top of the file.
I will declare the local ones on line when it makes it more readable.
Thanks.
Re: [PATCH blktests v4 1/5] nvme/rc: introduce remote target support
In reply to Shinichiro KawasakiQuoted 12 lines · Shinichiro Kawasaki
Review _cleanup_nvmet() { · line 220
Quoted 9 lines
(quoted diff) +5
-0@@ -208,6 +213,18 @@ _cleanup_nvmet() { _setup_nvmet() { _register_test_cleanup _cleanup_nvmet + + if [[ -n "${nvme_target_control}" ]]; then + def_hostnqn="$(${nvme_target_control} config --show-hostnqn)" + def_hostid="$(${nvme_target_control} config --show-hostid)" + def_host_traddr="$(${nvme_target_control} config --show-host-traddr)"I suggest to remove the line above. It caused ShellCheck warning SC2034. I think
def_host_traddris not used anywhere.
Ok.
Quoted 4 lines
Quoted 4 lines
(quoted diff) +0
-0@@ -811,6 +836,29 @@ _nvmet_target_setup() { fi fi
Quoted 11 lines
Review _nvmet_target_setup() { · line 844
Quoted 6 lines
(quoted diff) +6
-0+ if [[ -n "${hostkey}" ]]; then + ARGS+=(--hostkey "${hostkey}") + fi + if [[ -n "${ctrlkey}" ]]; then + ARGS+=(--ctrkey "${ctrlkey}") + fiThis part above sets arguments --hostkey and --ctrkey in ARGS to pass to
_create_nvmet_subsystem(), but I find that_create_nvmet_subsystem()does not refer to the arguments. Though I know this part was in v3 also, I suggest drop this part.
Good point.
Quoted 10 lines
Review _nvmet_target_setup() { · line 851
Quoted 7 lines
(quoted diff) +7
-0+ + if [[ -n "${nvme_target_control}" ]]; then + eval "${nvme_target_control}" setup \ + --subsysnqn "${subsysnqn}" \ + --subsys-uuid "${subsys_uuid:-$def_subsys_uuid}" \ + --hostnqn "${def_hostnqn}" \ + "${ARGS[@]}" &> /dev/nullThe line above causes the ShellCheck warning SC 2294. Let's replace ${ARGS[@]} with ${ARGS[*]}.
I think using quoting [*] will merge the args as one and is not what we want. I will remove the eval instead. It came from v3, not sure why it is needed.
Quoted 10 lines
Review _nvmet_target_setup() { · line 860
Quoted 9 lines
(quoted diff) +9
-0+ return + fi + + truncate -s "${NVME_IMG_SIZE}" "$(_nvme_def_file_path)" + if [[ "${blkdev_type}" == "device" ]]; then + blkdev="$(losetup -f --show "$(_nvme_def_file_path)")" + else + blkdev="$(_nvme_def_file_path)" + fi
Quoted 4 lines
This truncate and blkdev setup part causes failure of nvme/052:
[...]
Also, this part looks duplicated with the other part in_nvmet_target_setup(). Please see the 'if [[ "${blkdev_type}" != "none" ]]' block.
You're correct, this was a rebasing mistake. I will remove it.
Quoted 3 lines
I guess this is the part you added "to specify the backing block device on the target, instead of hardcoding '
/dev/vdc'". If so, I think such changes should be done under 'if [[ -n "${nvme_target_control}" ]]' condition.
No that part is done in the contrib/ script and the template.
Thanks