Re: [PATCH blktests v1 1/1] nvme: Introduce nvmet_target_{setup/cleanup} common code

From: Daniel Wagner
Date: Fri Aug 18 2023 - 08:10:52 EST


> +_nvmet_target_cleanup() {
> + local ports
> + local port
> + local blkdev
> +
> + _get_nvmet_ports "${def_subsysnqn}" ports
> +
> + for port in "${ports[@]}"; do
> + _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
> + done
> + _remove_nvmet_subsystem "${def_subsysnqn}"
> + _remove_nvmet_port "${port}"

_remove_nvmet_port should be also be part of the loop.

> + _remove_nvmet_host "${def_hostnqn}"
> +
> + blkdev="$(losetup -l | awk '$6 == "'"${def_file_path}"'" { print $1 }')"
> + if [[ -n "${blkdev}" ]] ; then
> + losetup -d "${blkdev}"
> + fi
> + rm "${def_file_path}"
> +}
> +