]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
nvme/048: test queue count changes on reconnect
authorDaniel Wagner <dwagner@suse.de>
Thu, 6 Apr 2023 08:30:50 +0000 (10:30 +0200)
committerShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Wed, 12 Apr 2023 10:45:16 +0000 (19:45 +0900)
The target is allowed to change the number of I/O queues. Test if the
host is able to reconnect in this scenario.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
[Shin'ichiro: added _setup_nvmet and replaced spaces with tabs]
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
tests/nvme/048 [new file with mode: 0755]
tests/nvme/048.out [new file with mode: 0644]

diff --git a/tests/nvme/048 b/tests/nvme/048
new file mode 100755 (executable)
index 0000000..09e205f
--- /dev/null
@@ -0,0 +1,127 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2023 Daniel Wagner, SUSE Labs
+#
+# Test queue count changes on reconnect
+
+. tests/nvme/rc
+
+DESCRIPTION="Test queue count changes on reconnect"
+
+requires() {
+       _nvme_requires
+       _have_loop
+       _require_nvme_trtype tcp rdma fc
+       _require_min_cpus 2
+}
+
+nvmf_wait_for_state() {
+       local def_state_timeout=5
+       local subsys_name="$1"
+       local state="$2"
+       local timeout="${3:-$def_state_timeout}"
+       local nvmedev
+       local state_file
+       local start_time
+       local end_time
+
+       nvmedev=$(_find_nvme_dev "${subsys_name}")
+       state_file="/sys/class/nvme-fabrics/ctl/${nvmedev}/state"
+
+       start_time=$(date +%s)
+       while ! grep -q "${state}" "${state_file}"; do
+               sleep 1
+               end_time=$(date +%s)
+               if (( end_time - start_time > timeout )); then
+                       echo "expected state \"${state}\" not " \
+                               "reached within ${timeout} seconds"
+                       return 1
+               fi
+       done
+
+       return 0
+}
+
+set_nvmet_attr_qid_max() {
+       local nvmet_subsystem="$1"
+       local qid_max="$2"
+       local cfs_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}"
+
+       echo "${qid_max}" > "${cfs_path}/attr_qid_max"
+}
+
+set_qid_max() {
+       local port="$1"
+       local subsys_name="$2"
+       local qid_max="$3"
+
+       set_nvmet_attr_qid_max "${subsys_name}" "${qid_max}"
+
+       # Setting qid_max forces a disconnect and the reconntect attempt starts
+       nvmf_wait_for_state "${subsys_name}" "connecting" || return 1
+       nvmf_wait_for_state "${subsys_name}" "live" || return 1
+
+       return 0
+}
+
+test() {
+       local subsys_name="blktests-subsystem-1"
+       local cfs_path="${NVMET_CFS}/subsystems/${subsys_name}"
+       local file_path="${TMPDIR}/img"
+       local skipped=false
+       local hostnqn
+       local hostid
+       local port
+
+       echo "Running ${TEST_NAME}"
+
+       _setup_nvmet
+
+       hostid="$(uuidgen)"
+       if [ -z "$hostid" ] ; then
+               echo "uuidgen failed"
+               return 1
+       fi
+       hostnqn="nqn.2014-08.org.nvmexpress:uuid:${hostid}"
+
+       truncate -s 512M "${file_path}"
+
+       _create_nvmet_subsystem "${subsys_name}" "${file_path}" \
+               "b92842df-a394-44b1-84a4-92ae7d112861"
+       port="$(_create_nvmet_port "${nvme_trtype}")"
+       _add_nvmet_subsys_to_port "${port}" "${subsys_name}"
+       _create_nvmet_host "${subsys_name}" "${hostnqn}"
+
+       if [[ -f "${cfs_path}/attr_qid_max" ]] ; then
+               _nvme_connect_subsys "${nvme_trtype}" "${subsys_name}" \
+                                       --hostnqn "${hostnqn}" \
+                                       --hostid "${hostid}" \
+                                       --keep-alive-tmo 1 \
+                                       --reconnect-delay 2
+
+               if ! nvmf_wait_for_state "${subsys_name}" "live" ; then
+                       echo FAIL
+               else
+                       set_qid_max "${port}" "${subsys_name}" 1 || echo FAIL
+                       set_qid_max "${port}" "${subsys_name}" 128 || echo FAIL
+               fi
+
+               _nvme_disconnect_subsys "${subsys_name}"
+       else
+               SKIP_REASONS+=("missing attr_qid_max feature")
+               skipped=true
+       fi
+
+       _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
+       _remove_nvmet_subsystem "${subsys_name}"
+       _remove_nvmet_port "${port}"
+       _remove_nvmet_host "${hostnqn}"
+
+       rm "${file_path}"
+
+       if [[ "${skipped}" = true ]] ; then
+               return 1
+       fi
+
+       echo "Test complete"
+}
diff --git a/tests/nvme/048.out b/tests/nvme/048.out
new file mode 100644 (file)
index 0000000..7f986ef
--- /dev/null
@@ -0,0 +1,3 @@
+Running nvme/048
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Test complete