Skip to contentSkip to conversation

nvme: add nvmf reset/disconnect during traffic test

PATCH Superseded Sagi Grimberg 2 participants 2 messages Jun 29, 2022 NVMe

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sagi Grimberg

author maintainer
#0 lore raw

PATCH 1/1 nvme: add nvmf reset/disconnect during traffic test

Test traffic controller reset and disconnect during traffic.

---
 tests/nvme/040     | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/040.out |  6 +++++
 tests/nvme/rc      |  8 +++++++
 3 files changed, 69 insertions(+)
 create mode 100755 tests/nvme/040
 create mode 100644 tests/nvme/040.out
tests/nvme/040 new file +55 -0
new file mode 100755
index 000000000000..88d255a8d0e0
@@ -0,0 +1,55 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2019 Yi Zhang <[email protected]>
+#
+# Test nvme fabrics controller reset/disconnect/reconnect operation during I/O
+# This test is somewhat similar to test 032 but for fabrics controllers.
+
+. tests/nvme/rc
+
+DESCRIPTION="test nvme fabrics controller reset/disconnect operation during I/O"
+
+requires() {
+	_nvme_requires
+	_have_loop
+	_have_fio
+	_require_nvme_trtype_is_fabrics
+}
+
+test() {
+	local subsys="blktests-subsystem-"
+	local port
+	local loop_dev
+	local nvmedev
+
+	echo "Running ${TEST_NAME}"
+
+	_setup_nvmet
+	truncate -s 1G "$TMPDIR/img"
+	loop_dev="$(losetup -f --show "$TMPDIR/img")"
+
+	port="$(_create_nvmet_port "${nvme_trtype}")"
+	_create_nvmet_subsystem "${subsys}" "${loop_dev}"
+	_add_nvmet_subsys_to_port "${port}" "${subsys}"
+	_nvme_connect_subsys "${nvme_trtype}" "${subsys}"
+	udevadm settle
+	nvmedev=$(_find_nvme_dev "${subsys}")
+
+	# start fio job
+	echo "starting background fio on ${nvmedev}n1"
+	_run_fio_rand_io --filename="${nvmedev}n1" --size=1g \
+		--group_reporting --ramp_time=5  &> /dev/null &
+	sleep 5
+
+	# do reset/remove operation
+	echo "resetting ${nvmedev}"
+	_nvme_reset_ctrl ${nvmedev}
+	sleep 1
+	echo "deleting ${nvmedev}"
+	_nvme_delete_ctrl ${nvmedev}
+
+	echo "stopping background fio on ${nvmedev}n1"
+	{ kill $!; wait; } &> /dev/null
+
+	echo "Test complete"
+}
tests/nvme/040.out new file +6 -0
new file mode 100644
index 000000000000..f14ae8db1ddb
@@ -0,0 +1,6 @@
+Running nvme/040
+starting background fio on nvme0n1
+resetting nvme0
+deleting nvme0
+stopping background fio on nvme0n1
+Test complete
tests/nvme/rc +8 -0
index 4bebbc762cbb..684d56b184e5 100644
@@ -447,3 +447,11 @@ _nvme_disable_err_inject()
         echo 0 > /sys/kernel/debug/"$1"/fault_inject/probability
         echo 0 > /sys/kernel/debug/"$1"/fault_inject/times
 }
+
+_nvme_reset_ctrl() {
+	echo 1 > /sys/class/nvme/$1/reset_controller
+}
+
+_nvme_delete_ctrl() {
+	echo 1 > /sys/class/nvme/$1/delete_controller
+}
Signature · 1 line
2.34.1
#1 lore raw
Quoted 1 line · Sagi Grimberg

Test traffic controller reset and disconnect during traffic.

Hi Sagi, thanks for the patch. This test case looks valuable. Is there any specific kernel bug or fix which motivated to add this test case? If so, it would be useful to note it in this commit message and the header comment of the test case.

Quoted 16 lines
---
 tests/nvme/040     | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/nvme/040.out |  6 +++++
 tests/nvme/rc      |  8 +++++++
 3 files changed, 69 insertions(+)
 create mode 100755 tests/nvme/040
 create mode 100644 tests/nvme/040.out
tests/nvme/040 new file +0 -0
new file mode 100755
index 000000000000..88d255a8d0e0

tests/nvme/040 line 3

Quoted 3 lines
tests/nvme/040 new file +3 -0
@@ -0,0 +1,55 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2019 Yi Zhang <[email protected]>

Was this authored by Yi in 2019?

tests/nvme/040 line 6

Quoted 3 lines
tests/nvme/040 new file +3 -0
+#
+# Test nvme fabrics controller reset/disconnect/reconnect operation during I/O
+# This test is somewhat similar to test 032 but for fabrics controllers.

