Skip to contentSkip to conversation

refactoring and various cleanups/fixes

PATCH Applied Daniel Wagner 2 participants 23 messages Mar 26, 2024 – Mar 29, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover refactoring and various cleanups/fixes

I've updated the passthru tests in the same way as the rest of the fabric tests.

changes:
v3:
- streamlined passthru tests according the rest of the fabric tests

v2:
- addressed 'make check' errors
- squashed 'nvme/rc: remove correct port from target'
into 'nvme/rc: add nqn/uuid args to target setup/cleanup helper'
- reordered patches
- added 'nvme: drop default trtype argument for _nvmet_passthru_target_connect'
- https://lore.kernel.org/linux-nvme/[email protected]/

v1:
- https://lore.kernel.org/linux-nvme/[email protected]/

Daniel Wagner (20):
nvme/rc: silence error on module unload for fc
nvme/rc: silence fcloop cleanup failures
nvme/rc: log error if stale configuration is found common/xfs: propagate errors from _xfs_run_fio_verify_io nvme/{012,013,035}: check return value of _xfs_run_fio_verify_io nvme/rc: use long command line option for nvme nvme/{014,015,018,019,020,023,024,026,045,046}: use long command line
option for nvme
nvme/rc: connect subsys only support long options
nvme/rc: add nqn/uuid args to target setup/cleanup helper nvme/rc: remove unused connect options
nvme/rc: do not cleanup external managed loop device nvme/031: do not open code target setup/cleanup
nvme: drop default trtype argument for _nvmet_connect_subsys
nvme: drop default trtype argument for _nvmet_passthru_target_connect
nvme: drop default subsysnqn argument from
_nvme_{connect|disconnect}_subsys
nvme: drop default subsysnqn argument from

    _nvme_passthru_target_{setup|cleanup}

nvme: drop default subsysnqn argument from
_nvmet_passthru_target_connect
nvme/{041,042,043,044,045,048}: do not pass default host{nqn|id} to
_nvme_connect_subsys
nvme: don't assume namespace id
nvme/028: drop unused nvmedev

 common/xfs     |   9 +-
 tests/nvme/003 |   4 +-
 tests/nvme/004 |   5 +-
 tests/nvme/005 |   2 +-
 tests/nvme/008 |   4 +-
 tests/nvme/009 |   4 +-
 tests/nvme/010 |  11 ++-
 tests/nvme/011 |  11 ++-
 tests/nvme/012 |  13 +--
 tests/nvme/013 |  13 +--
 tests/nvme/014 |  17 ++--
 tests/nvme/015 |  17 ++--
 tests/nvme/018 |  20 ++---
 tests/nvme/019 |  13 ++-
 tests/nvme/020 |  12 +--
 tests/nvme/021 |  11 ++-
 tests/nvme/022 |   4 +-
 tests/nvme/023 |  11 ++-
 tests/nvme/024 |  12 +--
 tests/nvme/025 |  11 ++-
 tests/nvme/026 |  11 ++-
 tests/nvme/027 |   4 +-
 tests/nvme/028 |   9 +-
 tests/nvme/029 |  11 +--
 tests/nvme/031 |  16 ++--
 tests/nvme/033 |   8 +-
 tests/nvme/034 |   8 +-
 tests/nvme/035 |  12 +--
 tests/nvme/036 |   8 +-
 tests/nvme/037 |  10 ++-
 tests/nvme/040 |   6 +-
 tests/nvme/041 |  13 +--
 tests/nvme/042 |  14 +--
 tests/nvme/043 |  14 +--
 tests/nvme/044 |  28 ++----
 tests/nvme/045 |  17 ++--
 tests/nvme/046 |   7 +-
 tests/nvme/047 |  16 ++--
 tests/nvme/048 |   9 +-
 tests/nvme/rc  | 232 ++++++++++++++++++++++++++++++++++---------------
 40 files changed, 357 insertions(+), 300 deletions(-)
Signature · 1 line
2.44.0
#1 lore raw

PATCH v3 1/20 nvme/rc: silence error on module unload for fc

The other transports silence the error output when trying to unload the module. Do the same for FC.

---
 tests/nvme/rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/nvme/rc +1 -1
