[PATCH blktests v2 11/13] common/nvme, nvme/003: specify "--port none" to _nvme_connect_subsys()

Shin'ichiro Kawasaki shinichiro.kawasaki at wdc.com
Tue Oct 29 23:51:47 PDT 2024


Commit "nvme: pass in port parameter to _nvme_connect_subsys()"
introduced the --port argument to _nvme_connect_subsys(). If the option
is not specified, _nvme_connect_subsys() automatically finds the port
for the specified subsysnqn. However, this does not work for the test
case nvme/003, since the test case connects to the subsys for discovery,
then, the port of the created subsysnqn is not to be used. This causes
the failure of the test case.

To avoid the failure, modify _nvme_connect_subsys() to take the special
value "none" for the --port option. When "--port none" is specified,
_nvme_connect_subsys() skips the steps to obtain port dependent
parameters and just use default parameters.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki at wdc.com>
---
 common/nvme    | 41 ++++++++++++++++++++++++++++++-----------
 tests/nvme/003 |  3 ++-
 2 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/common/nvme b/common/nvme
index 6513205..3a2bb35 100644
--- a/common/nvme
+++ b/common/nvme
@@ -690,22 +690,41 @@ _get_nvmet_port_params() {
 	local port="$1"
 	local -n args="$2"
 	local cfs_path="${NVMET_CFS}/ports/${port}"
-	local trtype
-	local traddr
-	local trsvcid
+	local trtype="${nvme_trtype}"
+	local traddr="${def_traddr}"
+	local trsvcid="${def_trsvcid}"
 
-	[[ -d "${cfs_path}" ]] || exit 1
-	trtype=$(cat "${cfs_path}/addr_trtype")
+	# When port is specified, get port dependent parameter values
+	if [[ $port != none ]]; then
+		[[ -d "${cfs_path}" ]] || exit 1
+		trtype=$(cat "${cfs_path}/addr_trtype")
+		traddr=$(cat "${cfs_path}/addr_traddr")
+		args+=(--traddr "${traddr}")
+		if [[ "${trtype}" == "tcp" ]] || [[ "${trtype}" == "rdma" ]]; then
+			trsvcid=$(cat "${cfs_path}/addr_trsvcid")
+		fi
+	fi
+
+	# Prepare parameter options
 	args+=(--transport "${trtype}")
-	traddr=$(cat "${cfs_path}/addr_traddr")
-	args+=(--traddr "${traddr}")
-	if [[ "${trtype}" == "tcp" ]] || [[ "${trtype}" == "rdma" ]]; then
-		trsvcid=$(cat "${cfs_path}/addr_trsvcid")
+	case ${trtype} in
+	loop)
+		;;
+	rdma | tcp)
+		if [[ $port == none ]]; then
+			args+=(--traddr "${traddr}")
+		fi
 		args+=(--trsvcid "${trsvcid}")
-	elif [[ "${trtype}" == "fc" ]]; then
+		;;
+	fc)
 		args+=(--traddr "$(_fc_traddr "$port")")
 		args+=(--host-traddr "$(_fc_host_traddr "$port")")
-	fi
+		;;
+	*)
+		echo Unexpected transport type: "${trtype}"
+		exit
+		;;
+	esac
 }
 
 _find_nvme_dev() {
diff --git a/tests/nvme/003 b/tests/nvme/003
index 36c0753..2222ad1 100755
--- a/tests/nvme/003
+++ b/tests/nvme/003
@@ -28,7 +28,8 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys --subsysnqn "nqn.2014-08.org.nvmexpress.discovery"
+	_nvme_connect_subsys --port none \
+			     --subsysnqn "nqn.2014-08.org.nvmexpress.discovery"
 
 	# This is ugly but checking for the absence of error messages is ...
 	sleep 10
-- 
2.45.2




More information about the Linux-nvme mailing list