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

From: Sagi Grimberg
Date: Sun Aug 13 2023 - 10:56:06 EST




On 8/11/23 12:36, Daniel Wagner wrote:
Almost all fabric tests have the identically code for
setting up and cleaning up the target side. Introduce
two new helpers.

Signed-off-by: Daniel Wagner <dwagner@xxxxxxx>
---
tests/nvme/003 | 13 +++-------
tests/nvme/004 | 20 +++------------
tests/nvme/005 | 19 ++-------------
tests/nvme/006 | 18 ++------------
tests/nvme/007 | 13 ++--------
tests/nvme/008 | 20 ++-------------
tests/nvme/009 | 15 ++----------
tests/nvme/010 | 20 ++-------------
tests/nvme/011 | 15 ++----------
tests/nvme/012 | 20 ++-------------
tests/nvme/013 | 15 ++----------
tests/nvme/014 | 20 ++-------------
tests/nvme/015 | 15 ++----------
tests/nvme/018 | 15 ++----------
tests/nvme/019 | 20 ++-------------
tests/nvme/020 | 15 ++----------
tests/nvme/021 | 15 ++----------
tests/nvme/022 | 15 ++----------
tests/nvme/023 | 20 ++-------------
tests/nvme/024 | 15 ++----------
tests/nvme/025 | 15 ++----------
tests/nvme/026 | 15 ++----------
tests/nvme/027 | 16 +++---------
tests/nvme/028 | 16 +++---------
tests/nvme/029 | 20 ++-------------
tests/nvme/040 | 18 ++------------
tests/nvme/041 | 17 ++-----------
tests/nvme/042 | 16 ++----------
tests/nvme/043 | 16 ++----------
tests/nvme/044 | 18 +++-----------
tests/nvme/045 | 17 +++----------
tests/nvme/047 | 20 ++-------------
tests/nvme/048 | 16 ++----------
tests/nvme/rc | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
34 files changed, 138 insertions(+), 486 deletions(-)

diff --git a/tests/nvme/003 b/tests/nvme/003
index 71b82ce758a3..54e5fe651c9a 100755
--- a/tests/nvme/003
+++ b/tests/nvme/003
@@ -22,15 +22,9 @@ test() {
_setup_nvmet
- local loop_dev
local port
- port="$(_create_nvmet_port "${nvme_trtype}")"
-
- loop_dev="$(losetup -f)"
-
- _create_nvmet_subsystem "${def_subsysnqn}" "${loop_dev}"
- _add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
+ port="$(_nvmet_target_setup --blkdev=device)"
_nvme_connect_subsys "${nvme_trtype}" nqn.2014-08.org.nvmexpress.discovery
@@ -46,9 +40,8 @@ test() {
fi
_nvme_disconnect_subsys nqn.2014-08.org.nvmexpress.discovery
- _remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
- _remove_nvmet_subsystem "${def_subsysnqn}"
- _remove_nvmet_port "${port}"
+
+ _nvmet_target_cleanup "${port}"

It is very very strange that _setup returns a port
which is passed to _cleanup...

I think that _cleanup should simply remove all
ports, and that setup should not return a port
to begin with.

If someone needs the actual port number, then it
should either not use this _setup helper or
query it somehow.