index 2d6ebeab2f6f..78d84af72e73 100644
@@ -332,7 +332,7 @@ _cleanup_nvmet() {
 	if [[ "${nvme_trtype}" == "fc" ]]; then
 		_cleanup_fcloop "${def_local_wwnn}" "${def_local_wwpn}" \
 				"${def_remote_wwnn}" "${def_remote_wwpn}"
-		modprobe -rq nvme-fcloop
+		modprobe -rq nvme-fcloop 2>/dev/null
 	fi
 	modprobe -rq nvme-"${nvme_trtype}" 2>/dev/null
 	if [[ "${nvme_trtype}" != "loop" ]]; then
Signature · 1 line
2.44.0
#2 lore raw

PATCH v3 2/20 nvme/rc: silence fcloop cleanup failures

In reply to Daniel Wagner

When the ctl file is missing we are logging

tests/nvme/rc: line 265: /sys/class/fcloop/ctl/del_target_port: No such file or directory tests/nvme/rc: line 257: /sys/class/fcloop/ctl/del_local_port: No such file or directory tests/nvme/rc: line 249: /sys/class/fcloop/ctl/del_remote_port: No such file or directory

because the first redirect operator fails. Also it's not possible to redirect the 'echo' error to /dev/null, because it's a builtin command which escapes the stderr redirect operator (why?).

Anyway, the simplest way to catch this error is to first check if the control file exists before attempting to write to it.

---
 tests/nvme/rc | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
tests/nvme/rc +12 -3
index 78d84af72e73..865c8c351159 100644
@@ -234,7 +234,10 @@ _nvme_fcloop_del_rport() {
 	local remote_wwpn="$4"
 	local loopctl=/sys/class/fcloop/ctl
 
-	echo "wwnn=${remote_wwnn},wwpn=${remote_wwpn}" > ${loopctl}/del_remote_port 2> /dev/null
+	if [[ ! -f "${loopctl}/del_remote_port" ]]; then
+		return
+	fi
+	echo "wwnn=${remote_wwnn},wwpn=${remote_wwpn}" > "${loopctl}/del_remote_port"
 }
 
 _nvme_fcloop_del_lport() {
@@ -242,7 +245,10 @@ _nvme_fcloop_del_lport() {
 	local wwpn="$2"
 	local loopctl=/sys/class/fcloop/ctl
 
-	echo "wwnn=${wwnn},wwpn=${wwpn}" > ${loopctl}/del_local_port 2> /dev/null
+	if [[ ! -f "${loopctl}/del_local_port" ]]; then
+		return
+	fi
+	echo "wwnn=${wwnn},wwpn=${wwpn}" > "${loopctl}/del_local_port"
 }
 
 _nvme_fcloop_del_tport() {
@@ -250,7 +256,10 @@ _nvme_fcloop_del_tport() {
 	local wwpn="$2"
 	local loopctl=/sys/class/fcloop/ctl
 
-	echo "wwnn=${wwnn},wwpn=${wwpn}" > ${loopctl}/del_target_port 2> /dev/null
+	if [[ ! -f "${loopctl}/del_target_port" ]]; then
+		return
+	fi
+	echo "wwnn=${wwnn},wwpn=${wwpn}" > "${loopctl}/del_target_port"
 }
 
 _cleanup_fcloop() {
Signature · 1 line
2.44.0
#3 lore raw

PATCH v3 3/20 nvme/rc: log error if stale configuration is found

In reply to Daniel Wagner

It's possible that a previous run of blktest left some stale configuration left. E.g. when the module unload doesn't work (the bug might in the kernel we are testing). In this case error out and avoid confusion.

---
 tests/nvme/rc | 5 +++++
 1 file changed, 5 insertions(+)
tests/nvme/rc +5 -0
index 865c8c351159..e67bb846ab77 100644
@@ -658,6 +658,11 @@ _create_nvmet_host() {
 	local nvmet_ctrlkey="$4"
 	local host_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}"
 
+	if [[ -d "${host_path}" ]]; then
+		echo "FAIL target setup failed. stale host configuration found"
+		return 1;
+	fi
+
 	mkdir "${host_path}"
 	_add_nvmet_allow_hosts "${nvmet_subsystem}" "${nvmet_hostnqn}"
 	if [[ "${nvmet_hostkey}" ]] ; then
Signature · 1 line
2.44.0
#4 lore raw

PATCH v3 4/20 common/xfs: propagate errors from _xfs_run_fio_verify_io

In reply to Daniel Wagner

If _xfs_mkfs_and_mount fails _xfs_run_fio_verify_io will continue to execute and fio will run against the local file system instead against the block device.

Propagate all errors back to the caller.

---
 common/xfs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
common/xfs +7 -2
index 37ce85878df2..569770fecd53 100644
@@ -16,7 +16,7 @@ _xfs_mkfs_and_mount() {
 
 	mkdir -p "${mount_dir}"
 	umount "${mount_dir}"
-	mkfs.xfs -l size=64m -f "${bdev}"
+	mkfs.xfs -l size=64m -f "${bdev}" || return $?
 	mount "${bdev}" "${mount_dir}"
 }
 
@@ -27,8 +27,10 @@ _xfs_run_fio_verify_io() {
 	local sz_mb
 	local avail
 	local avail_mb
+	local rc
 
-	_xfs_mkfs_and_mount "${bdev}" "${mount_dir}" >> "${FULL}" 2>&1
+	_xfs_mkfs_and_mount "${bdev}" "${mount_dir}" \
+		>>"${FULL}" 2>&1 || return $?
 
 	avail="$(df --output=avail "${mount_dir}" | tail -1)"
 	avail_mb="$((avail / 1024))"
@@ -43,7 +45,10 @@ _xfs_run_fio_verify_io() {
 	fi
 
 	_run_fio_verify_io --size="${sz_mb}m" --directory="${mount_dir}/"
+	rc=$?
 
 	umount "${mount_dir}" >> "${FULL}" 2>&1
 	rm -fr "${mount_dir}"
+
+	return "${rc}"
 }
Signature · 1 line
2.44.0
#5 lore raw

PATCH v3 5/20 nvme/{012,013,035}: check return value of _xfs_run_fio_verify_io

In reply to Daniel Wagner

When _xfs_run_fio_verify_io fails we should log the error. Currently, no failure is detected when this function fails.

---
 tests/nvme/012 | 4 +++-
 tests/nvme/013 | 4 +++-
 tests/nvme/035 | 4 +++-
 3 files changed, 9 insertions(+), 3 deletions(-)
tests/nvme/012 +3 -1
index c5e0eb9c5e23..f0914ce3206b 100755
@@ -33,7 +33,9 @@ test() {
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
-	_xfs_run_fio_verify_io "/dev/${nvmedev}n1"
+	if ! _xfs_run_fio_verify_io "/dev/${nvmedev}n1"; then
+		echo "FAIL: fio verify failed"
+	fi
 
 	_nvme_disconnect_subsys "${def_subsysnqn}"
 
tests/nvme/013 +3 -1
index 3ec280ff24cf..3cef009cb9f4 100755
@@ -32,7 +32,9 @@ test() {
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
-	_xfs_run_fio_verify_io "/dev/${nvmedev}n1"
+	if ! _xfs_run_fio_verify_io "/dev/${nvmedev}n1"; then
+		echo "FAIL: fio verify failed"
+	fi
 
 	_nvme_disconnect_subsys "${def_subsysnqn}"
 
tests/nvme/035 +3 -1
index 712fe1dbcfb8..01aa09077d6a 100755
@@ -31,7 +31,9 @@ test_device() {
 	_nvmet_passthru_target_setup "${def_subsysnqn}"
 	nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" "${def_subsysnqn}")
 
-	_xfs_run_fio_verify_io "${nsdev}" "${nvme_img_size}"
+	if ! _xfs_run_fio_verify_io "${nsdev}" "${nvme_img_size}"; then
+		echo "FAIL: fio verify failed"
+	fi
 
 	_nvme_disconnect_subsys "${def_subsysnqn}"
 	_nvmet_passthru_target_cleanup "${def_subsysnqn}"
Signature · 1 line
2.44.0
#6 lore raw

PATCH v3 6/20 nvme/rc: use long command line option for nvme

In reply to Daniel Wagner

The long format of the command line option are more descriptive and more likely to stay stable.

---
 tests/nvme/rc | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
tests/nvme/rc +9 -9
index e67bb846ab77..6bf2e3ae37c5 100644
@@ -148,7 +148,7 @@ _require_nvme_trtype_is_fabrics() {
 }
 
 _require_nvme_cli_auth() {
-	if ! nvme gen-dhchap-key -n nvmf-test-subsys > /dev/null 2>&1 ; then
+	if ! nvme gen-dhchap-key --nqn nvmf-test-subsys > /dev/null 2>&1 ; then
 		SKIP_REASONS+=("nvme gen-dhchap-key command missing")
 		return 1
 	fi
@@ -396,13 +396,13 @@ _setup_nvmet() {
 _nvme_disconnect_ctrl() {
 	local ctrl="$1"
 
-	nvme disconnect -d "${ctrl}"
+	nvme disconnect --device "${ctrl}"
 }
 
 _nvme_disconnect_subsys() {
 	local subsysnqn="$1"
 
-	nvme disconnect -n "${subsysnqn}" |& tee -a "$FULL" |
+	nvme disconnect --nqn "${subsysnqn}" |& tee -a "$FULL" |
 		grep -o "disconnected.*"
 }
 
@@ -496,11 +496,11 @@ _nvme_connect_subsys() {
 	trtype="$1"
 	subsysnqn="$2"
 
-	ARGS=(-t "${trtype}" -n "${subsysnqn}")
+	ARGS=(--transport "${trtype}" --nqn "${subsysnqn}")
 	if [[ "${trtype}" == "fc" ]] ; then
-		ARGS+=(-a "${traddr}" -w "${host_traddr}")
+		ARGS+=(--traddr "${traddr}" --host-traddr "${host_traddr}")
 	elif [[ "${trtype}" != "loop" ]]; then
-		ARGS+=(-a "${traddr}" -s "${trsvcid}")
+		ARGS+=(--traddr "${traddr}" --trsvcid "${trsvcid}")
 	fi
 	ARGS+=(--hostnqn="${hostnqn}")
 	ARGS+=(--hostid="${hostid}")
@@ -565,13 +565,13 @@ _nvme_discover() {
 	local host_traddr="${3:-$def_host_traddr}"
 	local trsvcid="${3:-$def_trsvcid}"
 
-	ARGS=(-t "${trtype}")
+	ARGS=(--transport "${trtype}")
 	ARGS+=(--hostnqn="${def_hostnqn}")
 	ARGS+=(--hostid="${def_hostid}")
 	if [[ "${trtype}" = "fc" ]]; then
-		ARGS+=(-a "${traddr}" -w "${host_traddr}")
+		ARGS+=(--traddr "${traddr}" --host-traddr "${host_traddr}")
 	elif [[ "${trtype}" != "loop" ]]; then
-		ARGS+=(-a "${traddr}" -s "${trsvcid}")
+		ARGS+=(--traddr "${traddr}" --trsvcid "${trsvcid}")
 	fi
 	nvme discover "${ARGS[@]}"
 }
Signature · 1 line
2.44.0
#7 lore raw

PATCH v3 7/20 nvme/{014,015,018,019,020,023,024,026,045,046}: use long command line option for nvme

In reply to Daniel Wagner

The long format of the command line option are more descriptive and more likely to stay stable.

---
 tests/nvme/014 | 2 +-
 tests/nvme/015 | 2 +-
 tests/nvme/018 | 3 ++-
 tests/nvme/019 | 3 ++-
 tests/nvme/020 | 3 ++-
 tests/nvme/023 | 3 ++-
 tests/nvme/024 | 3 ++-
 tests/nvme/026 | 3 ++-
 tests/nvme/045 | 4 ++--
 tests/nvme/046 | 7 ++++---
 10 files changed, 20 insertions(+), 13 deletions(-)
tests/nvme/014 +1 -1
index 31bfeb76d13d..c02167142cb3 100755
@@ -39,7 +39,7 @@ test() {
 	dd if=/dev/urandom of="/dev/${nvmedev}n1" \
 		count="${count}" bs="${bs}" status=none
 
-	nvme flush "/dev/${nvmedev}" -n 1
+	nvme flush "/dev/${nvmedev}" --namespace-id 1
 
 	_nvme_disconnect_subsys "${def_subsysnqn}"
 
tests/nvme/015 +1 -1
index 4315ffa57577..8ea90f10bda7 100755
@@ -39,7 +39,7 @@ test() {
 	dd if=/dev/urandom of="/dev/${nvmedev}n1" \
 		count="${count}" bs="${bs}" status=none
 
-	nvme flush "/dev/${nvmedev}n1" -n 1
+	nvme flush "/dev/${nvmedev}n1" --namespace-id 1
 
 	_nvme_disconnect_subsys "${def_subsysnqn}"
 
tests/nvme/018 +2 -1
index e90173098ec1..e631434d7bd6 100755
@@ -35,7 +35,8 @@ test() {
 	sectors="$(blockdev --getsz "/dev/${nvmedev}n1")"
 	bs="$(blockdev --getbsz "/dev/${nvmedev}n1")"
 
-	nvme read "/dev/${nvmedev}n1" -s "$sectors" -c 0 -z "$bs" &>"$FULL" \
+	nvme read "/dev/${nvmedev}n1" --start-block "$sectors" \
+		--block-count 0 --data-size "$bs" &>"$FULL" \
 		&& echo "ERROR: nvme read for out of range LBA was not rejected"
 
 	_nvme_disconnect_subsys "${def_subsysnqn}"
tests/nvme/019 +2 -1
index a1035ff8d8c7..3ab22e2cba01 100755
@@ -31,7 +31,8 @@ test() {
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
-	nvme dsm "/dev/${nvmedev}" -n 1 -d -s "${sblk_range}" -b "${nblk_range}"
+	nvme dsm "/dev/${nvmedev}" --namespace-id 1 --ad \
+		--slbs "${sblk_range}" --blocks "${nblk_range}"
 
 	_nvme_disconnect_subsys "${def_subsysnqn}"
 
tests/nvme/020 +2 -1
index ba3f4c8a5b3d..10de114b83af 100755
@@ -30,7 +30,8 @@ test() {
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
-	nvme dsm "/dev/${nvmedev}" -n 1 -d -s "${sblk_range}" -b "${nblk_range}"
+	nvme dsm "/dev/${nvmedev}" --namespace-id 1 --ad \
+		--slbs "${sblk_range}" --blocks "${nblk_range}"
 
 	_nvme_disconnect_subsys "${def_subsysnqn}"
 
tests/nvme/023 +2 -1
index 4e4d838ef6c9..58f03e8603a7 100755
@@ -29,7 +29,8 @@ test() {
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
-	if ! nvme smart-log "/dev/${nvmedev}" -n 1 >> "$FULL" 2>&1; then
+	if ! nvme smart-log "/dev/${nvmedev}" --namespace-id 1 \
+		>> "$FULL" 2>&1; then
 		echo "ERROR: smart-log bdev-ns failed"
 	fi
 
tests/nvme/024 +2 -1
index 2535a9a78d23..4608f015c4c3 100755
@@ -29,7 +29,8 @@ test() {
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
-	if ! nvme smart-log "/dev/${nvmedev}" -n 1 >> "$FULL" 2>&1; then
+	if ! nvme smart-log "/dev/${nvmedev}" --namespace-id 1 \
+		>> "$FULL" 2>&1; then
 		echo "ERROR: smart-log file-ns failed"
 	fi
 	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
tests/nvme/026 +2 -1
index 5a7d9927b44b..d5e13db0a916 100755
@@ -29,7 +29,8 @@ test() {
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
-	if ! nvme ns-descs "/dev/${nvmedev}" -n 1 >> "$FULL" 2>&1; then
+	if ! nvme ns-descs "/dev/${nvmedev}" --namespace-id 1 \
+		>> "$FULL" 2>&1; then
 		echo "ERROR: ns-desc failed"
 	fi
 
tests/nvme/045 +2 -2
index be408b629771..9e5cb54e9533 100755
@@ -68,7 +68,7 @@ test() {
 
 	echo "Renew host key on the controller"
 
-	new_hostkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)"
+	new_hostkey="$(nvme gen-dhchap-key --nqn ${def_subsysnqn} 2> /dev/null)"
 
 	_set_nvmet_hostkey "${def_hostnqn}" "${new_hostkey}"
 
@@ -78,7 +78,7 @@ test() {
 
 	echo "Renew ctrl key on the controller"
 
-	new_ctrlkey="$(nvme gen-dhchap-key -n ${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/046 +4 -3
index 7576a24f234d..ea68d4079403 100755
@@ -25,13 +25,14 @@ test_device() {
 
 	chmod g+r,o+r "$ngdev"
 
-	if ! _run_user "nvme io-passthru ${ngdev} --opcode 2 -l 4096 \
-		-n $nsid -r" >> "${FULL}" 2>&1; then
+	if ! _run_user "nvme io-passthru ${ngdev} --opcode 2 --data-len 4096 \
+		--namespace-id $nsid --read" >> "${FULL}" 2>&1; then
 		echo "Error: io-passthru read failed"
 	fi
 
 	if _run_user "echo hello | nvme io-passthru ${ngdev} --opcode 1 \
-		-l 4096 -n $nsid -r" >> "${FULL}" 2>&1; then
+		--data-len 4096 --namespace-id $nsid --read" \
+		>> "${FULL}" 2>&1; then
 		echo "Error: io-passthru write passed (unexpected)"
 	fi
 
Signature · 1 line
2.44.0
#8 lore raw

PATCH v3 8/20 nvme/rc: connect subsys only support long options

In reply to Daniel Wagner

There is no user for the short command line options, thus remove the short options to reduce the parsing overhead.

---
 tests/nvme/rc | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
tests/nvme/rc +13 -13
index 6bf2e3ae37c5..535bd869bf58 100644
@@ -428,55 +428,55 @@ _nvme_connect_subsys() {
 
 	while [[ $# -gt 0 ]]; do
 		case $1 in
-			-a|--traddr)
+			--traddr)
 				traddr="$2"
 				shift 2
 				;;
-			-w|--host-traddr)
+			--host-traddr)
 				host_traddr="$2"
 				shift 2
 				;;
-			-s|--trsvcid)
+			--trsvcid)
 				trsvcid="$2"
 				shift 2
 				;;
-			-n|--hostnqn)
+			--hostnqn)
 				hostnqn="$2"
 				shift 2
 				;;
-			-I|--hostid)
+			--hostid)
 				hostid="$2"
 				shift 2
 				;;
-			-S|--dhchap-secret)
+			--dhchap-secret)
 				hostkey="$2"
 				shift 2
 				;;
-			-C|--dhchap-ctrl-secret)
+			--dhchap-ctrl-secret)
 				ctrlkey="$2"
 				shift 2
 				;;
-			-i|--nr-io-queues)
+			--nr-io-queues)
 				nr_io_queues="$2"
 				shift 2
 				;;
-			-W|--nr-write-queues)
+			--nr-write-queues)
 				nr_write_queues="$2"
 				shift 2
 				;;
-			-P|--nr-poll-queues)
+			--nr-poll-queues)
 				nr_poll_queues="$2"
 				shift 2
 				;;
-			-k|--keep-alive-tmo)
+			--keep-alive-tmo)
 				keep_alive_tmo="$2"
 				shift 2
 				;;
-			-c|--reconnect-delay)
+			--reconnect-delay)
 				reconnect_delay="$2"
 				shift 2
 				;;
-			-l|--ctrl-loss-tmo)
+			--ctrl-loss-tmo)
 				ctrl_loss_tmo="$2"
 				shift 2
 				;;
Signature · 1 line
2.44.0
#9 lore raw

PATCH v3 9/20 nvme/rc: add nqn/uuid args to target setup/cleanup helper

In reply to Daniel Wagner

Make these helper a bit more flexible, so that the caller can setup not just the default subsysnqn.

---
 tests/nvme/rc | 38 +++++++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 7 deletions(-)
