[PATCH blktests v1 13/18] nvme/{rc,031}: do not cleanup external managed loop device

Daniel Wagner dwagner at suse.de
Thu Mar 21 02:47:22 PDT 2024


If the test setups a loop device itself (not created by
_nvmet_target_create), do not cleanup automatically.

Signed-off-by: Daniel Wagner <dwagner at suse.de>
---
 tests/nvme/031 | 2 +-
 tests/nvme/rc  | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/nvme/031 b/tests/nvme/031
index 892a52170ce9..bfc43282411e 100755
--- a/tests/nvme/031
+++ b/tests/nvme/031
@@ -45,7 +45,7 @@ test() {
 		_nvme_connect_subsys "${nvme_trtype}" "${subsys}$i"
 		_nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1
 
-		_nvmet_target_cleanup --subsysnqn "${subsys}$i"
+		_nvmet_target_cleanup --subsysnqn "${subsys}$i" --blkdev "${loop_dev}"
 	done
 
 	_remove_nvmet_port "${port}"
diff --git a/tests/nvme/rc b/tests/nvme/rc
index d74a5418557d..e6e7b113ca8b 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -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() {
-- 
2.44.0




More information about the Linux-nvme mailing list