[PATCH blktests 13/15] nvme: delete all namespaces in _remove_nvmet_subsystem()

Shin'ichiro Kawasaki shinichiro.kawasaki at wdc.com
Wed Oct 23 18:00:23 PDT 2024


From: Hannes Reinecke <hare at suse.de>

A subsystem might have more than one namespace, so delete all of
them in _remove_nvmet_subsystem().

Signed-off-by: Hannes Reinecke <hare at suse.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki at wdc.com>
---
 common/nvme    | 5 ++++-
 tests/nvme/016 | 4 ----
 tests/nvme/017 | 4 ----
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/common/nvme b/common/nvme
index dce3943..6cdff13 100644
--- a/common/nvme
+++ b/common/nvme
@@ -654,7 +654,10 @@ _remove_nvmet_subsystem() {
 	local nvmet_subsystem="$1"
 	local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}"
 
-	_remove_nvmet_ns "${nvmet_subsystem}" "1"
+	for n in "${subsys_path}/namespaces/"*; do
+		[ -d "${n}" ] || continue
+		_remove_nvmet_ns "${nvmet_subsystem}" "${n##*/}"
+	done
 	rm -f "${subsys_path}"/allowed_hosts/*
 	rmdir "${subsys_path}"
 }
diff --git a/tests/nvme/016 b/tests/nvme/016
index 13d2c46..4b01c0a 100755
--- a/tests/nvme/016
+++ b/tests/nvme/016
@@ -47,10 +47,6 @@ test() {
 	_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
 	_remove_nvmet_port "${port}"
 
-	for ((i = iterations; i > 1; i--)); do
-		_remove_nvmet_ns "${def_subsysnqn}" "$i"
-	done
-
 	_remove_nvmet_subsystem "${def_subsysnqn}"
 
 	echo "Test complete"
diff --git a/tests/nvme/017 b/tests/nvme/017
index 10ee38c..8f57579 100755
--- a/tests/nvme/017
+++ b/tests/nvme/017
@@ -48,10 +48,6 @@ test() {
 	_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
 	_remove_nvmet_port "${port}"
 
-	for ((i = iterations; i > 1; i--)); do
-		_remove_nvmet_ns "${def_subsysnqn}" "$i"
-	done
-
 	_remove_nvmet_subsystem "${def_subsysnqn}"
 
 	rm "$(_nvme_def_file_path)"
-- 
2.45.2




More information about the Linux-nvme mailing list