tests/nvme/rc +31 -7
index 535bd869bf58..7f436037eb94 100644
@@ -817,6 +817,8 @@ _nvmet_target_setup() {
 	local blkdev
 	local ctrlkey=""
 	local hostkey=""
+	local subsysnqn="${def_subsysnqn}"
+	local subsys_uuid="${def_subsys_uuid}"
 	local port
 
 	while [[ $# -gt 0 ]]; do
@@ -833,6 +835,14 @@ _nvmet_target_setup() {
 				hostkey="$2"
 				shift 2
 				;;
+			--subsysnqn)
+				subsysnqn="$2"
+				shift 2
+				;;
+			--subsys-uuid)
+				subsys_uuid="$2"
+				shift 2
+				;;
 			*)
 				echo "WARNING: unknown argument: $1"
 				shift
@@ -847,11 +857,11 @@ _nvmet_target_setup() {
 		blkdev="$(_nvme_def_file_path)"
 	fi
 
-	_create_nvmet_subsystem "${def_subsysnqn}" "${blkdev}" \
-				"${def_subsys_uuid}"
+	_create_nvmet_subsystem "${subsysnqn}" "${blkdev}" \
+				"${subsys_uuid}"
 	port="$(_create_nvmet_port "${nvme_trtype}")"
-	_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
-	_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" \
+	_add_nvmet_subsys_to_port "${port}" "${subsysnqn}"
+	_create_nvmet_host "${subsysnqn}" "${def_hostnqn}" \
 			"${hostkey}" "${ctrlkey}"
 }
 
@@ -859,14 +869,28 @@ _nvmet_target_cleanup() {
 	local ports
 	local port
 	local blkdev
+	local subsysnqn="${def_subsysnqn}"
+
+	while [[ $# -gt 0 ]]; do
+		case $1 in
+			--subsysnqn)
+				subsysnqn="$2"
+				shift 2
+				;;
+			*)
+				echo "WARNING: unknown argument: $1"
+				shift
+				;;
+		esac
+	done
 
-	_get_nvmet_ports "${def_subsysnqn}" ports
+	_get_nvmet_ports "${subsysnqn}" ports
 
 	for port in "${ports[@]}"; do
-		_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
+		_remove_nvmet_subsystem_from_port "${port}" "${subsysnqn}"
 		_remove_nvmet_port "${port}"
 	done
-	_remove_nvmet_subsystem "${def_subsysnqn}"
+	_remove_nvmet_subsystem "${subsysnqn}"
 	_remove_nvmet_host "${def_hostnqn}"
 
 	_cleanup_blkdev
Signature · 1 line
2.44.0
#10 lore raw

PATCH v3 10/20 nvme/rc: remove unused connect options

In reply to Daniel Wagner

These options are not used, thus remove them.

---
 tests/nvme/rc | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)
tests/nvme/rc +2 -17
index 7f436037eb94..4ad6cb640627 100644
@@ -410,9 +410,6 @@ _nvme_connect_subsys() {
 	local positional_args=()
 	local trtype=""
 	local subsysnqn=""
-	local traddr="$def_traddr"
-	local host_traddr="$def_host_traddr"
-	local trsvcid="$def_trsvcid"
 	local hostnqn="$def_hostnqn"
 	local hostid="$def_hostid"
 	local hostkey=""
@@ -428,18 +425,6 @@ _nvme_connect_subsys() {
 
 	while [[ $# -gt 0 ]]; do
 		case $1 in
-			--traddr)
-				traddr="$2"
-				shift 2
-				;;
-			--host-traddr)
-				host_traddr="$2"
-				shift 2
-				;;
-			--trsvcid)
-				trsvcid="$2"
-				shift 2
-				;;
 			--hostnqn)
 				hostnqn="$2"
 				shift 2
@@ -498,9 +483,9 @@ _nvme_connect_subsys() {
 
 	ARGS=(--transport "${trtype}" --nqn "${subsysnqn}")
 	if [[ "${trtype}" == "fc" ]] ; then
-		ARGS+=(--traddr "${traddr}" --host-traddr "${host_traddr}")
+		ARGS+=(--traddr "${def_traddr}" --host-traddr "${def_host_traddr}")
 	elif [[ "${trtype}" != "loop" ]]; then
-		ARGS+=(--traddr "${traddr}" --trsvcid "${trsvcid}")
+		ARGS+=(--traddr "${def_traddr}" --trsvcid "${def_trsvcid}")
 	fi
 	ARGS+=(--hostnqn="${hostnqn}")
 	ARGS+=(--hostid="${hostid}")
Signature · 1 line
2.44.0
#11 lore raw

PATCH v3 11/20 nvme/rc: do not cleanup external managed loop device

In reply to Daniel Wagner

If the test setups a loop device itself (not created by _nvmet_target_setup), _nvmet_target_cleanup should not cleanup the block device automatically.

Because _nvmet_target_cleanup has no way to figure this out by itself if it is managed or not, the caller needs to pass in the block device type.

---
 tests/nvme/rc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
tests/nvme/rc +8 -1
index 4ad6cb640627..9d47c737f9b0 100644
@@ -855,9 +855,14 @@ _nvmet_target_cleanup() {
 	local port
 	local blkdev
 	local subsysnqn="${def_subsysnqn}"
+	local blkdev_type=""
 
 	while [[ $# -gt 0 ]]; do
 		case $1 in
+			--blkdev)
+				blkdev_type="$2"
+				shift 2
+				;;
 			--subsysnqn)
 				subsysnqn="$2"
 				shift 2
@@ -878,7 +883,9 @@ _nvmet_target_cleanup() {
 	_remove_nvmet_subsystem "${subsysnqn}"
 	_remove_nvmet_host "${def_hostnqn}"
 
-	_cleanup_blkdev
+	if [[ "${blkdev_type}" == "device" ]]; then
+		_cleanup_blkdev
+	fi
 }
 
 _nvmet_passthru_target_setup() {
Signature · 1 line
2.44.0
#12 lore raw

PATCH v3 12/20 nvme/031: do not open code target setup/cleanup

In reply to Daniel Wagner

No need to open code the target setup and cleanup step. Just use the common helper to setup and cleanup the target.

---
 tests/nvme/031 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
tests/nvme/031 +6 -6
index ed5f19668674..204ba7d2892f 100755
@@ -40,14 +40,14 @@ test() {
 	port="$(_create_nvmet_port "${nvme_trtype}")"
 
 	for ((i = 0; i < iterations; i++)); do
-		_create_nvmet_subsystem "${subsys}$i" "${loop_dev}"
-		_add_nvmet_subsys_to_port "${port}" "${subsys}$i"
-		_create_nvmet_host "${subsys}$i" "${def_hostnqn}"
+		_nvmet_target_setup --subsysnqn "${subsys}$i" \
+			--blkdev "${loop_dev}"
+
 		_nvme_connect_subsys "${nvme_trtype}" "${subsys}$i"
 		_nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1
-		_remove_nvmet_subsystem_from_port "${port}" "${subsys}$i"
-		_remove_nvmet_subsystem "${subsys}$i"
-		_remove_nvmet_host "${def_hostnqn}"
+
+		_nvmet_target_cleanup --subsysnqn "${subsys}$i" \
+			--blkdev "${loop_dev}"
 	done
 
 	_remove_nvmet_port "${port}"
Signature · 1 line
2.44.0
#13 lore raw

PATCH v3 13/20 nvme: drop default trtype argument for _nvmet_connect_subsys

In reply to Daniel Wagner

Every invocation of _nvmet_connect_subsys passes in the default nvme_trtype argument. nvme/rc also assumes the test is always using nvme_trtype for trtype (e.g. cleanup code paths), thus just drop this argument.

---
 tests/nvme/003 |  2 +-
 tests/nvme/004 |  3 +--
 tests/nvme/005 |  2 +-
 tests/nvme/008 |  2 +-
 tests/nvme/009 |  2 +-
 tests/nvme/010 |  2 +-
 tests/nvme/011 |  2 +-
 tests/nvme/012 |  2 +-
 tests/nvme/013 |  2 +-
 tests/nvme/014 |  2 +-
 tests/nvme/015 |  2 +-
 tests/nvme/018 |  2 +-
 tests/nvme/019 |  2 +-
 tests/nvme/020 |  2 +-
 tests/nvme/021 |  2 +-
 tests/nvme/022 |  2 +-
 tests/nvme/023 |  2 +-
 tests/nvme/024 |  2 +-
 tests/nvme/025 |  2 +-
 tests/nvme/026 |  2 +-
 tests/nvme/027 |  2 +-
 tests/nvme/028 |  2 +-
 tests/nvme/029 |  2 +-
 tests/nvme/031 |  2 +-
 tests/nvme/040 |  2 +-
 tests/nvme/041 |  4 ++--
 tests/nvme/042 |  4 ++--
 tests/nvme/043 |  4 ++--
 tests/nvme/044 |  8 ++++----
 tests/nvme/045 |  2 +-
 tests/nvme/047 |  4 ++--
 tests/nvme/048 |  2 +-
 tests/nvme/rc  | 12 +++++-------
 33 files changed, 44 insertions(+), 47 deletions(-)
tests/nvme/003 +1 -1
index b5ea2720100e..9a7c41f0856b 100755
@@ -25,7 +25,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" nqn.2014-08.org.nvmexpress.discovery
+	_nvme_connect_subsys nqn.2014-08.org.nvmexpress.discovery
 
 	# This is ugly but checking for the absence of error messages is ...
 	sleep 10
tests/nvme/004 +1 -2
index cc5310e78e0b..024ac986e5c1 100755
@@ -22,10 +22,9 @@ test() {
 
 	_setup_nvmet
 
-
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	local nvmedev
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
tests/nvme/005 +1 -1
index f9956e960a56..80a5359e862e 100755
@@ -25,7 +25,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 
tests/nvme/008 +1 -1
index 6ff3362e9c9b..fb1726723d43 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/009 +1 -1
index 4ea00636e5dd..a9d83b675ba2 100755
@@ -23,7 +23,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/010 +1 -1
index 5ed6cb5c0374..496f6e5c6a52 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/011 +1 -1
index f9150e06434e..14a17a774d5f 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/012 +1 -1
index f0914ce3206b..8dbf8eb1a9f0 100755
@@ -28,7 +28,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/013 +1 -1
index 3cef009cb9f4..eb22933fdec6 100755
@@ -27,7 +27,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/014 +1 -1
index c02167142cb3..20ff69176231 100755
@@ -27,7 +27,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/015 +1 -1
index 8ea90f10bda7..634c42c07a86 100755
@@ -27,7 +27,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/018 +1 -1
index e631434d7bd6..9225f7d58377 100755
@@ -25,7 +25,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/019 +1 -1
index 3ab22e2cba01..9cf9f5299305 100755
@@ -26,7 +26,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/020 +1 -1
index 10de114b83af..f6a204e6e417 100755
@@ -25,7 +25,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/021 +1 -1
index 7dc6a41b9f7b..73e414e9db47 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/022 +1 -1
index c70fbbae822e..31435cd2e9c7 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/023 +1 -1
index 58f03e8603a7..c4c292899f32 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/024 +1 -1
index 4608f015c4c3..b0d6f5a3c0b9 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/025 +1 -1
index 46f6197cdfed..107eb38ba787 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/026 +1 -1
index d5e13db0a916..ff4ff91d5d4f 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/027 +1 -1
index 82b77a963623..a15e6d6e92d0 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/028 +1 -1
index 0b49e2016d30..41dcb6ef7a4f 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/029 +1 -1
index a4f0cb1402b1..7bde5565b020 100755
@@ -58,7 +58,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
tests/nvme/031 +1 -1
index 204ba7d2892f..19854ccb903f 100755
@@ -43,7 +43,7 @@ test() {
 		_nvmet_target_setup --subsysnqn "${subsys}$i" \
 			--blkdev "${loop_dev}"
 
-		_nvme_connect_subsys "${nvme_trtype}" "${subsys}$i"
+		_nvme_connect_subsys "${subsys}$i"
 		_nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1
 
 		_nvmet_target_cleanup --subsysnqn "${subsys}$i" \
tests/nvme/040 +1 -1
index 7759bac9b43c..06d0d0d47368 100755
@@ -26,7 +26,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}"
+	_nvme_connect_subsys "${def_subsysnqn}"
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 
 	# start fio job
tests/nvme/041 +2 -2
index c4588d7058ac..02452fd52628 100755
@@ -38,7 +38,7 @@ test() {
 
 	# Test unauthenticated connection (should fail)
 	echo "Test unauthenticated connection (should fail)"
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+	_nvme_connect_subsys "${def_subsysnqn}" \
 			     --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}"
 
@@ -46,7 +46,7 @@ test() {
 
 	# Test authenticated connection
 	echo "Test authenticated connection"
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+	_nvme_connect_subsys "${def_subsysnqn}" \
 			     --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}"
tests/nvme/042 +2 -2
index 815d65e7c610..961301ff6993 100755
@@ -41,7 +41,7 @@ test() {
 		fi
 		_set_nvmet_hostkey "${def_hostnqn}" "${hostkey}"
 
-		_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+		_nvme_connect_subsys "${def_subsysnqn}" \
 				     --hostnqn "${def_hostnqn}" \
 				     --hostid "${def_hostid}" \
 				     --dhchap-secret "${hostkey}"
@@ -58,7 +58,7 @@ test() {
 		fi
 		_set_nvmet_hostkey "${def_hostnqn}" "${hostkey}"
 
-		_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+		_nvme_connect_subsys "${def_subsysnqn}" \
 				     --hostnqn "${def_hostnqn}" \
 				     --hostid "${def_hostid}" \
 				     --dhchap-secret "${hostkey}"
tests/nvme/043 +2 -2
index e65abb09fe7c..ed18869a5977 100755
@@ -45,7 +45,7 @@ test() {
 
 		_set_nvmet_hash "${def_hostnqn}" "${hash}"
 
-		_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+		_nvme_connect_subsys "${def_subsysnqn}" \
 				     --hostnqn "${def_hostnqn}" \
 				     --hostid "${def_hostid}" \
 				     --dhchap-secret "${hostkey}"
@@ -59,7 +59,7 @@ test() {
 
 		_set_nvmet_dhgroup "${def_hostnqn}" "${dhgroup}"
 
-		_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+		_nvme_connect_subsys "${def_subsysnqn}" \
 				      --hostnqn "${def_hostnqn}" \
 				      --hostid "${def_hostid}" \
 				      --dhchap-secret "${hostkey}"
tests/nvme/044 +4 -4
index 9ee07475e738..8e2b4131b969 100755
@@ -49,7 +49,7 @@ test() {
 
 	# Step 1: Connect with host authentication only
 	echo "Test host authentication"
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+	_nvme_connect_subsys "${def_subsysnqn}" \
 			     --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}"
@@ -59,7 +59,7 @@ test() {
 	# Step 2: Connect with host authentication
 	# and invalid ctrl authentication
 	echo "Test invalid ctrl authentication (should fail)"
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+	_nvme_connect_subsys "${def_subsysnqn}" \
 			     --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}" \
@@ -70,7 +70,7 @@ test() {
 	# Step 3: Connect with host authentication
 	# and valid ctrl authentication
 	echo "Test valid ctrl authentication"
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+	_nvme_connect_subsys "${def_subsysnqn}" \
 			     --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}" \
@@ -82,7 +82,7 @@ test() {
 	# and invalid ctrl key
 	echo "Test invalid ctrl key (should fail)"
 	invkey="DHHC-1:00:Jc/My1o0qtLCWRp+sHhAVafdfaS7YQOMYhk9zSmlatobqB8C:"
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+	_nvme_connect_subsys "${def_subsysnqn}" \
 			     --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}" \
tests/nvme/045 +1 -1
index 9e5cb54e9533..f89378836e67 100755
@@ -51,7 +51,7 @@ test() {
 
 	_set_nvmet_dhgroup "${def_hostnqn}" "ffdhe2048"
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+	_nvme_connect_subsys "${def_subsysnqn}" \
 			     --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}" \
tests/nvme/047 +2 -2
index 94d7d50f9f98..162bd3bf70fa 100755
@@ -27,7 +27,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+	_nvme_connect_subsys \
 		--nr-write-queues 1 || echo FAIL
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
@@ -37,7 +37,7 @@ test() {
 
 	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
 
-	_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+	_nvme_connect_subsys "${def_subsysnqn}" \
 		--nr-write-queues 1 \
 		--nr-poll-queues 1 || echo FAIL
 
tests/nvme/048 +1 -1
index f76cfedf8b03..44fdffe287c8 100755
@@ -99,7 +99,7 @@ test() {
 	_nvmet_target_setup --blkdev file
 
 	if [[ -f "${cfs_path}/attr_qid_max" ]] ; then
-		_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
+		_nvme_connect_subsys "${def_subsysnqn}" \
 					--hostnqn "${def_hostnqn}" \
 					--hostid "${def_hostid}" \
 					--keep-alive-tmo 1 \
tests/nvme/rc +5 -7
index 9d47c737f9b0..9ce2fd787f8d 100644
@@ -408,7 +408,6 @@ _nvme_disconnect_subsys() {
 
 _nvme_connect_subsys() {
 	local positional_args=()
-	local trtype=""
 	local subsysnqn=""
 	local hostnqn="$def_hostnqn"
 	local hostid="$def_hostid"
@@ -478,13 +477,12 @@ _nvme_connect_subsys() {
 
 	set -- "${positional_args[@]}"
 
-	trtype="$1"
-	subsysnqn="$2"
+	subsysnqn="$1"
 
-	ARGS=(--transport "${trtype}" --nqn "${subsysnqn}")
-	if [[ "${trtype}" == "fc" ]] ; then
+	ARGS=(--transport "${nvme_trtype}" --nqn "${subsysnqn}")
+	if [[ "${nvme_trtype}" == "fc" ]] ; then
 		ARGS+=(--traddr "${def_traddr}" --host-traddr "${def_host_traddr}")
-	elif [[ "${trtype}" != "loop" ]]; then
+	elif [[ "${nvme_trtype}" != "loop" ]]; then
 		ARGS+=(--traddr "${def_traddr}" --trsvcid "${def_trsvcid}")
 	fi
 	ARGS+=(--hostnqn="${hostnqn}")
@@ -902,7 +900,7 @@ _nvmet_passthru_target_connect() {
 	local trtype=$1
 	local subsys_name=$2
 
-	_nvme_connect_subsys "${trtype}" "${subsys_name}" --no-wait || return
+	_nvme_connect_subsys "${subsys_name}" --no-wait || return
 	nsdev=$(_find_nvme_passthru_loop_dev "${subsys_name}")
 
 	# The following tests can race with the creation
Signature · 1 line
2.44.0
#14 lore raw

PATCH v3 14/20 nvme: drop default trtype argument for _nvmet_passthru_target_connect

In reply to Daniel Wagner

Every invocation of _nvmet_passthru_target_connect passes in the default nvme_trtype argument. The argument is not evaluated anymore, thus just remove it.

---
 tests/nvme/033 | 2 +-
 tests/nvme/034 | 2 +-
 tests/nvme/035 | 2 +-
 tests/nvme/036 | 2 +-
 tests/nvme/037 | 3 +--
 tests/nvme/rc  | 3 +--
 6 files changed, 6 insertions(+), 8 deletions(-)
tests/nvme/033 +1 -1
index 6cc4f57e6d60..cb120e20b573 100755
@@ -53,7 +53,7 @@ test_device() {
 
 	_nvmet_passthru_target_setup "${def_subsysnqn}"
 
-	nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" "${def_subsysnqn}")
+	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
 
 	compare_dev_info "${nsdev}"
 
tests/nvme/034 +1 -1
index 3bd1c3ad2f61..98a7db859b36 100755
@@ -23,7 +23,7 @@ test_device() {
 	local nsdev
 
 	_nvmet_passthru_target_setup "${def_subsysnqn}"
-	nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" "${def_subsysnqn}")
+	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
 
 	_run_fio_verify_io --size="${nvme_img_size}" --filename="${nsdev}"
 
tests/nvme/035 +1 -1
index 01aa09077d6a..c17e8be6ce46 100755
@@ -29,7 +29,7 @@ test_device() {
 	local nsdev
 
 	_nvmet_passthru_target_setup "${def_subsysnqn}"
-	nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" "${def_subsysnqn}")
+	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
 
 	if ! _xfs_run_fio_verify_io "${nsdev}" "${nvme_img_size}"; then
 		echo "FAIL: fio verify failed"
tests/nvme/036 +1 -1
index 89ccd256a67c..a1ae74fa95ea 100755
@@ -21,7 +21,7 @@ test_device() {
 	local ctrldev
 
 	_nvmet_passthru_target_setup "${def_subsysnqn}"
-	nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" "${def_subsysnqn}")
+	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
 
 	ctrldev=$(_find_nvme_dev "${def_subsysnqn}")
 
tests/nvme/037 +1 -2
index a2815b3ff2d7..eb47839a4289 100755
@@ -23,8 +23,7 @@ test_device() {
 
 	for ((i = 0; i < iterations; i++)); do
 		_nvmet_passthru_target_setup "${subsys}${i}"
-		nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" \
-				"${subsys}${i}")
+		nsdev=$(_nvmet_passthru_target_connect "${subsys}${i}")
 
 		_nvme_disconnect_subsys "${subsys}${i}" >>"${FULL}" 2>&1
 		_nvmet_passthru_target_cleanup "${subsys}${i}"
tests/nvme/rc +1 -2
index 9ce2fd787f8d..1dd1072f9ffb 100644
@@ -897,8 +897,7 @@ _nvmet_passthru_target_setup() {
 }
 
 _nvmet_passthru_target_connect() {
-	local trtype=$1
-	local subsys_name=$2
+	local subsys_name=$1
 
 	_nvme_connect_subsys "${subsys_name}" --no-wait || return
 	nsdev=$(_find_nvme_passthru_loop_dev "${subsys_name}")
Signature · 1 line
2.44.0
#15 lore raw

PATCH v3 15/20 nvme: drop default subsysnqn argument from _nvme_{connect|disconnect}_subsys

In reply to Daniel Wagner

Remove the last positional argument for _nvme_{connect|disconnect}_subsys which most test pass in the default subsysnqn anyway. There is little point in cluttering all the test textual noise.

---
 tests/nvme/003 |  4 ++--
 tests/nvme/004 |  4 ++--
 tests/nvme/005 |  2 +-
 tests/nvme/008 |  4 ++--
 tests/nvme/009 |  4 ++--
 tests/nvme/010 |  4 ++--
 tests/nvme/011 |  4 ++--
 tests/nvme/012 |  4 ++--
 tests/nvme/013 |  4 ++--
 tests/nvme/014 |  4 ++--
 tests/nvme/015 |  4 ++--
 tests/nvme/018 |  4 ++--
 tests/nvme/019 |  4 ++--
 tests/nvme/020 |  4 ++--
 tests/nvme/021 |  4 ++--
 tests/nvme/022 |  4 ++--
 tests/nvme/023 |  4 ++--
 tests/nvme/024 |  4 ++--
 tests/nvme/025 |  4 ++--
 tests/nvme/026 |  4 ++--
 tests/nvme/027 |  4 ++--
 tests/nvme/028 |  4 ++--
 tests/nvme/029 |  4 ++--
 tests/nvme/031 |  4 ++--
 tests/nvme/033 |  2 +-
 tests/nvme/034 |  2 +-
 tests/nvme/035 |  2 +-
 tests/nvme/036 |  2 +-
 tests/nvme/037 |  3 ++-
 tests/nvme/040 |  2 +-
 tests/nvme/041 | 10 ++++------
 tests/nvme/042 | 10 ++++------
 tests/nvme/043 | 10 ++++------
 tests/nvme/044 | 20 ++++++++------------
 tests/nvme/045 |  6 ++----
 tests/nvme/047 |  6 +++---
 tests/nvme/048 | 11 +++++------
 tests/nvme/rc  | 30 +++++++++++++++++++++---------
 38 files changed, 105 insertions(+), 105 deletions(-)
tests/nvme/003 +2 -2
index 9a7c41f0856b..be6b4e18ec30 100755
@@ -25,7 +25,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys nqn.2014-08.org.nvmexpress.discovery
+	_nvme_connect_subsys --subsysnqn "nqn.2014-08.org.nvmexpress.discovery"
 
 	# This is ugly but checking for the absence of error messages is ...
 	sleep 10
@@ -38,7 +38,7 @@ test() {
 		echo "Fail"
 	fi
 
-	_nvme_disconnect_subsys nqn.2014-08.org.nvmexpress.discovery
+	_nvme_disconnect_subsys --subsysnqn "nqn.2014-08.org.nvmexpress.discovery"
 
 	_nvmet_target_cleanup
 
tests/nvme/004 +2 -2
index 024ac986e5c1..b751746c6c91 100755
@@ -24,13 +24,13 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	local nvmedev
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
-	_nvme_disconnect_subsys ${def_subsysnqn}
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/005 +1 -1
index 80a5359e862e..f17174d40dfc 100755
@@ -25,7 +25,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 
tests/nvme/008 +2 -2
index fb1726723d43..a5d06818c6e4 100755
@@ -24,12 +24,12 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/009 +2 -2
index a9d83b675ba2..a1655d43e56f 100755
@@ -23,12 +23,12 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/010 +2 -2
index 496f6e5c6a52..7d875989a01c 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -32,7 +32,7 @@ test() {
 	_run_fio_verify_io --size="${nvme_img_size}" \
 		--filename="/dev/${nvmedev}n1"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/011 +2 -2
index 14a17a774d5f..0acc8b1dbaed 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -32,7 +32,7 @@ test() {
 	_run_fio_verify_io --size="${nvme_img_size}" \
 		--filename="/dev/${nvmedev}n1"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/012 +2 -2
index 8dbf8eb1a9f0..a0bff298ab29 100755
@@ -28,7 +28,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -37,7 +37,7 @@ test() {
 		echo "FAIL: fio verify failed"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/013 +2 -2
index eb22933fdec6..5e5026eabe17 100755
@@ -27,7 +27,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -36,7 +36,7 @@ test() {
 		echo "FAIL: fio verify failed"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/014 +2 -2
index 20ff69176231..da4b4c13b347 100755
@@ -27,7 +27,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -41,7 +41,7 @@ test() {
 
 	nvme flush "/dev/${nvmedev}" --namespace-id 1
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/015 +2 -2
index 634c42c07a86..b82f2253c011 100755
@@ -27,7 +27,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -41,7 +41,7 @@ test() {
 
 	nvme flush "/dev/${nvmedev}n1" --namespace-id 1
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/018 +2 -2
index 9225f7d58377..bd6e5e930e35 100755
@@ -25,7 +25,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -39,7 +39,7 @@ test() {
 		--block-count 0 --data-size "$bs" &>"$FULL" \
 		&& echo "ERROR: nvme read for out of range LBA was not rejected"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/019 +2 -2
index 9cf9f5299305..4d7de8191da7 100755
@@ -26,7 +26,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -34,7 +34,7 @@ test() {
 	nvme dsm "/dev/${nvmedev}" --namespace-id 1 --ad \
 		--slbs "${sblk_range}" --blocks "${nblk_range}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/020 +2 -2
index f6a204e6e417..c734210c5bd9 100755
@@ -25,7 +25,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -33,7 +33,7 @@ test() {
 	nvme dsm "/dev/${nvmedev}" --namespace-id 1 --ad \
 		--slbs "${sblk_range}" --blocks "${nblk_range}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/021 +2 -2
index 73e414e9db47..358e209d0458 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -33,7 +33,7 @@ test() {
 		echo "ERROR: device not listed"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
 
tests/nvme/022 +2 -2
index 31435cd2e9c7..7ce33ddbf006 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -33,7 +33,7 @@ test() {
 		echo "ERROR: reset failed"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
 
tests/nvme/023 +2 -2
index c4c292899f32..abbb35a0b580 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -34,7 +34,7 @@ test() {
 		echo "ERROR: smart-log bdev-ns failed"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
 
tests/nvme/024 +2 -2
index b0d6f5a3c0b9..3ee18822e26b 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -33,7 +33,7 @@ test() {
 		>> "$FULL" 2>&1; then
 		echo "ERROR: smart-log file-ns failed"
 	fi
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
 
tests/nvme/025 +2 -2
index 107eb38ba787..3cd62d0b4e5e 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -33,7 +33,7 @@ test() {
 		echo "ERROR: effects-log failed"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
 
tests/nvme/026 +2 -2
index ff4ff91d5d4f..5d54b0ff3d28 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -34,7 +34,7 @@ test() {
 		echo "ERROR: ns-desc failed"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
 
tests/nvme/027 +2 -2
index a15e6d6e92d0..053fd58f9369 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -33,7 +33,7 @@ test() {
 		echo "ERROR: ns-rescan failed"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
 
tests/nvme/028 +2 -2
index 41dcb6ef7a4f..4710bba1f416 100755
@@ -24,7 +24,7 @@ test() {
 
 	_nvmet_target_setup --blkdev file
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -33,7 +33,7 @@ test() {
 		echo "ERROR: list-subsys"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
 
tests/nvme/029 +2 -2
index 7bde5565b020..8dbe49ba15cc 100755
@@ -58,7 +58,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 	_check_uuid "${nvmedev}"
@@ -84,7 +84,7 @@ test() {
 		echo 0 > /proc/sys/vm/nr_hugepages
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
 
tests/nvme/031 +2 -2
index 19854ccb903f..0bf823dbbb0d 100755
@@ -43,8 +43,8 @@ test() {
 		_nvmet_target_setup --subsysnqn "${subsys}$i" \
 			--blkdev "${loop_dev}"
 
-		_nvme_connect_subsys "${subsys}$i"
-		_nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1
+		_nvme_connect_subsys --subsysnqn "${subsys}$i"
+		_nvme_disconnect_subsys --subsysnqn "${subsys}$i" >> "${FULL}" 2>&1
 
 		_nvmet_target_cleanup --subsysnqn "${subsys}$i" \
 			--blkdev "${loop_dev}"
tests/nvme/033 +1 -1
index cb120e20b573..c0482c808d43 100755
@@ -57,7 +57,7 @@ test_device() {
 
 	compare_dev_info "${nsdev}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 	_nvmet_passthru_target_cleanup "${def_subsysnqn}"
 
 	echo "Test complete"
tests/nvme/034 +1 -1
index 98a7db859b36..8bb2d8cd8d62 100755
@@ -27,7 +27,7 @@ test_device() {
 
 	_run_fio_verify_io --size="${nvme_img_size}" --filename="${nsdev}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 	_nvmet_passthru_target_cleanup "${def_subsysnqn}"
 
 	echo "Test complete"
tests/nvme/035 +1 -1
index c17e8be6ce46..1d1b5e4ac46e 100755
@@ -35,7 +35,7 @@ test_device() {
 		echo "FAIL: fio verify failed"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 	_nvmet_passthru_target_cleanup "${def_subsysnqn}"
 
 	echo "Test complete"
tests/nvme/036 +1 -1
index a1ae74fa95ea..0e9c3bf3486c 100755
@@ -29,7 +29,7 @@ test_device() {
 		echo "ERROR: reset failed"
 	fi
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 	_nvmet_passthru_target_cleanup "${def_subsysnqn}"
 
 	echo "Test complete"
tests/nvme/037 +2 -1
index eb47839a4289..159d9d990bb7 100755
@@ -25,7 +25,8 @@ test_device() {
 		_nvmet_passthru_target_setup "${subsys}${i}"
 		nsdev=$(_nvmet_passthru_target_connect "${subsys}${i}")
 
-		_nvme_disconnect_subsys "${subsys}${i}" >>"${FULL}" 2>&1
+		_nvme_disconnect_subsys \
+			--subsysnqn "${subsys}${i}" >>"${FULL}" 2>&1
 		_nvmet_passthru_target_cleanup "${subsys}${i}"
 	done
 
tests/nvme/040 +1 -1
index 06d0d0d47368..f00fc16b643f 100755
@@ -26,7 +26,7 @@ test() {
 
 	_nvmet_target_setup
 
-	_nvme_connect_subsys "${def_subsysnqn}"
+	_nvme_connect_subsys
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
 
 	# start fio job
tests/nvme/041 +4 -6
index 02452fd52628..d6845628726e 100755
@@ -38,20 +38,18 @@ test() {
 
 	# Test unauthenticated connection (should fail)
 	echo "Test unauthenticated connection (should fail)"
-	_nvme_connect_subsys "${def_subsysnqn}" \
-			     --hostnqn "${def_hostnqn}" \
+	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	# Test authenticated connection
 	echo "Test authenticated connection"
-	_nvme_connect_subsys "${def_subsysnqn}" \
-			     --hostnqn "${def_hostnqn}" \
+	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/042 +4 -6
index 961301ff6993..480e1cba9d19 100755
@@ -41,12 +41,11 @@ test() {
 		fi
 		_set_nvmet_hostkey "${def_hostnqn}" "${hostkey}"
 
-		_nvme_connect_subsys "${def_subsysnqn}" \
-				     --hostnqn "${def_hostnqn}" \
+		_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
 				     --hostid "${def_hostid}" \
 				     --dhchap-secret "${hostkey}"
 
-		_nvme_disconnect_subsys "${def_subsysnqn}"
+		_nvme_disconnect_subsys
 	done
 
 	for key_len in 32 48 64; do
@@ -58,12 +57,11 @@ test() {
 		fi
 		_set_nvmet_hostkey "${def_hostnqn}" "${hostkey}"
 
-		_nvme_connect_subsys "${def_subsysnqn}" \
-				     --hostnqn "${def_hostnqn}" \
+		_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
 				     --hostid "${def_hostid}" \
 				     --dhchap-secret "${hostkey}"
 
-		_nvme_disconnect_subsys "${def_subsysnqn}"
+		_nvme_disconnect_subsys
 	done
 
 	_nvmet_target_cleanup
tests/nvme/043 +4 -6
index ed18869a5977..dd48035dd967 100755
@@ -45,12 +45,11 @@ test() {
 
 		_set_nvmet_hash "${def_hostnqn}" "${hash}"
 
-		_nvme_connect_subsys "${def_subsysnqn}" \
-				     --hostnqn "${def_hostnqn}" \
+		_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
 				     --hostid "${def_hostid}" \
 				     --dhchap-secret "${hostkey}"
 
-		_nvme_disconnect_subsys "${def_subsysnqn}"
+		_nvme_disconnect_subsys
 	done
 
 	for dhgroup in "ffdhe2048" "ffdhe3072" "ffdhe4096" "ffdhe6144" "ffdhe8192" ; do
@@ -59,12 +58,11 @@ test() {
 
 		_set_nvmet_dhgroup "${def_hostnqn}" "${dhgroup}"
 
-		_nvme_connect_subsys "${def_subsysnqn}" \
-				      --hostnqn "${def_hostnqn}" \
+		_nvme_connect_subsys  --hostnqn "${def_hostnqn}" \
 				      --hostid "${def_hostid}" \
 				      --dhchap-secret "${hostkey}"
 
-		_nvme_disconnect_subsys "${def_subsysnqn}"
+		_nvme_disconnect_subsys
 	done
 
 	_nvmet_target_cleanup
tests/nvme/044 +8 -12
index 8e2b4131b969..624b832c0cc6 100755
@@ -49,46 +49,42 @@ test() {
 
 	# Step 1: Connect with host authentication only
 	echo "Test host authentication"
-	_nvme_connect_subsys "${def_subsysnqn}" \
-			     --hostnqn "${def_hostnqn}" \
+	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	# Step 2: Connect with host authentication
 	# and invalid ctrl authentication
 	echo "Test invalid ctrl authentication (should fail)"
-	_nvme_connect_subsys "${def_subsysnqn}" \
-			     --hostnqn "${def_hostnqn}" \
+	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}" \
 			     --dhchap-ctrl-secret "${hostkey}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	# Step 3: Connect with host authentication
 	# and valid ctrl authentication
 	echo "Test valid ctrl authentication"
-	_nvme_connect_subsys "${def_subsysnqn}" \
-			     --hostnqn "${def_hostnqn}" \
+	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}" \
 			     --dhchap-ctrl-secret "${ctrlkey}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	# Step 4: Connect with host authentication
 	# and invalid ctrl key
 	echo "Test invalid ctrl key (should fail)"
 	invkey="DHHC-1:00:Jc/My1o0qtLCWRp+sHhAVafdfaS7YQOMYhk9zSmlatobqB8C:"
-	_nvme_connect_subsys "${def_subsysnqn}" \
-			     --hostnqn "${def_hostnqn}" \
+	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}" \
 			     --dhchap-ctrl-secret "${invkey}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
+	_nvme_disconnect_subsys
 
 	_nvmet_target_cleanup
 
tests/nvme/045 +2 -4
index f89378836e67..3a5df7c0946c 100755
@@ -51,8 +51,7 @@ test() {
 
 	_set_nvmet_dhgroup "${def_hostnqn}" "ffdhe2048"
 
-	_nvme_connect_subsys "${def_subsysnqn}" \
-			     --hostnqn "${def_hostnqn}" \
+	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
 			     --hostid "${def_hostid}" \
 			     --dhchap-secret "${hostkey}" \
 			     --dhchap-ctrl-secret "${ctrlkey}"
@@ -108,8 +107,7 @@ test() {
 	rand_io_size="$(_nvme_calc_rand_io_size 4m)"
 	_run_fio_rand_io --size="${rand_io_size}" --filename="/dev/${nvmedev}n1"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}"
-
+	_nvme_disconnect_subsys
 	_nvmet_target_cleanup
 
 	echo "Test complete"
tests/nvme/047 +3 -3
index 162bd3bf70fa..75aad7d06a36 100755
@@ -35,15 +35,15 @@ test() {
 	rand_io_size="$(_nvme_calc_rand_io_size 4M)"
 	_run_fio_rand_io --filename="/dev/${nvmedev}n1" --size="${rand_io_size}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
-	_nvme_connect_subsys "${def_subsysnqn}" \
+	_nvme_connect_subsys \
 		--nr-write-queues 1 \
 		--nr-poll-queues 1 || echo FAIL
 
 	_run_fio_rand_io --filename="/dev/${nvmedev}n1" --size="${rand_io_size}"
 
-	_nvme_disconnect_subsys "${def_subsysnqn}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
 
tests/nvme/048 +5 -6
index 44fdffe287c8..79620e0d0879 100755
@@ -99,11 +99,10 @@ test() {
 	_nvmet_target_setup --blkdev file
 
 	if [[ -f "${cfs_path}/attr_qid_max" ]] ; then
-		_nvme_connect_subsys "${def_subsysnqn}" \
-					--hostnqn "${def_hostnqn}" \
-					--hostid "${def_hostid}" \
-					--keep-alive-tmo 1 \
-					--reconnect-delay 2
+		_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
+				     --hostid "${def_hostid}" \
+				     --keep-alive-tmo 1 \
+				     --reconnect-delay 2
 
 		if ! nvmf_wait_for_state "${def_subsysnqn}" "live" ; then
 			echo FAIL
@@ -112,7 +111,7 @@ test() {
 			set_qid_max "${def_subsysnqn}" 2 || echo FAIL
 		fi
 
-		_nvme_disconnect_subsys "${def_subsysnqn}"
+		_nvme_disconnect_subsys
 	else
 		SKIP_REASONS+=("missing attr_qid_max feature")
 		skipped=true
tests/nvme/rc +21 -9
index 1dd1072f9ffb..6493aa30adef 100644
@@ -400,15 +400,27 @@ _nvme_disconnect_ctrl() {
 }
 
 _nvme_disconnect_subsys() {
-	local subsysnqn="$1"
+	local subsysnqn="$def_subsysnqn"
+
+	while [[ $# -gt 0 ]]; do
+		case $1 in
+			--subsysnqn)
+				subsysnqn="$2"
+				shift 2
+				;;
+			*)
+				echo "WARNING: unknown argument: $1"
+				shift
+				;;
+		esac
+	done
 
 	nvme disconnect --nqn "${subsysnqn}" |& tee -a "$FULL" |
 		grep -o "disconnected.*"
 }
 
 _nvme_connect_subsys() {
-	local positional_args=()
-	local subsysnqn=""
+	local subsysnqn="$def_subsysnqn"
 	local hostnqn="$def_hostnqn"
 	local hostid="$def_hostid"
 	local hostkey=""
@@ -424,6 +436,10 @@ _nvme_connect_subsys() {
 
 	while [[ $# -gt 0 ]]; do
 		case $1 in
+			--subsysnqn)
+				subsysnqn="$2"
+				shift 2
+				;;
 			--hostnqn)
 				hostnqn="$2"
 				shift 2
@@ -469,16 +485,12 @@ _nvme_connect_subsys() {
 				shift 1
 				;;
 			*)
-				positional_args+=("$1")
+				echo "WARNING: unknown argument: $1"
 				shift
 				;;
 		esac
 	done
 
-	set -- "${positional_args[@]}"
-
-	subsysnqn="$1"
-
 	ARGS=(--transport "${nvme_trtype}" --nqn "${subsysnqn}")
 	if [[ "${nvme_trtype}" == "fc" ]] ; then
 		ARGS+=(--traddr "${def_traddr}" --host-traddr "${def_host_traddr}")
@@ -899,7 +911,7 @@ _nvmet_passthru_target_setup() {
 _nvmet_passthru_target_connect() {
 	local subsys_name=$1
 
-	_nvme_connect_subsys "${subsys_name}" --no-wait || return
+	_nvme_connect_subsys --subsysnqn "${subsys_name}" --no-wait || return
 	nsdev=$(_find_nvme_passthru_loop_dev "${subsys_name}")
 
 	# The following tests can race with the creation
Signature · 1 line
2.44.0
#16 lore raw

PATCH v3 16/20 nvme: drop default subsysnqn argument from _nvme_passthru_target_{setup|cleanup}

In reply to Daniel Wagner

Remove the last positional argument for _nvme_passthrue_target_{setup|cleanup} which most test pass in the default subsysnqn anyway. There is little point in cluttering all the test textual noise.

While at it, also use subsysnqn as variable name everywhere, instead of subsys_name.

---
 tests/nvme/033 |  4 ++--
 tests/nvme/034 |  4 ++--
 tests/nvme/035 |  4 ++--
 tests/nvme/036 |  4 ++--
 tests/nvme/037 |  5 +++--
 tests/nvme/rc  | 42 ++++++++++++++++++++++++++++++++++--------
 6 files changed, 45 insertions(+), 18 deletions(-)
tests/nvme/033 +2 -2
index c0482c808d43..f7d9f04450a8 100755
@@ -51,14 +51,14 @@ test_device() {
 
 	local nsdev
 
-	_nvmet_passthru_target_setup "${def_subsysnqn}"
+	_nvmet_passthru_target_setup
 
 	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
 
 	compare_dev_info "${nsdev}"
 
 	_nvme_disconnect_subsys
-	_nvmet_passthru_target_cleanup "${def_subsysnqn}"
+	_nvmet_passthru_target_cleanup
 
 	echo "Test complete"
 }
tests/nvme/034 +2 -2
index 8bb2d8cd8d62..e5518d497377 100755
@@ -22,13 +22,13 @@ test_device() {
 	local ctrldev
 	local nsdev
 
-	_nvmet_passthru_target_setup "${def_subsysnqn}"
+	_nvmet_passthru_target_setup
 	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
 
 	_run_fio_verify_io --size="${nvme_img_size}" --filename="${nsdev}"
 
 	_nvme_disconnect_subsys
-	_nvmet_passthru_target_cleanup "${def_subsysnqn}"
+	_nvmet_passthru_target_cleanup
 
 	echo "Test complete"
 }
tests/nvme/035 +2 -2
index 1d1b5e4ac46e..8a66c2c15218 100755
@@ -28,7 +28,7 @@ test_device() {
 	local ctrldev
 	local nsdev
 
-	_nvmet_passthru_target_setup "${def_subsysnqn}"
+	_nvmet_passthru_target_setup
 	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
 
 	if ! _xfs_run_fio_verify_io "${nsdev}" "${nvme_img_size}"; then
@@ -36,7 +36,7 @@ test_device() {
 	fi
 
 	_nvme_disconnect_subsys
-	_nvmet_passthru_target_cleanup "${def_subsysnqn}"
+	_nvmet_passthru_target_cleanup
 
 	echo "Test complete"
 }
tests/nvme/036 +2 -2
index 0e9c3bf3486c..20cd3af7081a 100755
@@ -20,7 +20,7 @@ test_device() {
 
 	local ctrldev
 
-	_nvmet_passthru_target_setup "${def_subsysnqn}"
+	_nvmet_passthru_target_setup
 	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
 
 	ctrldev=$(_find_nvme_dev "${def_subsysnqn}")
@@ -30,7 +30,7 @@ test_device() {
 	fi
 
 	_nvme_disconnect_subsys
-	_nvmet_passthru_target_cleanup "${def_subsysnqn}"
+	_nvmet_passthru_target_cleanup
 
 	echo "Test complete"
 }
tests/nvme/037 +3 -2
index 159d9d990bb7..2fe37a7a7340 100755
@@ -22,12 +22,13 @@ test_device() {
 	local ctrldev
 
 	for ((i = 0; i < iterations; i++)); do
-		_nvmet_passthru_target_setup "${subsys}${i}"
+		_nvmet_passthru_target_setup --subsysnqn "${subsys}${i}"
 		nsdev=$(_nvmet_passthru_target_connect "${subsys}${i}")
 
 		_nvme_disconnect_subsys \
 			--subsysnqn "${subsys}${i}" >>"${FULL}" 2>&1
-		_nvmet_passthru_target_cleanup "${subsys}${i}"
+		_nvme_disconnect_subsys "${subsys}${i}" >>"${FULL}" 2>&1
+		_nvmet_passthru_target_cleanup --subsysnqn "${subsys}${i}"
 	done
 
 	echo "Test complete"
tests/nvme/rc +34 -8

65 lines not on this page · raw message

Signature · 1 line
2.44.0
#17 lore raw

Re: [PATCH blktests v3 16/20] nvme: drop default subsysnqn argument from _nvme_passthru_target_{setup|cleanup}

Quoted 7 lines · Daniel Wagner

Remove the last positional argument for _nvme_passthrue_target_{setup|cleanup} which most test pass in the default subsysnqn anyway. There is little point in cluttering all the test textual noise.

While at it, also use subsysnqn as variable name everywhere, instead of subsys_name.

...

Quoted 6 lines
tests/nvme/037 +0 -0
index 159d9d990bb7..2fe37a7a7340 100755
@@ -22,12 +22,13 @@ test_device() {
 	local ctrldev

tests/nvme/037 test_device() { · line 30

Quoted 10 lines
tests/nvme/037 +2 -2
 
 	for ((i = 0; i < iterations; i++)); do
-		_nvmet_passthru_target_setup "${subsys}${i}"
+		_nvmet_passthru_target_setup --subsysnqn "${subsys}${i}"
 		nsdev=$(_nvmet_passthru_target_connect "${subsys}${i}")
 
 		_nvme_disconnect_subsys \
 			--subsysnqn "${subsys}${i}" >>"${FULL}" 2>&1
-		_nvmet_passthru_target_cleanup "${subsys}${i}"
+		_nvme_disconnect_subsys "${subsys}${i}" >>"${FULL}" 2>&1

I believe that the line above is unnecessary. I took the liberty to remove it when I applied this patch.

#18 lore raw

PATCH v3 17/20 nvme: drop default subsysnqn argument from _nvmet_passthru_target_connect

In reply to Daniel Wagner

Remove the last positional argument for _nvmet_passthru_target_connect which most test pass in the default subsysnqn anyway. There is little point in cluttering all the test textual noise.

While at it, also use subsysnqn as variable name everywhere, instead of subsys_name.

---
 tests/nvme/033 |  2 +-
 tests/nvme/034 |  2 +-
 tests/nvme/035 |  2 +-
 tests/nvme/036 |  2 +-
 tests/nvme/037 |  3 ++-
 tests/nvme/rc  | 19 ++++++++++++++++---
 6 files changed, 22 insertions(+), 8 deletions(-)
tests/nvme/033 +1 -1
index f7d9f04450a8..70a73b8c7b6a 100755
@@ -53,7 +53,7 @@ test_device() {
 
 	_nvmet_passthru_target_setup
 
-	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
+	nsdev=$(_nvmet_passthru_target_connect)
 
 	compare_dev_info "${nsdev}"
 
tests/nvme/034 +1 -1
index e5518d497377..409324aafb39 100755
@@ -23,7 +23,7 @@ test_device() {
 	local nsdev
 
 	_nvmet_passthru_target_setup
-	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
+	nsdev=$(_nvmet_passthru_target_connect)
 
 	_run_fio_verify_io --size="${nvme_img_size}" --filename="${nsdev}"
 
tests/nvme/035 +1 -1
index 8a66c2c15218..ecf6b7285ee5 100755
@@ -29,7 +29,7 @@ test_device() {
 	local nsdev
 
 	_nvmet_passthru_target_setup
-	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
+	nsdev=$(_nvmet_passthru_target_connect)
 
 	if ! _xfs_run_fio_verify_io "${nsdev}" "${nvme_img_size}"; then
 		echo "FAIL: fio verify failed"
tests/nvme/036 +1 -1
index 20cd3af7081a..36ea792e3d40 100755
@@ -21,7 +21,7 @@ test_device() {
 	local ctrldev
 
 	_nvmet_passthru_target_setup
-	nsdev=$(_nvmet_passthru_target_connect "${def_subsysnqn}")
+	nsdev=$(_nvmet_passthru_target_connect)
 
 	ctrldev=$(_find_nvme_dev "${def_subsysnqn}")
 
tests/nvme/037 +2 -1
index 2fe37a7a7340..3e733d201d6a 100755
@@ -23,7 +23,8 @@ test_device() {
 
 	for ((i = 0; i < iterations; i++)); do
 		_nvmet_passthru_target_setup --subsysnqn "${subsys}${i}"
-		nsdev=$(_nvmet_passthru_target_connect "${subsys}${i}")
+		nsdev=$(_nvmet_passthru_target_connect \
+				--subsysnqn "${subsys}${i}")
 
 		_nvme_disconnect_subsys \
 			--subsysnqn "${subsys}${i}" >>"${FULL}" 2>&1
tests/nvme/rc +16 -3
index fca7408062ee..fb7a5fa864e8 100644
@@ -922,10 +922,23 @@ _nvmet_passthru_target_setup() {
 }
 
 _nvmet_passthru_target_connect() {
-	local subsys_name=$1
+	local subsysnqn="$def_subsysnqn"
+
+	while [[ $# -gt 0 ]]; do
+		case $1 in
+			--subsysnqn)
+				subsysnqn="$2"
+				shift 2
+				;;
+			*)
+				echo "WARNING: unknown argument: $1"
+				shift
+				;;
+		esac
+	done
 
-	_nvme_connect_subsys --subsysnqn "${subsys_name}" --no-wait || return
-	nsdev=$(_find_nvme_passthru_loop_dev "${subsys_name}")
+	_nvme_connect_subsys --subsysnqn "${subsysnqn}" --no-wait || return
+	nsdev=$(_find_nvme_passthru_loop_dev "${subsysnqn}")
 
 	# The following tests can race with the creation
 	# of the device so ensure the block device exists
Signature · 1 line
2.44.0
#19 lore raw

PATCH v3 18/20 nvme/{041,042,043,044,045,048}: do not pass default host{nqn|id} to _nvme_connect_subsys

In reply to Daniel Wagner

There is no point in passing the default values to _nvme_connect_subsys, thus drop these arguments.

---
 tests/nvme/041 |  7 ++-----
 tests/nvme/042 |  8 ++------
 tests/nvme/043 |  8 ++------
 tests/nvme/044 | 16 ++++------------
 tests/nvme/045 |  4 +---
 tests/nvme/048 |  4 +---
 6 files changed, 12 insertions(+), 35 deletions(-)
tests/nvme/041 +2 -5
index d6845628726e..f1fa00c0f420 100755
@@ -38,16 +38,13 @@ test() {
 
 	# Test unauthenticated connection (should fail)
 	echo "Test unauthenticated connection (should fail)"
-	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-			     --hostid "${def_hostid}"
+	_nvme_connect_subsys
 
 	_nvme_disconnect_subsys
 
 	# Test authenticated connection
 	echo "Test authenticated connection"
-	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-			     --hostid "${def_hostid}" \
-			     --dhchap-secret "${hostkey}"
+	_nvme_connect_subsys --dhchap-secret "${hostkey}"
 
 	_nvme_disconnect_subsys
 
tests/nvme/042 +2 -6
index 480e1cba9d19..a9e79c6a13b4 100755
@@ -41,9 +41,7 @@ test() {
 		fi
 		_set_nvmet_hostkey "${def_hostnqn}" "${hostkey}"
 
-		_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-				     --hostid "${def_hostid}" \
-				     --dhchap-secret "${hostkey}"
+		_nvme_connect_subsys --dhchap-secret "${hostkey}"
 
 		_nvme_disconnect_subsys
 	done
@@ -57,9 +55,7 @@ test() {
 		fi
 		_set_nvmet_hostkey "${def_hostnqn}" "${hostkey}"
 
-		_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-				     --hostid "${def_hostid}" \
-				     --dhchap-secret "${hostkey}"
+		_nvme_connect_subsys --dhchap-secret "${hostkey}"
 
 		_nvme_disconnect_subsys
 	done
tests/nvme/043 +2 -6
index dd48035dd967..4589423d4335 100755
@@ -45,9 +45,7 @@ test() {
 
 		_set_nvmet_hash "${def_hostnqn}" "${hash}"
 
-		_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-				     --hostid "${def_hostid}" \
-				     --dhchap-secret "${hostkey}"
+		_nvme_connect_subsys --dhchap-secret "${hostkey}"
 
 		_nvme_disconnect_subsys
 	done
@@ -58,9 +56,7 @@ test() {
 
 		_set_nvmet_dhgroup "${def_hostnqn}" "${dhgroup}"
 
-		_nvme_connect_subsys  --hostnqn "${def_hostnqn}" \
-				      --hostid "${def_hostid}" \
-				      --dhchap-secret "${hostkey}"
+		_nvme_connect_subsys --dhchap-secret "${hostkey}"
 
 		_nvme_disconnect_subsys
 	done
tests/nvme/044 +4 -12
index 624b832c0cc6..8b8859068660 100755
@@ -49,18 +49,14 @@ test() {
 
 	# Step 1: Connect with host authentication only
 	echo "Test host authentication"
-	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-			     --hostid "${def_hostid}" \
-			     --dhchap-secret "${hostkey}"
+	_nvme_connect_subsys --dhchap-secret "${hostkey}"
 
 	_nvme_disconnect_subsys
 
 	# Step 2: Connect with host authentication
 	# and invalid ctrl authentication
 	echo "Test invalid ctrl authentication (should fail)"
-	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-			     --hostid "${def_hostid}" \
-			     --dhchap-secret "${hostkey}" \
+	_nvme_connect_subsys --dhchap-secret "${hostkey}" \
 			     --dhchap-ctrl-secret "${hostkey}"
 
 	_nvme_disconnect_subsys
@@ -68,9 +64,7 @@ test() {
 	# Step 3: Connect with host authentication
 	# and valid ctrl authentication
 	echo "Test valid ctrl authentication"
-	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-			     --hostid "${def_hostid}" \
-			     --dhchap-secret "${hostkey}" \
+	_nvme_connect_subsys --dhchap-secret "${hostkey}" \
 			     --dhchap-ctrl-secret "${ctrlkey}"
 
 	_nvme_disconnect_subsys
@@ -79,9 +73,7 @@ test() {
 	# and invalid ctrl key
 	echo "Test invalid ctrl key (should fail)"
 	invkey="DHHC-1:00:Jc/My1o0qtLCWRp+sHhAVafdfaS7YQOMYhk9zSmlatobqB8C:"
-	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-			     --hostid "${def_hostid}" \
-			     --dhchap-secret "${hostkey}" \
+	_nvme_connect_subsys --dhchap-secret "${hostkey}" \
 			     --dhchap-ctrl-secret "${invkey}"
 
 	_nvme_disconnect_subsys
tests/nvme/045 +1 -3
index 3a5df7c0946c..87ac3c019970 100755
@@ -51,9 +51,7 @@ test() {
 
 	_set_nvmet_dhgroup "${def_hostnqn}" "ffdhe2048"
 
-	_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-			     --hostid "${def_hostid}" \
-			     --dhchap-secret "${hostkey}" \
+	_nvme_connect_subsys --dhchap-secret "${hostkey}" \
 			     --dhchap-ctrl-secret "${ctrlkey}"
 
 	echo "Re-authenticate with original host key"
tests/nvme/048 +1 -3
index 79620e0d0879..0b299a91288b 100755
@@ -99,9 +99,7 @@ test() {
 	_nvmet_target_setup --blkdev file
 
 	if [[ -f "${cfs_path}/attr_qid_max" ]] ; then
-		_nvme_connect_subsys --hostnqn "${def_hostnqn}" \
-				     --hostid "${def_hostid}" \
-				     --keep-alive-tmo 1 \
+		_nvme_connect_subsys --keep-alive-tmo 1 \
 				     --reconnect-delay 2
 
 		if ! nvmf_wait_for_state "${def_subsysnqn}" "live" ; then
Signature · 1 line
2.44.0
#20 lore raw

PATCH v3 19/20 nvme: don't assume namespace id

In reply to Daniel Wagner

The tests assume that the namespace id is always 1. This might not be correct in future (e.g. running real targets), thus harden the test by using the uuid to lookup the correct namespace id.

The passthru test already do this, so it makes also sense to update the other tests as well.

---
 tests/nvme/010 |  7 +++----
 tests/nvme/011 |  7 +++----
 tests/nvme/012 |  7 +++----
 tests/nvme/013 |  7 +++----
 tests/nvme/014 | 13 ++++++-------
 tests/nvme/015 | 13 ++++++-------
 tests/nvme/018 | 15 +++++++--------
 tests/nvme/019 |  8 +++-----
 tests/nvme/020 |  7 +++----
 tests/nvme/021 |  7 +++----
 tests/nvme/023 |  8 +++-----
 tests/nvme/024 |  9 ++++-----
 tests/nvme/025 |  7 +++----
 tests/nvme/026 |  8 +++-----
 tests/nvme/029 |  7 ++-----
 tests/nvme/040 |  4 +++-
 tests/nvme/045 |  5 +++--
 tests/nvme/047 |  8 ++++----
 tests/nvme/rc  | 18 ++++++++++++++++++
 19 files changed, 83 insertions(+), 82 deletions(-)
tests/nvme/010 +3 -4
index 7d875989a01c..6feb39153e99 100755
@@ -20,17 +20,16 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 
 	_nvmet_target_setup
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
 	_run_fio_verify_io --size="${nvme_img_size}" \
-		--filename="/dev/${nvmedev}n1"
+		--filename="/dev/${ns}"
 
 	_nvme_disconnect_subsys
 
tests/nvme/011 +3 -4
index 0acc8b1dbaed..eee044cbb4f8 100755
@@ -20,17 +20,16 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 
 	_nvmet_target_setup --blkdev file
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
 	_run_fio_verify_io --size="${nvme_img_size}" \
-		--filename="/dev/${nvmedev}n1"
+		--filename="$/dev/{ns}"
 
 	_nvme_disconnect_subsys
 
tests/nvme/012 +3 -4
index a0bff298ab29..64cb6ecf0191 100755
@@ -24,16 +24,15 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 
 	_nvmet_target_setup
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
-	if ! _xfs_run_fio_verify_io "/dev/${nvmedev}n1"; then
+	if ! _xfs_run_fio_verify_io "/dev/${ns}"; then
 		echo "FAIL: fio verify failed"
 	fi
 
tests/nvme/013 +3 -4
index 5e5026eabe17..68d07cbc4afa 100755
@@ -23,16 +23,15 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 
 	_nvmet_target_setup --blkdev file
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
-	if ! _xfs_run_fio_verify_io "/dev/${nvmedev}n1"; then
+	if ! _xfs_run_fio_verify_io "$/dev/{ns}"; then
 		echo "FAIL: fio verify failed"
 	fi
 
tests/nvme/014 +6 -7
index da4b4c13b347..e56e3212cf28 100755
@@ -20,7 +20,7 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 	local size
 	local bs
 	local count
@@ -29,17 +29,16 @@ test() {
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
-	size="$(blockdev --getsize64 "/dev/${nvmedev}n1")"
-	bs="$(blockdev --getbsz "/dev/${nvmedev}n1")"
+	size="$(blockdev --getsize64 "/dev/${ns}")"
+	bs="$(blockdev --getbsz "/dev/${ns}")"
 	count=$((size / bs))
 
-	dd if=/dev/urandom of="/dev/${nvmedev}n1" \
+	dd if=/dev/urandom of="$/dev/{ns}" \
 		count="${count}" bs="${bs}" status=none
 
-	nvme flush "/dev/${nvmedev}" --namespace-id 1
+	nvme flush "/dev/${ns}"
 
 	_nvme_disconnect_subsys
 
tests/nvme/015 +6 -7
index b82f2253c011..f0621dab681b 100755
@@ -20,7 +20,7 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 	local size
 	local bs
 	local count
@@ -29,17 +29,16 @@ test() {
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
-	size="$(blockdev --getsize64 "/dev/${nvmedev}n1")"
-	bs="$(blockdev --getbsz "/dev/${nvmedev}n1")"
+	size="$(blockdev --getsize64 "/dev/${ns}")"
+	bs="$(blockdev --getbsz "/dev/${ns}")"
 	count=$((size / bs))
 
-	dd if=/dev/urandom of="/dev/${nvmedev}n1" \
+	dd if=/dev/urandom of="/dev/${ns}" \
 		count="${count}" bs="${bs}" status=none
 
-	nvme flush "/dev/${nvmedev}n1" --namespace-id 1
+	nvme flush "/dev/${ns}"
 
 	_nvme_disconnect_subsys
 
tests/nvme/018 +7 -8
index bd6e5e930e35..b8c16354a01b 100755
@@ -21,21 +21,20 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
+	local sectors
+	local bs
 
 	_nvmet_target_setup --blkdev file
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
-	local sectors
-	local bs
-	sectors="$(blockdev --getsz "/dev/${nvmedev}n1")"
-	bs="$(blockdev --getbsz "/dev/${nvmedev}n1")"
+	sectors="$(blockdev --getsz "/dev/${ns}")"
+	bs="$(blockdev --getbsz "/dev/${ns}")"
 
-	nvme read "/dev/${nvmedev}n1" --start-block "$sectors" \
+	nvme read "/dev/${ns}" --start-block "$sectors" \
 		--block-count 0 --data-size "$bs" &>"$FULL" \
 		&& echo "ERROR: nvme read for out of range LBA was not rejected"
 
tests/nvme/019 +3 -5
index 4d7de8191da7..1cd5378e9dd4 100755
@@ -20,7 +20,7 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 	local nblk_range="10,10,10,10,10,10,10,10,10,10"
 	local sblk_range="100,200,300,400,500,600,700,800,900,1000"
 
@@ -28,10 +28,8 @@ test() {
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
-
-	nvme dsm "/dev/${nvmedev}" --namespace-id 1 --ad \
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
+	nvme dsm "/dev/${ns}" --ad \
 		--slbs "${sblk_range}" --blocks "${nblk_range}"
 
 	_nvme_disconnect_subsys
tests/nvme/020 +3 -4
index c734210c5bd9..0364c4e0dd4f 100755
@@ -19,7 +19,7 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 	local nblk_range="10,10,10,10,10,10,10,10,10,10"
 	local sblk_range="100,200,300,400,500,600,700,800,900,1000"
 
@@ -27,10 +27,9 @@ test() {
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
-	nvme dsm "/dev/${nvmedev}" --namespace-id 1 --ad \
+	nvme dsm "/dev/${ns}" --ad \
 		--slbs "${sblk_range}" --blocks "${nblk_range}"
 
 	_nvme_disconnect_subsys
tests/nvme/021 +3 -4
index 358e209d0458..7ee1f078cd60 100755
@@ -20,16 +20,15 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 
 	_nvmet_target_setup --blkdev file
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
-	if ! nvme list 2>> "$FULL" | grep -q "${nvmedev}n1"; then
+	if ! nvme list 2>> "$FULL" | grep -q "/dev/${ns}"; then
 		echo "ERROR: device not listed"
 	fi
 
tests/nvme/023 +3 -5
index abbb35a0b580..d8f17ae7a8ea 100755
@@ -20,17 +20,15 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 
 	_nvmet_target_setup
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
-	if ! nvme smart-log "/dev/${nvmedev}" --namespace-id 1 \
-		>> "$FULL" 2>&1; then
+	if ! nvme smart-log "/dev/${ns}" >> "$FULL" 2>&1; then
 		echo "ERROR: smart-log bdev-ns failed"
 	fi
 
tests/nvme/024 +4 -5
index 3ee18822e26b..a5121940a543 100755
@@ -20,19 +20,18 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 
 	_nvmet_target_setup --blkdev file
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns ${def_subsys_uuid})
 
-	if ! nvme smart-log "/dev/${nvmedev}" --namespace-id 1 \
-		>> "$FULL" 2>&1; then
+	if ! nvme smart-log "/dev/${ns}" >> "$FULL" 2>&1; then
 		echo "ERROR: smart-log file-ns failed"
 	fi
+
 	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
 	_nvmet_target_cleanup
tests/nvme/025 +3 -4
index 3cd62d0b4e5e..3f9a615e542e 100755
@@ -20,16 +20,15 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 
 	_nvmet_target_setup --blkdev file
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
-	if ! nvme effects-log "/dev/${nvmedev}" >> "$FULL" 2>&1; then
+	if ! nvme effects-log "/dev/${ns}" >> "$FULL" 2>&1; then
 		echo "ERROR: effects-log failed"
 	fi
 
tests/nvme/026 +3 -5
index 5d54b0ff3d28..28fd151d9a77 100755
@@ -20,17 +20,15 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 
 	_nvmet_target_setup --blkdev file
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
-	if ! nvme ns-descs "/dev/${nvmedev}" --namespace-id 1 \
-		>> "$FULL" 2>&1; then
+	if ! nvme ns-descs "/dev/${ns}" >> "$FULL" 2>&1; then
 		echo "ERROR: ns-desc failed"
 	fi
 
tests/nvme/029 +2 -5
index 8dbe49ba15cc..559c0b4feabe 100755
@@ -53,16 +53,12 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
 	local reset_nr_hugepages=false
 
 	_nvmet_target_setup
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
-
 	# nvme-cli may fail to allocate linear memory for rather large IO buffers.
 	# Increase nr_hugepages to allow nvme-cli to try the linear memory allocation
 	# from HugeTLB pool.
@@ -72,7 +68,8 @@ test() {
 		reset_nr_hugepages=true
 	fi
 
-	local dev="/dev/${nvmedev}n1"
+	local dev
+	dev="/dev/$(_find_nvme_ns "${def_subsys_uuid}")"
 	test_user_io "$dev" 1 512 > "$FULL" 2>&1 || echo FAIL
 	test_user_io "$dev" 1 511 > "$FULL" 2>&1 || echo FAIL
 	test_user_io "$dev" 1 513 > "$FULL" 2>&1 || echo FAIL
tests/nvme/040 +3 -1
index f00fc16b643f..bb9ed5ef57e9 100755
@@ -23,15 +23,17 @@ test() {
 
 	local nvmedev
 	local fio_pid
+	local ns
 
 	_nvmet_target_setup
 
 	_nvme_connect_subsys
 	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
 	# start fio job
 	echo "starting background fio"
-	_run_fio_rand_io --filename="/dev/${nvmedev}n1" \
+	_run_fio_rand_io --filename="/dev/${ns}" \
 		--group_reporting --ramp_time=5 \
 		--time_based --runtime=1d &> /dev/null &
 	fio_pid=$!
tests/nvme/045 +3 -2
index 87ac3c019970..f387eadcbda3 100755
@@ -33,6 +33,7 @@ test() {
 	local new_ctrlkey
 	local ctrldev
 	local rand_io_size
+	local ns
 
 	hostkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)"
 	if [ -z "$hostkey" ] ; then
@@ -100,10 +101,10 @@ test() {
 
 	echo "${new_hostkey}" > "${hostkey_file}"
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
 	rand_io_size="$(_nvme_calc_rand_io_size 4m)"
-	_run_fio_rand_io --size="${rand_io_size}" --filename="/dev/${nvmedev}n1"
+	_run_fio_rand_io --size="${rand_io_size}" --filename="/dev/${ns}"
 
 	_nvme_disconnect_subsys
 	_nvmet_target_cleanup
tests/nvme/047 +4 -4
index 75aad7d06a36..9bbe84d4f145 100755
@@ -22,7 +22,7 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
+	local ns
 	local rand_io_size
 
 	_nvmet_target_setup
@@ -30,10 +30,10 @@ test() {
 	_nvme_connect_subsys \
 		--nr-write-queues 1 || echo FAIL
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
 
 	rand_io_size="$(_nvme_calc_rand_io_size 4M)"
-	_run_fio_rand_io --filename="/dev/${nvmedev}n1" --size="${rand_io_size}"
+	_run_fio_rand_io --filename="/dev/${ns}" --size="${rand_io_size}"
 
 	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
@@ -41,7 +41,7 @@ test() {
 		--nr-write-queues 1 \
 		--nr-poll-queues 1 || echo FAIL
 
-	_run_fio_rand_io --filename="/dev/${nvmedev}n1" --size="${rand_io_size}"
+	_run_fio_rand_io --filename="/dev/${ns}" --size="${rand_io_size}"
 
 	_nvme_disconnect_subsys >> "$FULL" 2>&1
 
tests/nvme/rc +18 -0
index fb7a5fa864e8..203cf0c7903b 100644
@@ -797,6 +797,24 @@ _find_nvme_dev() {
 	done
 }
 
+_find_nvme_ns() {
+	local subsys_uuid=$1
+	local uuid
+	local ns
+
+	for ns in "/sys/block/nvme"* ; do
+		# ignore nvme channel block devices
+		if ! [[ "${ns}" =~ nvme[0-9]+n[0-9]+ ]]; then
+			continue
+		fi
+		[ -e "${ns}/uuid" ] || continue
+		uuid=$(cat "${ns}/uuid")
+		if [[ "${subsys_uuid}" == "${uuid}" ]]; then
+			basename "${ns}"
+		fi
+	done
+}
+
 _find_nvme_passthru_loop_dev() {
 	local subsys=$1
 	local nsid
Signature · 1 line
2.44.0
#21 lore raw

PATCH v3 20/20 nvme/028: drop unused nvmedev

In reply to Daniel Wagner

Nothing uses nvmedev, so just remove it.

---
 tests/nvme/028 | 5 -----
 1 file changed, 5 deletions(-)
tests/nvme/028 +0 -5
index 4710bba1f416..9f4a90581984 100755
@@ -20,15 +20,10 @@ test() {
 
 	_setup_nvmet
 
-	local nvmedev
-
 	_nvmet_target_setup --blkdev file
 
 	_nvme_connect_subsys
 
-	nvmedev=$(_find_nvme_dev "${def_subsysnqn}")
-	_check_uuid "${nvmedev}"
-
 	if ! nvme list-subsys 2>> "$FULL" | grep -q "${nvme_trtype}"; then
 		echo "ERROR: list-subsys"
 	fi
Signature · 1 line
2.44.0
#22 lore raw
In reply to Daniel Wagner
Quoted 5 lines · Daniel Wagner

I've updated the passthru tests in the same way as the rest of the fabric tests.

changes:
v3:
- streamlined passthru tests according the rest of the fabric tests

Applied, thanks!