Ah, the copyright was copied from nvme/032, probably.

Quoted 4 lines
tests/nvme/040 new file +4 -0
+
+. tests/nvme/rc
+
+DESCRIPTION="test nvme fabrics controller reset/disconnect operation during I/O"

tests/nvme/040 line 20

Quoted 10 lines
tests/nvme/040 new file +10 -0
+
+requires() {
+	_nvme_requires
+	_have_loop
+	_have_fio
+	_require_nvme_trtype_is_fabrics
+}
+
+test() {
+	local subsys="blktests-subsystem-"

As for the sub-system name, other test cases have a number after "blktests-subsystem-". "blktests-subsystem-1" would be the better for this test case also, just for consistency.

Quoted 22 lines
tests/nvme/040 new file +22 -0
+	local port
+	local loop_dev
+	local nvmedev
+
+	echo "Running ${TEST_NAME}"
+
+	_setup_nvmet
+	truncate -s 1G "$TMPDIR/img"
+	loop_dev="$(losetup -f --show "$TMPDIR/img")"
+
+	port="$(_create_nvmet_port "${nvme_trtype}")"
+	_create_nvmet_subsystem "${subsys}" "${loop_dev}"
+	_add_nvmet_subsys_to_port "${port}" "${subsys}"
+	_nvme_connect_subsys "${nvme_trtype}" "${subsys}"
+	udevadm settle
+	nvmedev=$(_find_nvme_dev "${subsys}")
+
+	# start fio job
+	echo "starting background fio on ${nvmedev}n1"
+	_run_fio_rand_io --filename="${nvmedev}n1" --size=1g \
+		--group_reporting --ramp_time=5  &> /dev/null &
+	sleep 5

tests/nvme/040 line 52

Quoted 10 lines
tests/nvme/040 new file +10 -0
+
+	# do reset/remove operation
+	echo "resetting ${nvmedev}"
+	_nvme_reset_ctrl ${nvmedev}
+	sleep 1
+	echo "deleting ${nvmedev}"
+	_nvme_delete_ctrl ${nvmedev}
+
+	echo "stopping background fio on ${nvmedev}n1"
+	{ kill $!; wait; } &> /dev/null

It looks like that clean up helper function calls for the port and the sybsystem are missing. When I ran this test case, I observed WARNINGS as follows, which _cleanup_nvmet() in nvme/rc prints out.

WARNING: Test did not clean up port: 0
WARNING: Test did not clean up subsystem: blktests-subsystem-

Quoted 9 lines
tests/nvme/040 new file +3 -0
+
+	echo "Test complete"
+}
tests/nvme/040.out new file +0 -0
new file mode 100644
index 000000000000..f14ae8db1ddb

tests/nvme/040.out line 5

Quoted 5 lines
tests/nvme/040.out new file +5 -0
@@ -0,0 +1,6 @@
+Running nvme/040
+starting background fio on nvme0n1
+resetting nvme0
+deleting nvme0
+stopping background fio on nvme0n1

The nvme controller name "nvme0" is assumed in the out file. However, when the test system has nvme devices, the name of the nvme controller created by this test case is not "nvme0". Then this test case fails. I suggest not to record the nvme device names in the out file.

Quoted 20 lines
tests/nvme/040.out new file +1 -0
+Test complete
tests/nvme/rc +8 -0
index 4bebbc762cbb..684d56b184e5 100644
@@ -447,3 +447,11 @@ _nvme_disable_err_inject()
         echo 0 > /sys/kernel/debug/"$1"/fault_inject/probability
         echo 0 > /sys/kernel/debug/"$1"/fault_inject/times
 }
+
+_nvme_reset_ctrl() {
+	echo 1 > /sys/class/nvme/$1/reset_controller
+}
+
+_nvme_delete_ctrl() {
+	echo 1 > /sys/class/nvme/$1/delete_controller
+}
Signature · 1 line
2.34.1

And shellcheck complains that some variable references lack double quotes.

$ make check
shellcheck -x -e SC2119 -f gcc check new common/* \
        tests/*/rc tests/*/[0-9]*[0-9]
tests/nvme/rc:452:27: note: Double quote to prevent globbing and word splitting. [SC2086]
tests/nvme/rc:456:27: note: Double quote to prevent globbing and word splitting. [SC2086]
tests/nvme/040:46:19: note: Double quote to prevent globbing and word splitting. [SC2086]
tests/nvme/040:49:20: note: Double quote to prevent globbing and word splitting. [SC2086]
make: *** [Makefile:21: check] Error 1
Signature · 1 line
Shin'ichiro Kawasaki