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

Daniel Wagner dwagner at suse.de
Tue Mar 26 06:13:58 PDT 2024


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.

Signed-off-by: Daniel Wagner <dwagner at suse.de>
---
 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(-)

diff --git a/tests/nvme/033 b/tests/nvme/033
index c0482c808d43..f7d9f04450a8 100755
--- a/tests/nvme/033
+++ b/tests/nvme/033
@@ -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"
 }
diff --git a/tests/nvme/034 b/tests/nvme/034
index 8bb2d8cd8d62..e5518d497377 100755
--- a/tests/nvme/034
+++ b/tests/nvme/034
@@ -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"
 }
diff --git a/tests/nvme/035 b/tests/nvme/035
index 1d1b5e4ac46e..8a66c2c15218 100755
--- a/tests/nvme/035
+++ b/tests/nvme/035
@@ -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"
 }
diff --git a/tests/nvme/036 b/tests/nvme/036
index 0e9c3bf3486c..20cd3af7081a 100755
--- a/tests/nvme/036
+++ b/tests/nvme/036
@@ -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"
 }
diff --git a/tests/nvme/037 b/tests/nvme/037
index 159d9d990bb7..2fe37a7a7340 100755
--- a/tests/nvme/037
+++ b/tests/nvme/037
@@ -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"
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 6493aa30adef..fca7408062ee 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -899,13 +899,26 @@ _nvmet_target_cleanup() {
 }
 
 _nvmet_passthru_target_setup() {
-	local subsys_name=$1
+	local subsysnqn="$def_subsysnqn"
 	local port
 
-	_create_nvmet_passthru "${subsys_name}"
+	while [[ $# -gt 0 ]]; do
+		case $1 in
+			--subsysnqn)
+				subsysnqn="$2"
+				shift 2
+				;;
+			*)
+				echo "WARNING: unknown argument: $1"
+				shift
+				;;
+		esac
+	done
+
+	_create_nvmet_passthru "${subsysnqn}"
 	port="$(_create_nvmet_port "${nvme_trtype}")"
-	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
-	_create_nvmet_host "${subsys_name}" "${def_hostnqn}"
+	_add_nvmet_subsys_to_port "${port}" "${subsysnqn}"
+	_create_nvmet_host "${subsysnqn}" "${def_hostnqn}"
 }
 
 _nvmet_passthru_target_connect() {
@@ -923,18 +936,31 @@ _nvmet_passthru_target_connect() {
 }
 
 _nvmet_passthru_target_cleanup() {
-	local subsys_name=$1
+	local subsysnqn="$def_subsysnqn"
 	local ports
 	local port
 
-	_get_nvmet_ports "${subsys_name}" ports
+	while [[ $# -gt 0 ]]; do
+		case $1 in
+			--subsysnqn)
+				subsysnqn="$2"
+				shift 2
+				;;
+			*)
+				echo "WARNING: unknown argument: $1"
+				shift
+				;;
+		esac
+	done
+
+	_get_nvmet_ports "${subsysnqn}" ports
 
 	for port in "${ports[@]}"; do
-		_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
+		_remove_nvmet_subsystem_from_port "${port}" "${subsysnqn}"
 		_remove_nvmet_port "${port}"
 	done
 
-	_remove_nvmet_passhtru "${subsys_name}"
+	_remove_nvmet_passhtru "${subsysnqn}"
 	_remove_nvmet_host "${def_hostnqn}"
 }
 
-- 
2.44.0




More information about the Linux-nvme mailing list