diff mbox series

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

Message ID 20240321094727.6503-14-dwagner@suse.de (mailing list archive)
State New, archived
Headers show
Series refactoring and various cleanups/fixes | expand

Commit Message

Daniel Wagner March 21, 2024, 9:47 a.m. UTC
If the test setups a loop device itself (not created by
_nvmet_target_create), do not cleanup automatically.

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

Comments

Shinichiro Kawasaki March 22, 2024, 9:21 a.m. UTC | #1
On Mar 21, 2024 / 10:47, Daniel Wagner wrote:
> If the test setups a loop device itself (not created by
> _nvmet_target_create), do not cleanup automatically.

I couldn't find _nvmet_target_create(). Do you mean _nvmet_target_setup()?

This patch looks fixing an issue caused by the previous patch. If this guess is
correct, it might be a bit better to reorder this patch and the previous one.

> 
> Signed-off-by: Daniel Wagner <dwagner@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
>
diff mbox series

Patch

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() {