linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/7] blktests: Add support to run nvme tests with tcp/rdma transports
@ 2020-08-06 19:15 Sagi Grimberg
  2020-08-06 19:15 ` [PATCH v2 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
                   ` (6 more replies)
  0 siblings, 7 replies; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-06 19:15 UTC (permalink / raw)
  To: linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni

We have a collection of nvme tests, but all run with nvme-loop. This
is the easiest to run on a standalone machine. However its very much possible
to run nvme-tcp and nvme-rdma using a loopback network. Add capability to run
tests with a new environment variable to set the transport type $nvme_trtype.

$ nvme_trtype=[loop|tcp|rdma] ./check test/nvme

This buys us some nice coverage on some more transport types. We also add
some transport type specific helpers to mark tests that are relevant only
for a single transport.

Changes from v1:
- added patch to remove use of module_unload
- move trtype agnostic logig helpers in patch #3

Sagi Grimberg (7):
  nvme: consolidate nvme requirements based on transport type
  nvme: consolidate some nvme-cli utility functions
  nvme: make tests transport type agnostic
  tests/nvme: restrict tests to specific transports
  nvme: support nvme-tcp when runinng tests
  common/multipath-over-rdma: don't retry module unload
  nvme: support rdma transport type

 common/multipath-over-rdma |   4 +-
 tests/nvme/002             |   8 ++-
 tests/nvme/003             |  10 +--
 tests/nvme/004             |  12 ++--
 tests/nvme/005             |  15 ++---
 tests/nvme/006             |   7 ++-
 tests/nvme/007             |   5 +-
 tests/nvme/008             |  13 ++--
 tests/nvme/009             |  11 ++--
 tests/nvme/010             |  13 ++--
 tests/nvme/011             |  13 ++--
 tests/nvme/012             |  14 +++--
 tests/nvme/013             |  13 ++--
 tests/nvme/014             |  13 ++--
 tests/nvme/015             |  12 ++--
 tests/nvme/016             |   7 ++-
 tests/nvme/017             |   7 ++-
 tests/nvme/018             |  13 ++--
 tests/nvme/019             |  13 ++--
 tests/nvme/020             |  11 ++--
 tests/nvme/021             |  13 ++--
 tests/nvme/022             |  13 ++--
 tests/nvme/023             |  13 ++--
 tests/nvme/024             |  13 ++--
 tests/nvme/025             |  13 ++--
 tests/nvme/026             |  13 ++--
 tests/nvme/027             |  13 ++--
 tests/nvme/028             |  15 ++---
 tests/nvme/029             |  13 ++--
 tests/nvme/030             |   8 +--
 tests/nvme/031             |  12 ++--
 tests/nvme/032             |   4 ++
 tests/nvme/rc              | 122 ++++++++++++++++++++++++++++++++++---
 33 files changed, 311 insertions(+), 168 deletions(-)

-- 
2.25.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 1/7] nvme: consolidate nvme requirements based on transport type
  2020-08-06 19:15 [PATCH v2 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
@ 2020-08-06 19:15 ` Sagi Grimberg
  2020-08-07  2:41   ` Chaitanya Kulkarni
  2020-08-06 19:15 ` [PATCH v2 2/7] nvme: consolidate some nvme-cli utility functions Sagi Grimberg
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-06 19:15 UTC (permalink / raw)
  To: linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni

Right now, only pci and loop have tests, hence these are
the only ones that are allowed. The user can pass an env
variable nvme_trtype and check for the necessary modules.

This allows prepares us to support other transport types.

Note that test 031 is designed to run only with nvme, hence
it overrides the environment variable to nvme_trtype=pci.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 tests/nvme/002 |  3 ++-
 tests/nvme/003 |  3 ++-
 tests/nvme/004 |  3 ++-
 tests/nvme/005 |  6 +++---
 tests/nvme/006 |  4 ++--
 tests/nvme/007 |  2 +-
 tests/nvme/008 |  4 ++--
 tests/nvme/009 |  2 +-
 tests/nvme/010 |  4 ++--
 tests/nvme/011 |  4 ++--
 tests/nvme/012 |  5 +++--
 tests/nvme/013 |  4 ++--
 tests/nvme/014 |  4 ++--
 tests/nvme/015 |  3 ++-
 tests/nvme/016 |  2 +-
 tests/nvme/017 |  2 +-
 tests/nvme/018 |  4 ++--
 tests/nvme/019 |  4 ++--
 tests/nvme/020 |  2 +-
 tests/nvme/021 |  4 ++--
 tests/nvme/022 |  4 ++--
 tests/nvme/023 |  4 ++--
 tests/nvme/024 |  4 ++--
 tests/nvme/025 |  4 ++--
 tests/nvme/026 |  4 ++--
 tests/nvme/027 |  4 ++--
 tests/nvme/028 |  4 ++--
 tests/nvme/029 |  4 ++--
 tests/nvme/030 |  5 ++---
 tests/nvme/031 |  5 ++---
 tests/nvme/032 |  4 ++++
 tests/nvme/rc  | 19 +++++++++++++++++++
 32 files changed, 80 insertions(+), 54 deletions(-)

diff --git a/tests/nvme/002 b/tests/nvme/002
index 07b7fdae2d39..aaa5ec4d729a 100755
--- a/tests/nvme/002
+++ b/tests/nvme/002
@@ -10,7 +10,8 @@
 DESCRIPTION="create many subsystems and test discovery"
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && _have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/003 b/tests/nvme/003
index ed0feca3cac7..fd696d9efe2c 100755
--- a/tests/nvme/003
+++ b/tests/nvme/003
@@ -11,7 +11,8 @@ DESCRIPTION="test if we're sending keep-alives to a discovery controller"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && _have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/004 b/tests/nvme/004
index 0debcd9c7049..b841a8d4cd87 100755
--- a/tests/nvme/004
+++ b/tests/nvme/004
@@ -12,7 +12,8 @@ DESCRIPTION="test nvme and nvmet UUID NS descriptors"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && _have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/005 b/tests/nvme/005
index 8c79d234bb1d..df0900b372be 100755
--- a/tests/nvme/005
+++ b/tests/nvme/005
@@ -11,9 +11,9 @@ DESCRIPTION="reset local loopback target"
 QUICK=1
 
 requires() {
-	_have_modules loop nvme-core nvme-loop nvmet && \
-		_have_module_param_value nvme_core multipath Y && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop && \
+		_have_module_param_value nvme_core multipath Y
 }
 
 test() {
diff --git a/tests/nvme/006 b/tests/nvme/006
index 6c8e18560264..3f47613d52d2 100755
--- a/tests/nvme/006
+++ b/tests/nvme/006
@@ -10,8 +10,8 @@ DESCRIPTION="create an NVMeOF target with a block device-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/007 b/tests/nvme/007
index 58f4bf8808a1..0902745a4ab2 100755
--- a/tests/nvme/007
+++ b/tests/nvme/007
@@ -10,7 +10,7 @@ DESCRIPTION="create an NVMeOF target with a file-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules nvme-loop nvmet && _have_configfs
+	_nvme_requires
 }
 
 test() {
diff --git a/tests/nvme/008 b/tests/nvme/008
index 71ff4d962b00..f19de17fefac 100755
--- a/tests/nvme/008
+++ b/tests/nvme/008
@@ -10,8 +10,8 @@ DESCRIPTION="create an NVMeOF host with a block device-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/009 b/tests/nvme/009
index 25c7da2ab854..4afbe62864f6 100755
--- a/tests/nvme/009
+++ b/tests/nvme/009
@@ -10,7 +10,7 @@ DESCRIPTION="create an NVMeOF host with a file-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules nvme-loop nvmet && _have_configfs
+	_nvme_requires
 }
 
 test() {
diff --git a/tests/nvme/010 b/tests/nvme/010
index 2ed0f4871a30..53b97484615f 100755
--- a/tests/nvme/010
+++ b/tests/nvme/010
@@ -10,8 +10,8 @@ DESCRIPTION="run data verification fio job on NVMeOF block device-backed ns"
 TIMED=1
 
 requires() {
-	_have_program nvme && _have_fio && \
-		_have_modules loop nvme-loop nvmet && _have_configfs
+	_nvme_requires
+	_have_fio _have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/011 b/tests/nvme/011
index 974b33745b99..a54583d5c582 100755
--- a/tests/nvme/011
+++ b/tests/nvme/011
@@ -10,8 +10,8 @@ DESCRIPTION="run data verification fio job on NVMeOF file-backed ns"
 TIMED=1
 
 requires() {
-	_have_program nvme && _have_fio && _have_configfs && \
-		_have_modules nvme-loop nvmet
+	_nvme_requires
+	_have_fio
 }
 
 test() {
diff --git a/tests/nvme/012 b/tests/nvme/012
index 27981e903c58..0049c3d8ceb6 100755
--- a/tests/nvme/012
+++ b/tests/nvme/012
@@ -10,8 +10,9 @@ DESCRIPTION="run mkfs and data verification fio job on NVMeOF block device-backe
 TIMED=1
 
 requires() {
-	_have_program nvme && _have_program mkfs.xfs && _have_program fio && \
-		_have_modules loop nvme-loop nvmet && _have_configfs
+	_nvme_requires
+	_have_program mkfs.xfs && _have_program fio && \
+		_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/013 b/tests/nvme/013
index af5f3730a2fc..622706ec4088 100755
--- a/tests/nvme/013
+++ b/tests/nvme/013
@@ -10,8 +10,8 @@ DESCRIPTION="run mkfs and data verification fio job on NVMeOF file-backed ns"
 TIMED=1
 
 requires() {
-	_have_program nvme && _have_program mkfs.xfs && _have_fio && \
-		_have_modules nvme-loop nvmet && _have_configfs
+	_nvme_requires
+	_have_program mkfs.xfs && _have_fio
 }
 
 test() {
diff --git a/tests/nvme/014 b/tests/nvme/014
index c255d5f12205..9517230253ab 100755
--- a/tests/nvme/014
+++ b/tests/nvme/014
@@ -10,8 +10,8 @@ DESCRIPTION="flush a NVMeOF block device-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/015 b/tests/nvme/015
index a8497a2ba400..40b850974b43 100755
--- a/tests/nvme/015
+++ b/tests/nvme/015
@@ -10,7 +10,8 @@ DESCRIPTION="unit test for NVMe flush for file backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && _have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/016 b/tests/nvme/016
index f1e383cb441a..e1bad2f81461 100755
--- a/tests/nvme/016
+++ b/tests/nvme/016
@@ -9,7 +9,7 @@
 DESCRIPTION="create/delete many NVMeOF block device-backed ns and test discovery"
 
 requires() {
-	_have_program nvme && _have_modules nvme-loop nvmet && _have_configfs
+	_nvme_requires
 }
 
 test() {
diff --git a/tests/nvme/017 b/tests/nvme/017
index 6787b5c754ba..2e6d649f9b65 100755
--- a/tests/nvme/017
+++ b/tests/nvme/017
@@ -9,7 +9,7 @@
 DESCRIPTION="create/delete many file-ns and test discovery"
 
 requires() {
-	_have_program nvme && _have_modules nvme-loop nvmet && _have_configfs
+	_nvme_requires
 }
 
 test() {
diff --git a/tests/nvme/018 b/tests/nvme/018
index 67d89a6f0b24..e39613709c90 100755
--- a/tests/nvme/018
+++ b/tests/nvme/018
@@ -11,8 +11,8 @@ DESCRIPTION="unit test NVMe-oF out of range access on a file backend"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/019 b/tests/nvme/019
index a8b0204ec0eb..86a2a2945b35 100755
--- a/tests/nvme/019
+++ b/tests/nvme/019
@@ -10,8 +10,8 @@ DESCRIPTION="test NVMe DSM Discard command on NVMeOF block-device ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/020 b/tests/nvme/020
index b480ee1b92d0..ccadec6a5822 100755
--- a/tests/nvme/020
+++ b/tests/nvme/020
@@ -10,7 +10,7 @@ DESCRIPTION="test NVMe DSM Discard command on NVMeOF file-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules nvme-loop nvmet && _have_configfs
+	_nvme_requires
 }
 
 test() {
diff --git a/tests/nvme/021 b/tests/nvme/021
index bbee54d16ff1..bbcb9d56a350 100755
--- a/tests/nvme/021
+++ b/tests/nvme/021
@@ -10,8 +10,8 @@ DESCRIPTION="test NVMe list command on NVMeOF file-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/022 b/tests/nvme/022
index 9ba07c1cc50f..452e7b3d196c 100755
--- a/tests/nvme/022
+++ b/tests/nvme/022
@@ -10,8 +10,8 @@ DESCRIPTION="test NVMe reset command on NVMeOF file-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/023 b/tests/nvme/023
index ed2a5ad7653f..2714571d16d9 100755
--- a/tests/nvme/023
+++ b/tests/nvme/023
@@ -10,8 +10,8 @@ DESCRIPTION="test NVMe smart-log command on NVMeOF block-device ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/024 b/tests/nvme/024
index 538580947c5c..1f87bd19ec69 100755
--- a/tests/nvme/024
+++ b/tests/nvme/024
@@ -10,8 +10,8 @@ DESCRIPTION="test NVMe smart-log command on NVMeOF file-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/025 b/tests/nvme/025
index 0039fefa5007..1b9e33351f61 100755
--- a/tests/nvme/025
+++ b/tests/nvme/025
@@ -10,8 +10,8 @@ DESCRIPTION="test NVMe effects-log command on NVMeOF file-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/026 b/tests/nvme/026
index 7e89d840529c..21a265a630ba 100755
--- a/tests/nvme/026
+++ b/tests/nvme/026
@@ -10,8 +10,8 @@ DESCRIPTION="test NVMe ns-descs command on NVMeOF file-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/027 b/tests/nvme/027
index 4d293beb8b47..d7d33796e122 100755
--- a/tests/nvme/027
+++ b/tests/nvme/027
@@ -10,8 +10,8 @@ DESCRIPTION="test NVMe ns-rescan command on NVMeOF file-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/028 b/tests/nvme/028
index 1280107ed5df..1643857437e8 100755
--- a/tests/nvme/028
+++ b/tests/nvme/028
@@ -10,8 +10,8 @@ DESCRIPTION="test NVMe list-subsys command on NVMeOF file-backed ns"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/029 b/tests/nvme/029
index 65eb40031888..9f437285d085 100755
--- a/tests/nvme/029
+++ b/tests/nvme/029
@@ -11,8 +11,8 @@ DESCRIPTION="test userspace IO via nvme-cli read/write interface"
 QUICK=1
 
 requires() {
-	_have_program nvme && _have_modules loop nvme-loop nvmet && \
-		_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test_user_io()
diff --git a/tests/nvme/030 b/tests/nvme/030
index 94020f47411e..7156cad7b657 100755
--- a/tests/nvme/030
+++ b/tests/nvme/030
@@ -10,9 +10,8 @@ DESCRIPTION="ensure the discovery generation counter is updated appropriately"
 QUICK=1
 
 requires() {
-	_have_program nvme &&
-	_have_modules loop nvme-loop nvmet &&
-	_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 
diff --git a/tests/nvme/031 b/tests/nvme/031
index 892f20bad9a7..7e7ee7327e62 100755
--- a/tests/nvme/031
+++ b/tests/nvme/031
@@ -18,9 +18,8 @@ DESCRIPTION="test deletion of NVMeOF controllers immediately after setup"
 QUICK=1
 
 requires() {
-	_have_program nvme &&
-	_have_modules loop nvme-loop nvmet &&
-	_have_configfs
+	_nvme_requires
+	_have_modules loop
 }
 
 test() {
diff --git a/tests/nvme/032 b/tests/nvme/032
index 0d0d53b325e6..017d4a339971 100755
--- a/tests/nvme/032
+++ b/tests/nvme/032
@@ -11,11 +11,15 @@
 
 . tests/nvme/rc
 
+#restrict test to nvme-pci only
+nvme_trtype=pci
+
 DESCRIPTION="test nvme pci adapter rescan/reset/remove during I/O"
 QUICK=1
 CAN_BE_ZONED=1
 
 requires() {
+	_nvme_requires
 	_have_fio
 }
 
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 6ffa971b4308..320aa4b2b475 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -6,6 +6,25 @@
 
 . common/rc
 
+nvme_trtype=${nvme_trtype:-"loop"}
+
+_nvme_requires() {
+	_have_program nvme
+	case ${nvme_trtype} in
+	loop)
+		_have_modules nvmet nvme-core nvme-loop
+		_have_configfs
+		;;
+	pci)
+		_have_modules nvme nvme-core
+		;;
+	*)
+		SKIP_REASON="unsupported nvme_trtype=${nvme_trtype}"
+		return 1
+	esac
+	return 0
+}
+
 group_requires() {
 	_have_root
 }
-- 
2.25.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 2/7] nvme: consolidate some nvme-cli utility functions
  2020-08-06 19:15 [PATCH v2 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
  2020-08-06 19:15 ` [PATCH v2 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
@ 2020-08-06 19:15 ` Sagi Grimberg
  2020-08-07  2:53   ` Chaitanya Kulkarni
  2020-08-06 19:15 ` [PATCH v2 3/7] nvme: make tests transport type agnostic Sagi Grimberg
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-06 19:15 UTC (permalink / raw)
  To: linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 tests/nvme/002 |  2 +-
 tests/nvme/003 |  4 ++--
 tests/nvme/004 |  4 ++--
 tests/nvme/005 |  4 ++--
 tests/nvme/008 |  4 ++--
 tests/nvme/009 |  4 ++--
 tests/nvme/010 |  4 ++--
 tests/nvme/011 |  4 ++--
 tests/nvme/012 |  4 ++--
 tests/nvme/013 |  4 ++--
 tests/nvme/014 |  4 ++--
 tests/nvme/015 |  4 ++--
 tests/nvme/016 |  2 +-
 tests/nvme/017 |  2 +-
 tests/nvme/018 |  4 ++--
 tests/nvme/019 |  4 ++--
 tests/nvme/020 |  4 ++--
 tests/nvme/021 |  4 ++--
 tests/nvme/022 |  4 ++--
 tests/nvme/023 |  4 ++--
 tests/nvme/024 |  4 ++--
 tests/nvme/025 |  4 ++--
 tests/nvme/026 |  4 ++--
 tests/nvme/027 |  4 ++--
 tests/nvme/028 |  4 ++--
 tests/nvme/029 |  4 ++--
 tests/nvme/031 |  4 ++--
 tests/nvme/rc  | 31 +++++++++++++++++++++++++++++--
 28 files changed, 80 insertions(+), 53 deletions(-)

diff --git a/tests/nvme/002 b/tests/nvme/002
index aaa5ec4d729a..999e222705bf 100755
--- a/tests/nvme/002
+++ b/tests/nvme/002
@@ -31,7 +31,7 @@ test() {
 		_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-$i"
 	done
 
-	nvme discover -t loop | _filter_discovery
+	_nvme_discover "loop" | _filter_discovery
 
 	for ((i = iterations - 1; i >= 0; i--)); do
 		_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-$i"
diff --git a/tests/nvme/003 b/tests/nvme/003
index fd696d9efe2c..6ea6a23b7942 100755
--- a/tests/nvme/003
+++ b/tests/nvme/003
@@ -29,7 +29,7 @@ test() {
 	_create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}"
 	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
 
-	nvme connect -t loop -n nqn.2014-08.org.nvmexpress.discovery
+	_nvme_connect_subsys "loop" "nqn.2014-08.org.nvmexpress.discovery"
 
 	# This is ugly but checking for the absence of error messages is ...
 	sleep 10
@@ -42,7 +42,7 @@ test() {
 		echo "Fail"
 	fi
 
-	nvme disconnect -n nqn.2014-08.org.nvmexpress.discovery
+	_nvme_disconnect_subsys "nqn.2014-08.org.nvmexpress.discovery"
 	_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
 	_remove_nvmet_subsystem "blktests-subsystem-1"
 	_remove_nvmet_port "${port}"
diff --git a/tests/nvme/004 b/tests/nvme/004
index b841a8d4cd87..7ea539fda55e 100755
--- a/tests/nvme/004
+++ b/tests/nvme/004
@@ -33,14 +33,14 @@ test() {
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
 	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
 
-	nvme connect -t loop -n blktests-subsystem-1
+	_nvme_connect_subsys "loop" "blktests-subsystem-1"
 
 	local nvmedev
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
-	nvme disconnect -n "blktests-subsystem-1"
+	_nvme_disconnect_subsys "blktests-subsystem-1"
 	_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
 	_remove_nvmet_subsystem "blktests-subsystem-1"
 	_remove_nvmet_port "${port}"
diff --git a/tests/nvme/005 b/tests/nvme/005
index df0900b372be..d4ce6d703c1b 100755
--- a/tests/nvme/005
+++ b/tests/nvme/005
@@ -33,7 +33,7 @@ test() {
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
 	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
 
-	nvme connect -t loop -n blktests-subsystem-1
+	_nvme_connect_subsys "loop" "blktests-subsystem-1"
 
 	local nvmedev
 	nvmedev="$(_find_nvme_loop_dev)"
@@ -42,7 +42,7 @@ test() {
 
 	echo 1 > "/sys/class/nvme/${nvmedev}/reset_controller"
 
-	nvme disconnect -d "${nvmedev}"
+	_nvme_disconnect_ctrl "${nvmedev}"
 	_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1"
 	_remove_nvmet_port "${port}"
 
diff --git a/tests/nvme/008 b/tests/nvme/008
index f19de17fefac..5ab5c49b2039 100755
--- a/tests/nvme/008
+++ b/tests/nvme/008
@@ -34,7 +34,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -42,7 +42,7 @@ test() {
 
 	udevadm settle
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/009 b/tests/nvme/009
index 4afbe62864f6..f6b999dea541 100755
--- a/tests/nvme/009
+++ b/tests/nvme/009
@@ -30,7 +30,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -38,7 +38,7 @@ test() {
 
 	udevadm settle
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/010 b/tests/nvme/010
index 53b97484615f..6caa2d0f813d 100755
--- a/tests/nvme/010
+++ b/tests/nvme/010
@@ -34,7 +34,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -42,7 +42,7 @@ test() {
 
 	_run_fio_verify_io --size=950m --filename="/dev/${nvmedev}n1"
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/011 b/tests/nvme/011
index a54583d5c582..7a5535982a74 100755
--- a/tests/nvme/011
+++ b/tests/nvme/011
@@ -32,7 +32,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -40,7 +40,7 @@ test() {
 
 	_run_fio_verify_io --size=950m --filename="/dev/${nvmedev}n1"
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/012 b/tests/nvme/012
index 0049c3d8ceb6..5c3477a16af9 100755
--- a/tests/nvme/012
+++ b/tests/nvme/012
@@ -38,7 +38,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -54,7 +54,7 @@ test() {
 
 	umount "${mount_dir}" > /dev/null 2>&1
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/013 b/tests/nvme/013
index 622706ec4088..49784a0d46b5 100755
--- a/tests/nvme/013
+++ b/tests/nvme/013
@@ -35,7 +35,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -51,7 +51,7 @@ test() {
 
 	umount "${mount_dir}" > /dev/null 2>&1
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/014 b/tests/nvme/014
index 9517230253ab..a33ff439fb3d 100755
--- a/tests/nvme/014
+++ b/tests/nvme/014
@@ -34,7 +34,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -44,7 +44,7 @@ test() {
 
 	nvme flush "/dev/${nvmedev}" -n 1
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/015 b/tests/nvme/015
index 40b850974b43..cb9792e13442 100755
--- a/tests/nvme/015
+++ b/tests/nvme/015
@@ -31,7 +31,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -41,7 +41,7 @@ test() {
 
 	nvme flush "/dev/${nvmedev}n1" -n 1
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/016 b/tests/nvme/016
index e1bad2f81461..1ad744abb9b0 100755
--- a/tests/nvme/016
+++ b/tests/nvme/016
@@ -33,7 +33,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "$port" "${subsys_nqn}"
 
-	nvme discover -t loop | _filter_discovery
+	_nvme_discover "loop" | _filter_discovery
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_nqn}"
 	_remove_nvmet_port "${port}"
 
diff --git a/tests/nvme/017 b/tests/nvme/017
index 2e6d649f9b65..2507bcd606b7 100755
--- a/tests/nvme/017
+++ b/tests/nvme/017
@@ -36,7 +36,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme discover -t loop | _filter_discovery
+	_nvme_discover "loop" | _filter_discovery
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_port "${port}"
 
diff --git a/tests/nvme/018 b/tests/nvme/018
index e39613709c90..4863274cc525 100755
--- a/tests/nvme/018
+++ b/tests/nvme/018
@@ -32,7 +32,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -46,7 +46,7 @@ test() {
 	nvme read "/dev/${nvmedev}n1" -s "$sectors" -c 0 -z "$bs" &>"$FULL" \
 		&& echo "ERROR: nvme read for out of range LBA was not rejected"
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/019 b/tests/nvme/019
index 86a2a2945b35..19c5b4755387 100755
--- a/tests/nvme/019
+++ b/tests/nvme/019
@@ -36,7 +36,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -44,7 +44,7 @@ test() {
 
 	nvme dsm "/dev/${nvmedev}" -n 1 -d -s "${sblk_range}" -b "${nblk_range}"
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/020 b/tests/nvme/020
index ccadec6a5822..0a817004225a 100755
--- a/tests/nvme/020
+++ b/tests/nvme/020
@@ -32,7 +32,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -40,7 +40,7 @@ test() {
 
 	nvme dsm "/dev/${nvmedev}" -n 1 -d -s "${sblk_range}" -b "${nblk_range}"
 
-	nvme disconnect -n "${subsys_name}"
+	_nvme_disconnect_subsys "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/021 b/tests/nvme/021
index bbcb9d56a350..ac3cbd17cd03 100755
--- a/tests/nvme/021
+++ b/tests/nvme/021
@@ -31,7 +31,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -41,7 +41,7 @@ test() {
 		echo "ERROR: device not listed"
 	fi
 
-	nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/022 b/tests/nvme/022
index 452e7b3d196c..4c91f98734fc 100755
--- a/tests/nvme/022
+++ b/tests/nvme/022
@@ -31,7 +31,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -41,7 +41,7 @@ test() {
 		echo "ERROR: reset failed"
 	fi
 
-	nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/023 b/tests/nvme/023
index 2714571d16d9..dcbe821f2709 100755
--- a/tests/nvme/023
+++ b/tests/nvme/023
@@ -34,7 +34,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -44,7 +44,7 @@ test() {
 		echo "ERROR: smart-log bdev-ns failed"
 	fi
 
-	nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/024 b/tests/nvme/024
index 1f87bd19ec69..0f4bddcb3142 100755
--- a/tests/nvme/024
+++ b/tests/nvme/024
@@ -31,7 +31,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -40,7 +40,7 @@ test() {
 	if ! nvme smart-log "/dev/${nvmedev}" -n 1 >> "$FULL" 2>&1; then
 		echo "ERROR: smart-log file-ns failed"
 	fi
-	nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/025 b/tests/nvme/025
index 1b9e33351f61..90896d327cff 100755
--- a/tests/nvme/025
+++ b/tests/nvme/025
@@ -31,7 +31,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -41,7 +41,7 @@ test() {
 		echo "ERROR: effects-log failed"
 	fi
 
-	nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/026 b/tests/nvme/026
index 21a265a630ba..39cfe12a23c7 100755
--- a/tests/nvme/026
+++ b/tests/nvme/026
@@ -31,7 +31,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -41,7 +41,7 @@ test() {
 		echo "ERROR: ns-desc failed"
 	fi
 
-	nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/027 b/tests/nvme/027
index d7d33796e122..5915c336a0cd 100755
--- a/tests/nvme/027
+++ b/tests/nvme/027
@@ -31,7 +31,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -40,7 +40,7 @@ test() {
 	if ! nvme ns-rescan "/dev/${nvmedev}" >> "$FULL" 2>&1; then
 		echo "ERROR: ns-rescan failed"
 	fi
-	nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/028 b/tests/nvme/028
index 1643857437e8..cf44102b3957 100755
--- a/tests/nvme/028
+++ b/tests/nvme/028
@@ -31,7 +31,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -40,7 +40,7 @@ test() {
 	if ! nvme list-subsys 2>> "$FULL" | grep -q loop; then
 		echo "ERROR: list-subsys"
 	fi
-	nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/029 b/tests/nvme/029
index 9f437285d085..192b5c52168c 100755
--- a/tests/nvme/029
+++ b/tests/nvme/029
@@ -67,7 +67,7 @@ test() {
 	port="$(_create_nvmet_port "loop")"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	nvme connect -t loop -n "${subsys_name}"
+	_nvme_connect_subsys "loop" "${subsys_name}"
 
 	nvmedev="$(_find_nvme_loop_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
@@ -81,7 +81,7 @@ test() {
 	test_user_io "$dev" 511 1023 > "$FULL" 2>&1 || echo FAIL
 	test_user_io "$dev" 511 1025 > "$FULL" 2>&1 || echo FAIL
 
-	nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1
+	_nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
 	_remove_nvmet_subsystem "${subsys_name}"
diff --git a/tests/nvme/031 b/tests/nvme/031
index 7e7ee7327e62..ab17633bc8fc 100755
--- a/tests/nvme/031
+++ b/tests/nvme/031
@@ -41,8 +41,8 @@ test() {
 	for ((i = 0; i < iterations; i++)); do
 		_create_nvmet_subsystem "${subsys}$i" "${loop_dev}"
 		_add_nvmet_subsys_to_port "${port}" "${subsys}$i"
-		nvme connect -t loop -n "${subsys}$i"
-		nvme disconnect -n "${subsys}$i" >> "${FULL}" 2>&1
+		_nvme_connect_subsys "loop" "${subsys}$i"
+		_nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1
 		_remove_nvmet_subsystem_from_port "${port}" "${subsys}$i"
 		_remove_nvmet_subsystem "${subsys}$i"
 	done
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 320aa4b2b475..6d57cf591300 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -64,7 +64,7 @@ _cleanup_nvmet() {
 		transport="$(cat "/sys/class/nvme/${dev}/transport")"
 		if [[ "$transport" == "loop" ]]; then
 			echo "WARNING: Test did not clean up loop device: ${dev}"
-			nvme disconnect -d "${dev}"
+			_nvme_disconnect_ctrl "${dev}"
 		fi
 	done
 
@@ -97,6 +97,33 @@ _setup_nvmet() {
 	modprobe nvme-loop
 }
 
+_nvme_disconnect_ctrl() {
+	local ctrl="$1"
+
+	nvme disconnect -d ${ctrl}
+}
+
+_nvme_disconnect_subsys() {
+	local subsysnqn="$1"
+
+	nvme disconnect -n ${subsysnqn}
+}
+
+_nvme_connect_subsys() {
+	local trtype="$1"
+	local subsysnqn="$2"
+
+	cmd="nvme connect -t ${trtype} -n ${subsysnqn}"
+	eval $cmd
+}
+
+_nvme_discover() {
+	local trtype="$1"
+
+	cmd="nvme discover -t ${trtype}"
+	eval $cmd
+}
+
 _create_nvmet_port() {
 	local trtype="$1"
 
@@ -206,6 +233,6 @@ _filter_discovery() {
 }
 
 _discovery_genctr() {
-	nvme discover -t loop |
+	_nvme_discover "loop" |
 		sed -n -e 's/^.*Generation counter \([0-9]\+\).*$/\1/p'
 }
-- 
2.25.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 3/7] nvme: make tests transport type agnostic
  2020-08-06 19:15 [PATCH v2 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
  2020-08-06 19:15 ` [PATCH v2 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
  2020-08-06 19:15 ` [PATCH v2 2/7] nvme: consolidate some nvme-cli utility functions Sagi Grimberg
@ 2020-08-06 19:15 ` Sagi Grimberg
  2020-08-07  3:09   ` Chaitanya Kulkarni
  2020-08-06 19:15 ` [PATCH v2 4/7] tests/nvme: restrict tests to specific transports Sagi Grimberg
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-06 19:15 UTC (permalink / raw)
  To: linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni

Pass in nvme_trtype to common routines that can
support multiple transport types.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 tests/nvme/002 |  4 ++--
 tests/nvme/003 |  4 ++--
 tests/nvme/004 |  6 +++---
 tests/nvme/005 |  6 +++---
 tests/nvme/006 |  2 +-
 tests/nvme/007 |  2 +-
 tests/nvme/008 |  6 +++---
 tests/nvme/009 |  6 +++---
 tests/nvme/010 |  6 +++---
 tests/nvme/011 |  6 +++---
 tests/nvme/012 |  6 +++---
 tests/nvme/013 |  6 +++---
 tests/nvme/014 |  6 +++---
 tests/nvme/015 |  6 +++---
 tests/nvme/016 |  2 +-
 tests/nvme/017 |  2 +-
 tests/nvme/018 |  6 +++---
 tests/nvme/019 |  6 +++---
 tests/nvme/020 |  6 +++---
 tests/nvme/021 |  6 +++---
 tests/nvme/022 |  6 +++---
 tests/nvme/023 |  6 +++---
 tests/nvme/024 |  6 +++---
 tests/nvme/025 |  6 +++---
 tests/nvme/026 |  6 +++---
 tests/nvme/027 |  6 +++---
 tests/nvme/028 |  8 ++++----
 tests/nvme/029 |  6 +++---
 tests/nvme/030 |  2 +-
 tests/nvme/031 |  4 ++--
 tests/nvme/rc  | 39 ++++++++++++++++++++++++++++++++-------
 31 files changed, 110 insertions(+), 85 deletions(-)

diff --git a/tests/nvme/002 b/tests/nvme/002
index 999e222705bf..8540623497c7 100755
--- a/tests/nvme/002
+++ b/tests/nvme/002
@@ -21,7 +21,7 @@ test() {
 
 	local iterations=1000
 	local port
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 
 	local loop_dev
 	loop_dev="$(losetup -f)"
@@ -31,7 +31,7 @@ test() {
 		_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-$i"
 	done
 
-	_nvme_discover "loop" | _filter_discovery
+	_nvme_discover "${nvme_trtype}" | _filter_discovery
 
 	for ((i = iterations - 1; i >= 0; i--)); do
 		_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-$i"
diff --git a/tests/nvme/003 b/tests/nvme/003
index 6ea6a23b7942..68f823011d7d 100755
--- a/tests/nvme/003
+++ b/tests/nvme/003
@@ -21,7 +21,7 @@ test() {
 	_setup_nvmet
 
 	local port
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port "${nvme_trtype}")"
 
 	local loop_dev
 	loop_dev="$(losetup -f)"
@@ -29,7 +29,7 @@ test() {
 	_create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}"
 	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
 
-	_nvme_connect_subsys "loop" "nqn.2014-08.org.nvmexpress.discovery"
+	_nvme_connect_subsys "${nvme_trtype}" "nqn.2014-08.org.nvmexpress.discovery"
 
 	# This is ugly but checking for the absence of error messages is ...
 	sleep 10
diff --git a/tests/nvme/004 b/tests/nvme/004
index 7ea539fda55e..af434674beaa 100755
--- a/tests/nvme/004
+++ b/tests/nvme/004
@@ -22,7 +22,7 @@ test() {
 	_setup_nvmet
 
 	local port
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 
 	truncate -s 1G "$TMPDIR/img"
 
@@ -33,10 +33,10 @@ test() {
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
 	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
 
-	_nvme_connect_subsys "loop" "blktests-subsystem-1"
+	_nvme_connect_subsys ${nvme_trtype} "blktests-subsystem-1"
 
 	local nvmedev
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/005 b/tests/nvme/005
index d4ce6d703c1b..ff0975ce7c28 100755
--- a/tests/nvme/005
+++ b/tests/nvme/005
@@ -22,7 +22,7 @@ test() {
 	_setup_nvmet
 
 	local port
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 
 	truncate -s 1G "$TMPDIR/img"
 
@@ -33,10 +33,10 @@ test() {
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
 	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
 
-	_nvme_connect_subsys "loop" "blktests-subsystem-1"
+	_nvme_connect_subsys ${nvme_trtype} "blktests-subsystem-1"
 
 	local nvmedev
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 
 	udevadm settle
 
diff --git a/tests/nvme/006 b/tests/nvme/006
index 3f47613d52d2..3f161d08bc22 100755
--- a/tests/nvme/006
+++ b/tests/nvme/006
@@ -29,7 +29,7 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
diff --git a/tests/nvme/007 b/tests/nvme/007
index 0902745a4ab2..b0e61186e886 100755
--- a/tests/nvme/007
+++ b/tests/nvme/007
@@ -28,7 +28,7 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
 	_remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
diff --git a/tests/nvme/008 b/tests/nvme/008
index 5ab5c49b2039..7ffac945a58a 100755
--- a/tests/nvme/008
+++ b/tests/nvme/008
@@ -31,12 +31,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/009 b/tests/nvme/009
index f6b999dea541..9ac5cb479983 100755
--- a/tests/nvme/009
+++ b/tests/nvme/009
@@ -27,12 +27,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/010 b/tests/nvme/010
index 6caa2d0f813d..d90ca9d88053 100755
--- a/tests/nvme/010
+++ b/tests/nvme/010
@@ -31,12 +31,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/011 b/tests/nvme/011
index 7a5535982a74..d8badbc00846 100755
--- a/tests/nvme/011
+++ b/tests/nvme/011
@@ -29,12 +29,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/012 b/tests/nvme/012
index 5c3477a16af9..93b6cfaf4c77 100755
--- a/tests/nvme/012
+++ b/tests/nvme/012
@@ -35,12 +35,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/013 b/tests/nvme/013
index 49784a0d46b5..3bae2f5edb3d 100755
--- a/tests/nvme/013
+++ b/tests/nvme/013
@@ -32,12 +32,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/014 b/tests/nvme/014
index a33ff439fb3d..b61e7182af66 100755
--- a/tests/nvme/014
+++ b/tests/nvme/014
@@ -31,12 +31,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \
 		 "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/015 b/tests/nvme/015
index cb9792e13442..05195e3bc598 100755
--- a/tests/nvme/015
+++ b/tests/nvme/015
@@ -28,12 +28,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		 "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/016 b/tests/nvme/016
index 1ad744abb9b0..a5ad973dc246 100755
--- a/tests/nvme/016
+++ b/tests/nvme/016
@@ -30,7 +30,7 @@ test() {
 		_create_nvmet_ns "${subsys_nqn}" "${i}" "${loop_dev}"
 	done
 
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "$port" "${subsys_nqn}"
 
 	_nvme_discover "loop" | _filter_discovery
diff --git a/tests/nvme/017 b/tests/nvme/017
index 2507bcd606b7..67d7ffc72e93 100755
--- a/tests/nvme/017
+++ b/tests/nvme/017
@@ -33,7 +33,7 @@ test() {
 		_create_nvmet_ns "${subsys_name}" "${i}" "${file_path}"
 	done
 
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
 	_nvme_discover "loop" | _filter_discovery
diff --git a/tests/nvme/018 b/tests/nvme/018
index 4863274cc525..43340d3c4d25 100755
--- a/tests/nvme/018
+++ b/tests/nvme/018
@@ -29,12 +29,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		 "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/019 b/tests/nvme/019
index 19c5b4755387..98d82ae21b42 100755
--- a/tests/nvme/019
+++ b/tests/nvme/019
@@ -33,12 +33,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/020 b/tests/nvme/020
index 0a817004225a..2d4c0152bc55 100755
--- a/tests/nvme/020
+++ b/tests/nvme/020
@@ -29,12 +29,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/021 b/tests/nvme/021
index ac3cbd17cd03..03b2ab749052 100755
--- a/tests/nvme/021
+++ b/tests/nvme/021
@@ -28,12 +28,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/022 b/tests/nvme/022
index 4c91f98734fc..977b844ee117 100755
--- a/tests/nvme/022
+++ b/tests/nvme/022
@@ -28,12 +28,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/023 b/tests/nvme/023
index dcbe821f2709..6c3b44174884 100755
--- a/tests/nvme/023
+++ b/tests/nvme/023
@@ -31,12 +31,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/024 b/tests/nvme/024
index 0f4bddcb3142..9b5f6a44a916 100755
--- a/tests/nvme/024
+++ b/tests/nvme/024
@@ -28,12 +28,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/025 b/tests/nvme/025
index 90896d327cff..9f0e9f722a02 100755
--- a/tests/nvme/025
+++ b/tests/nvme/025
@@ -28,12 +28,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/026 b/tests/nvme/026
index 39cfe12a23c7..e60e73b2c26a 100755
--- a/tests/nvme/026
+++ b/tests/nvme/026
@@ -28,12 +28,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/027 b/tests/nvme/027
index 5915c336a0cd..805a3c63eba2 100755
--- a/tests/nvme/027
+++ b/tests/nvme/027
@@ -28,12 +28,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/028 b/tests/nvme/028
index cf44102b3957..c9bd3dde7f20 100755
--- a/tests/nvme/028
+++ b/tests/nvme/028
@@ -28,16 +28,16 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
 		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
-	if ! nvme list-subsys 2>> "$FULL" | grep -q loop; then
+	if ! nvme list-subsys 2>> "$FULL" | grep -q ${nvme_trtype}; then
 		echo "ERROR: list-subsys"
 	fi
 	_nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1
diff --git a/tests/nvme/029 b/tests/nvme/029
index 192b5c52168c..7bf904b16edc 100755
--- a/tests/nvme/029
+++ b/tests/nvme/029
@@ -64,12 +64,12 @@ test() {
 
 	_create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \
 		 "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
 
-	_nvme_connect_subsys "loop" "${subsys_name}"
+	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev="$(_find_nvme_dev)"
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/030 b/tests/nvme/030
index 7156cad7b657..220b29f42962 100755
--- a/tests/nvme/030
+++ b/tests/nvme/030
@@ -37,7 +37,7 @@ test() {
 
     _setup_nvmet
 
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 
 	_create_nvmet_subsystem "${subsys}1" "$(losetup -f)"
 	_add_nvmet_subsys_to_port "${port}" "${subsys}1"
diff --git a/tests/nvme/031 b/tests/nvme/031
index ab17633bc8fc..001f9d2b0b3a 100755
--- a/tests/nvme/031
+++ b/tests/nvme/031
@@ -36,12 +36,12 @@ test() {
 
 	loop_dev="$(losetup -f --show "$TMPDIR/img")"
 
-	port="$(_create_nvmet_port "loop")"
+	port="$(_create_nvmet_port ${nvme_trtype})"
 
 	for ((i = 0; i < iterations; i++)); do
 		_create_nvmet_subsystem "${subsys}$i" "${loop_dev}"
 		_add_nvmet_subsys_to_port "${port}" "${subsys}$i"
-		_nvme_connect_subsys "loop" "${subsys}$i"
+		_nvme_connect_subsys ${nvme_trtype} "${subsys}$i"
 		_nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1
 		_remove_nvmet_subsystem_from_port "${port}" "${subsys}$i"
 		_remove_nvmet_subsystem "${subsys}$i"
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 6d57cf591300..191f0497416a 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -6,6 +6,9 @@
 
 . common/rc
 
+def_traddr="127.0.0.1"
+def_adrfam="ipv4"
+def_trsvcid="4420"
 nvme_trtype=${nvme_trtype:-"loop"}
 
 _nvme_requires() {
@@ -62,8 +65,8 @@ _cleanup_nvmet() {
 	for dev in /sys/class/nvme/nvme*; do
 		dev="$(basename "$dev")"
 		transport="$(cat "/sys/class/nvme/${dev}/transport")"
-		if [[ "$transport" == "loop" ]]; then
-			echo "WARNING: Test did not clean up loop device: ${dev}"
+		if [[ "$transport" == "${nvme_trtype}" ]]; then
+			echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}"
 			_nvme_disconnect_ctrl "${dev}"
 		fi
 	done
@@ -87,14 +90,20 @@ _cleanup_nvmet() {
 	shopt -u nullglob
 	trap SIGINT
 
-	modprobe -r nvme-loop 2>/dev/null
+	modprobe -r nvme-${nvme_trtype} 2>/dev/null
+	if [[ "${nvme_trtype}" != "loop" ]]; then
+		modprobe -r nvmet-${nvme_trtype} 2>/dev/null
+	fi
 	modprobe -r nvmet 2>/dev/null
 }
 
 _setup_nvmet() {
 	_register_test_cleanup _cleanup_nvmet
 	modprobe nvmet
-	modprobe nvme-loop
+	if [[ "${nvme_trtype}" != "loop" ]]; then
+		modprobe nvmet-${nvme_trtype}
+	fi
+	modprobe nvme-${nvme_trtype}
 }
 
 _nvme_disconnect_ctrl() {
@@ -112,20 +121,33 @@ _nvme_disconnect_subsys() {
 _nvme_connect_subsys() {
 	local trtype="$1"
 	local subsysnqn="$2"
+	local traddr="${3:-$def_traddr}"
+	local trsvcid="${4:-$def_trsvcid}"
 
 	cmd="nvme connect -t ${trtype} -n ${subsysnqn}"
+	if [[ "${trtype}" != "loop" ]]; then
+		cmd=$cmd" -a ${traddr} -s ${trsvcid}"
+	fi
 	eval $cmd
 }
 
 _nvme_discover() {
 	local trtype="$1"
+	local traddr="${2:-$def_traddr}"
+	local trsvcid="${3:-$def_trsvcid}"
 
 	cmd="nvme discover -t ${trtype}"
+	if [[ "${trtype}" != "loop" ]]; then
+		cmd=$cmd" -a ${traddr} -s ${trsvcid}"
+	fi
 	eval $cmd
 }
 
 _create_nvmet_port() {
 	local trtype="$1"
+	local traddr="${2:-$def_traddr}"
+	local adrfam="${3:-$def_adrfam}"
+	local trsvcid="${4:-$def_trsvcid}"
 
 	local port
 	for ((port = 0; ; port++)); do
@@ -136,6 +158,9 @@ _create_nvmet_port() {
 
 	mkdir "${NVMET_CFS}/ports/${port}"
 	echo "${trtype}" > "${NVMET_CFS}/ports/${port}/addr_trtype"
+	echo "${traddr}" > "${NVMET_CFS}/ports/${port}/addr_traddr"
+	echo "${adrfam}" > "${NVMET_CFS}/ports/${port}/addr_adrfam"
+	echo "${trsvcid}" > "${NVMET_CFS}/ports/${port}/addr_trsvcid"
 
 	echo "${port}"
 }
@@ -207,13 +232,13 @@ _remove_nvmet_subsystem_from_port() {
 	rm "${NVMET_CFS}/ports/${port}/subsystems/${nvmet_subsystem}"
 }
 
-_find_nvme_loop_dev() {
+_find_nvme_dev() {
 	local dev
 	local transport
 	for dev in /sys/class/nvme/nvme*; do
 		dev="$(basename "$dev")"
 		transport="$(cat "/sys/class/nvme/${dev}/transport")"
-		if [[ "$transport" == "loop" ]]; then
+		if [[ "$transport" == "${nvme_trtype}" ]]; then
 			echo "$dev"
 			for ((i = 0; i < 10; i++)); do
 				if [[ -e /sys/block/$dev/uuid &&
@@ -233,6 +258,6 @@ _filter_discovery() {
 }
 
 _discovery_genctr() {
-	_nvme_discover "loop" |
+	_nvme_discover "${nvme_trtype}" |
 		sed -n -e 's/^.*Generation counter \([0-9]\+\).*$/\1/p'
 }
-- 
2.25.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 4/7] tests/nvme: restrict tests to specific transports
  2020-08-06 19:15 [PATCH v2 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (2 preceding siblings ...)
  2020-08-06 19:15 ` [PATCH v2 3/7] nvme: make tests transport type agnostic Sagi Grimberg
@ 2020-08-06 19:15 ` Sagi Grimberg
  2020-08-07  3:15   ` Chaitanya Kulkarni
  2020-08-06 19:15 ` [PATCH v2 5/7] nvme: support nvme-tcp when runinng tests Sagi Grimberg
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-06 19:15 UTC (permalink / raw)
  To: linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni

Protect against running tests with the wrong transport type. Most tests
cannot have nvme_trtype=nvme and discovery tests expect the $trtype to
be written and verified in the .out file. Adding a couple of helpers
to restrict the transport types in tests.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 tests/nvme/002 |  1 +
 tests/nvme/003 |  1 +
 tests/nvme/004 |  1 +
 tests/nvme/005 |  1 +
 tests/nvme/006 |  1 +
 tests/nvme/007 |  1 +
 tests/nvme/008 |  1 +
 tests/nvme/009 |  1 +
 tests/nvme/010 |  1 +
 tests/nvme/011 |  1 +
 tests/nvme/012 |  1 +
 tests/nvme/013 |  1 +
 tests/nvme/014 |  1 +
 tests/nvme/015 |  1 +
 tests/nvme/016 |  1 +
 tests/nvme/017 |  1 +
 tests/nvme/018 |  1 +
 tests/nvme/019 |  1 +
 tests/nvme/020 |  1 +
 tests/nvme/021 |  1 +
 tests/nvme/022 |  1 +
 tests/nvme/023 |  1 +
 tests/nvme/024 |  1 +
 tests/nvme/025 |  1 +
 tests/nvme/026 |  1 +
 tests/nvme/027 |  1 +
 tests/nvme/028 |  1 +
 tests/nvme/029 |  1 +
 tests/nvme/030 |  1 +
 tests/nvme/031 |  1 +
 tests/nvme/rc  | 16 ++++++++++++++++
 31 files changed, 46 insertions(+)

diff --git a/tests/nvme/002 b/tests/nvme/002
index 8540623497c7..8cfcb75e5142 100755
--- a/tests/nvme/002
+++ b/tests/nvme/002
@@ -12,6 +12,7 @@ DESCRIPTION="create many subsystems and test discovery"
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_loop
 }
 
 test() {
diff --git a/tests/nvme/003 b/tests/nvme/003
index 68f823011d7d..09d4c50bef2f 100755
--- a/tests/nvme/003
+++ b/tests/nvme/003
@@ -13,6 +13,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/004 b/tests/nvme/004
index af434674beaa..9e40b08ca595 100755
--- a/tests/nvme/004
+++ b/tests/nvme/004
@@ -14,6 +14,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/005 b/tests/nvme/005
index ff0975ce7c28..68dc9311e9de 100755
--- a/tests/nvme/005
+++ b/tests/nvme/005
@@ -14,6 +14,7 @@ requires() {
 	_nvme_requires
 	_have_modules loop && \
 		_have_module_param_value nvme_core multipath Y
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/006 b/tests/nvme/006
index 3f161d08bc22..82809379b5d4 100755
--- a/tests/nvme/006
+++ b/tests/nvme/006
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/007 b/tests/nvme/007
index b0e61186e886..747e7402ee7d 100755
--- a/tests/nvme/007
+++ b/tests/nvme/007
@@ -11,6 +11,7 @@ QUICK=1
 
 requires() {
 	_nvme_requires
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/008 b/tests/nvme/008
index 7ffac945a58a..9f17fcfe801a 100755
--- a/tests/nvme/008
+++ b/tests/nvme/008
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/009 b/tests/nvme/009
index 9ac5cb479983..017b06e13637 100755
--- a/tests/nvme/009
+++ b/tests/nvme/009
@@ -11,6 +11,7 @@ QUICK=1
 
 requires() {
 	_nvme_requires
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/010 b/tests/nvme/010
index d90ca9d88053..426276c87ed1 100755
--- a/tests/nvme/010
+++ b/tests/nvme/010
@@ -12,6 +12,7 @@ TIMED=1
 requires() {
 	_nvme_requires
 	_have_fio _have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/011 b/tests/nvme/011
index d8badbc00846..d799af0ba6f4 100755
--- a/tests/nvme/011
+++ b/tests/nvme/011
@@ -12,6 +12,7 @@ TIMED=1
 requires() {
 	_nvme_requires
 	_have_fio
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/012 b/tests/nvme/012
index 93b6cfaf4c77..b9848eb0b0ee 100755
--- a/tests/nvme/012
+++ b/tests/nvme/012
@@ -13,6 +13,7 @@ requires() {
 	_nvme_requires
 	_have_program mkfs.xfs && _have_program fio && \
 		_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/013 b/tests/nvme/013
index 3bae2f5edb3d..df462f165a8d 100755
--- a/tests/nvme/013
+++ b/tests/nvme/013
@@ -12,6 +12,7 @@ TIMED=1
 requires() {
 	_nvme_requires
 	_have_program mkfs.xfs && _have_fio
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/014 b/tests/nvme/014
index b61e7182af66..9a9292a9d309 100755
--- a/tests/nvme/014
+++ b/tests/nvme/014
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/015 b/tests/nvme/015
index 05195e3bc598..600e625d341d 100755
--- a/tests/nvme/015
+++ b/tests/nvme/015
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/016 b/tests/nvme/016
index a5ad973dc246..8ba0a895fbff 100755
--- a/tests/nvme/016
+++ b/tests/nvme/016
@@ -10,6 +10,7 @@ DESCRIPTION="create/delete many NVMeOF block device-backed ns and test discovery
 
 requires() {
 	_nvme_requires
+	_require_nvme_trtype_is_loop
 }
 
 test() {
diff --git a/tests/nvme/017 b/tests/nvme/017
index 67d7ffc72e93..36b14f677449 100755
--- a/tests/nvme/017
+++ b/tests/nvme/017
@@ -10,6 +10,7 @@ DESCRIPTION="create/delete many file-ns and test discovery"
 
 requires() {
 	_nvme_requires
+	_require_nvme_trtype_is_loop
 }
 
 test() {
diff --git a/tests/nvme/018 b/tests/nvme/018
index 43340d3c4d25..9059b2557efa 100755
--- a/tests/nvme/018
+++ b/tests/nvme/018
@@ -13,6 +13,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/019 b/tests/nvme/019
index 98d82ae21b42..ca7954953fd8 100755
--- a/tests/nvme/019
+++ b/tests/nvme/019
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/020 b/tests/nvme/020
index 2d4c0152bc55..39d08439f113 100755
--- a/tests/nvme/020
+++ b/tests/nvme/020
@@ -11,6 +11,7 @@ QUICK=1
 
 requires() {
 	_nvme_requires
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/021 b/tests/nvme/021
index 03b2ab749052..918be51d2087 100755
--- a/tests/nvme/021
+++ b/tests/nvme/021
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/022 b/tests/nvme/022
index 977b844ee117..a03e83500b47 100755
--- a/tests/nvme/022
+++ b/tests/nvme/022
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/023 b/tests/nvme/023
index 6c3b44174884..c1ef8e08a31d 100755
--- a/tests/nvme/023
+++ b/tests/nvme/023
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/024 b/tests/nvme/024
index 9b5f6a44a916..bf7416f908e9 100755
--- a/tests/nvme/024
+++ b/tests/nvme/024
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/025 b/tests/nvme/025
index 9f0e9f722a02..8f8e472ab3ce 100755
--- a/tests/nvme/025
+++ b/tests/nvme/025
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/026 b/tests/nvme/026
index e60e73b2c26a..f1f8878793ce 100755
--- a/tests/nvme/026
+++ b/tests/nvme/026
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/027 b/tests/nvme/027
index 805a3c63eba2..53766775e096 100755
--- a/tests/nvme/027
+++ b/tests/nvme/027
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/028 b/tests/nvme/028
index c9bd3dde7f20..6fbf0d6d7938 100755
--- a/tests/nvme/028
+++ b/tests/nvme/028
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/029 b/tests/nvme/029
index 7bf904b16edc..7a4fd8d6d4c5 100755
--- a/tests/nvme/029
+++ b/tests/nvme/029
@@ -13,6 +13,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test_user_io()
diff --git a/tests/nvme/030 b/tests/nvme/030
index 220b29f42962..44f3b56dec4e 100755
--- a/tests/nvme/030
+++ b/tests/nvme/030
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 
diff --git a/tests/nvme/031 b/tests/nvme/031
index 001f9d2b0b3a..a5714982b5d9 100755
--- a/tests/nvme/031
+++ b/tests/nvme/031
@@ -20,6 +20,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_not_pci
 }
 
 test() {
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 191f0497416a..a2cb0c0add93 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -46,6 +46,22 @@ _require_test_dev_is_nvme() {
 	return 0
 }
 
+_require_nvme_trtype_is_loop() {
+	if [[ "${nvme_trtype}" != "loop" ]]; then
+		SKIP_REASON="nvme_trtype=${nvme_trtype} is not supported in this test"
+		return 1
+	fi
+	return 0
+}
+
+_require_nvme_trtype_not_pci() {
+	if [[ "${nvme_trtype}" == "pci" ]]; then
+		SKIP_REASON="nvme_trtype=${nvme_trtype} is not supported in this test"
+		return 1
+	fi
+	return 0
+}
+
 _cleanup_nvmet() {
 	local dev
 	local port
-- 
2.25.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 5/7] nvme: support nvme-tcp when runinng tests
  2020-08-06 19:15 [PATCH v2 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (3 preceding siblings ...)
  2020-08-06 19:15 ` [PATCH v2 4/7] tests/nvme: restrict tests to specific transports Sagi Grimberg
@ 2020-08-06 19:15 ` Sagi Grimberg
  2020-08-07  3:16   ` Chaitanya Kulkarni
  2020-08-06 19:15 ` [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload Sagi Grimberg
  2020-08-06 19:15 ` [PATCH v2 7/7] nvme: support rdma transport type Sagi Grimberg
  6 siblings, 1 reply; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-06 19:15 UTC (permalink / raw)
  To: linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni

run with: nvme_trtype=tcp ./check test/nvme

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 tests/nvme/rc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/nvme/rc b/tests/nvme/rc
index a2cb0c0add93..69ab7d2f3964 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -21,6 +21,10 @@ _nvme_requires() {
 	pci)
 		_have_modules nvme nvme-core
 		;;
+	tcp)
+		_have_modules nvmet nvme-core nvme-tcp nvmet-tcp
+		_have_configfs
+		;;
 	*)
 		SKIP_REASON="unsupported nvme_trtype=${nvme_trtype}"
 		return 1
-- 
2.25.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload
  2020-08-06 19:15 [PATCH v2 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (4 preceding siblings ...)
  2020-08-06 19:15 ` [PATCH v2 5/7] nvme: support nvme-tcp when runinng tests Sagi Grimberg
@ 2020-08-06 19:15 ` Sagi Grimberg
  2020-08-07  3:18   ` Chaitanya Kulkarni
  2020-08-07 14:03   ` Bart Van Assche
  2020-08-06 19:15 ` [PATCH v2 7/7] nvme: support rdma transport type Sagi Grimberg
  6 siblings, 2 replies; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-06 19:15 UTC (permalink / raw)
  To: linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni

There is no need to retry module unload for rdma_rxe
and siw. This also creates a dependency on
tests/nvmeof/rc which prevents it from using in
other test subsystems.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 common/multipath-over-rdma | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/multipath-over-rdma b/common/multipath-over-rdma
index 676d2837fb06..e54b2a96153c 100644
--- a/common/multipath-over-rdma
+++ b/common/multipath-over-rdma
@@ -457,7 +457,7 @@ stop_soft_rdma() {
 				fi
 			done
 	)
-	if ! unload_module rdma_rxe 10; then
+	if ! modprobe -r rdma_rxe; then
 		echo "Unloading rdma_rxe failed"
 		return 1
 	fi
@@ -469,7 +469,7 @@ stop_soft_rdma() {
 					echo "Failed to unbind the siw driver from ${i%_siw}"
 			done
 	)
-	if ! unload_module siw 10; then
+	if ! modprobe -r siw; then
 		echo "Unloading siw failed"
 		return 1
 	fi
-- 
2.25.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 7/7] nvme: support rdma transport type
  2020-08-06 19:15 [PATCH v2 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (5 preceding siblings ...)
  2020-08-06 19:15 ` [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload Sagi Grimberg
@ 2020-08-06 19:15 ` Sagi Grimberg
  6 siblings, 0 replies; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-06 19:15 UTC (permalink / raw)
  To: linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 tests/nvme/rc | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tests/nvme/rc b/tests/nvme/rc
index 69ab7d2f3964..31d02fefa70e 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -5,6 +5,7 @@
 # Test specific to NVMe devices
 
 . common/rc
+. common/multipath-over-rdma
 
 def_traddr="127.0.0.1"
 def_adrfam="ipv4"
@@ -25,6 +26,12 @@ _nvme_requires() {
 		_have_modules nvmet nvme-core nvme-tcp nvmet-tcp
 		_have_configfs
 		;;
+	rdma)
+		_have_modules nvmet nvme-core nvme-rdma nvmet-rdma
+		_have_configfs
+		_have_program rdma
+		_have_modules rdma_rxe siw
+		;;
 	*)
 		SKIP_REASON="unsupported nvme_trtype=${nvme_trtype}"
 		return 1
@@ -115,6 +122,9 @@ _cleanup_nvmet() {
 		modprobe -r nvmet-${nvme_trtype} 2>/dev/null
 	fi
 	modprobe -r nvmet 2>/dev/null
+	if [[ "${nvme_trtype}" == "rdma" ]]; then
+		stop_soft_rdma
+	fi
 }
 
 _setup_nvmet() {
@@ -124,6 +134,11 @@ _setup_nvmet() {
 		modprobe nvmet-${nvme_trtype}
 	fi
 	modprobe nvme-${nvme_trtype}
+	if [[ "${nvme_trtype}" == "rdma" ]]; then
+		start_soft_rdma
+		rdma_intfs=$(rdma_network_interfaces)
+		def_traddr=$(get_ipv4_addr ${rdma_intfs[0]})
+	fi
 }
 
 _nvme_disconnect_ctrl() {
-- 
2.25.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 1/7] nvme: consolidate nvme requirements based on transport type
  2020-08-06 19:15 ` [PATCH v2 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
@ 2020-08-07  2:41   ` Chaitanya Kulkarni
  2020-08-07 17:14     ` Sagi Grimberg
  0 siblings, 1 reply; 26+ messages in thread
From: Chaitanya Kulkarni @ 2020-08-07  2:41 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig

On 8/6/20 12:15, Sagi Grimberg wrote:
>   
> diff --git a/tests/nvme/rc b/tests/nvme/rc
> index 6ffa971b4308..320aa4b2b475 100644
> --- a/tests/nvme/rc
> +++ b/tests/nvme/rc
> @@ -6,6 +6,25 @@
>   
>   . common/rc
>   
> +nvme_trtype=${nvme_trtype:-"loop"}
> +
> +_nvme_requires() {
> +	_have_program nvme
> +	case ${nvme_trtype} in
> +	loop)
> +		_have_modules nvmet nvme-core nvme-loop
> +		_have_configfs
We should just move nvmet nvme-core configfs _have_nvme_fabrics_common
which are common for all the transports to avoid the duplication.
> +		;;
> +	pci)
> +		_have_modules nvme nvme-core
> +		;;
> +	*)
> +		SKIP_REASON="unsupported nvme_trtype=${nvme_trtype}"
> +		return 1
> +	esac
> +	return 0
> +}
> +
>   group_requires() {
>   	_have_root
>   }
> -- 2.25.1

Apart from that it looks good to me, I've not tested this yet though.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 2/7] nvme: consolidate some nvme-cli utility functions
  2020-08-06 19:15 ` [PATCH v2 2/7] nvme: consolidate some nvme-cli utility functions Sagi Grimberg
@ 2020-08-07  2:53   ` Chaitanya Kulkarni
  2020-08-07 17:15     ` Sagi Grimberg
  0 siblings, 1 reply; 26+ messages in thread
From: Chaitanya Kulkarni @ 2020-08-07  2:53 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig

On 8/6/20 12:15, Sagi Grimberg wrote:
>   
> @@ -97,6 +97,33 @@ _setup_nvmet() {
>   	modprobe nvme-loop
>   }
>   
> +_nvme_disconnect_ctrl() {
> +	local ctrl="$1"
> +
> +	nvme disconnect -d ${ctrl}
> +}
> +
> +_nvme_disconnect_subsys() {
> +	local subsysnqn="$1"
> +
> +	nvme disconnect -n ${subsysnqn}
> +}
> +
> +_nvme_connect_subsys() {
> +	local trtype="$1"
> +	local subsysnqn="$2"
> +
> +	cmd="nvme connect -t ${trtype} -n ${subsysnqn}"
> +	eval $cmd
> +}
> +
> +_nvme_discover() {
> +	local trtype="$1"
> +
> +	cmd="nvme discover -t ${trtype}"
> +	eval $cmd
> +}
> +
>   _create_nvmet_port() {
>   	local trtype="$1"
>   
> @@ -206,6 +233,6 @@ _filter_discovery() {
>   }
>   
>   _discovery_genctr() {
> -	nvme discover -t loop |
> +	_nvme_discover "loop" |
>   		sed -n -e 's/^.*Generation counter \([0-9]\+\).*$/\1/p'
>   }
> -- 2.25.1

I'm okay with having a wrapper for disconnect but for connect and 
discover command it can have many arguments having a call in the
test-case might loose the readability.

The downside is it will need argument count handling in the future
and makes things not easier when user want to skip certain
parameters, closest example would be _create_nvmet_ns().

Also if we are adding wrappers why not move $FULL 2>&1 to avoid
duplication ?

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 3/7] nvme: make tests transport type agnostic
  2020-08-06 19:15 ` [PATCH v2 3/7] nvme: make tests transport type agnostic Sagi Grimberg
@ 2020-08-07  3:09   ` Chaitanya Kulkarni
  2020-08-07 17:19     ` Sagi Grimberg
  0 siblings, 1 reply; 26+ messages in thread
From: Chaitanya Kulkarni @ 2020-08-07  3:09 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig

On 8/6/20 12:15, Sagi Grimberg wrote:
> Pass in nvme_trtype to common routines that can
> support multiple transport types.
> 
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
> ---
>   tests/nvme/002 |  4 ++--
>   tests/nvme/003 |  4 ++--
>   tests/nvme/004 |  6 +++---
>   tests/nvme/005 |  6 +++---
>   tests/nvme/006 |  2 +-
>   tests/nvme/007 |  2 +-
>   tests/nvme/008 |  6 +++---
>   tests/nvme/009 |  6 +++---
>   tests/nvme/010 |  6 +++---
>   tests/nvme/011 |  6 +++---
>   tests/nvme/012 |  6 +++---
>   tests/nvme/013 |  6 +++---
>   tests/nvme/014 |  6 +++---
>   tests/nvme/015 |  6 +++---
>   tests/nvme/016 |  2 +-
>   tests/nvme/017 |  2 +-
>   tests/nvme/018 |  6 +++---
>   tests/nvme/019 |  6 +++---
>   tests/nvme/020 |  6 +++---
>   tests/nvme/021 |  6 +++---
>   tests/nvme/022 |  6 +++---
>   tests/nvme/023 |  6 +++---
>   tests/nvme/024 |  6 +++---
>   tests/nvme/025 |  6 +++---
>   tests/nvme/026 |  6 +++---
>   tests/nvme/027 |  6 +++---
>   tests/nvme/028 |  8 ++++----
>   tests/nvme/029 |  6 +++---
>   tests/nvme/030 |  2 +-
>   tests/nvme/031 |  4 ++--
>   tests/nvme/rc  | 39 ++++++++++++++++++++++++++++++++-------
>   31 files changed, 110 insertions(+), 85 deletions(-)
> 
> diff --git a/tests/nvme/002 b/tests/nvme/002
> index 999e222705bf..8540623497c7 100755
> --- a/tests/nvme/002
> +++ b/tests/nvme/002
> @@ -21,7 +21,7 @@ test() {
>   
>   	local iterations=1000
>   	local port
> -	port="$(_create_nvmet_port "loop")"
> +	port="$(_create_nvmet_port ${nvme_trtype})"
Is there a way to directly use nvme_trtype especially in rc ?
if not disregard this comment.
>   
>   	local loop_dev
>   	loop_dev="$(losetup -f)"
> @@ -31,7 +31,7 @@ test() {
>   		_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-$i"
>   	done
>   
> -	_nvme_discover "loop" | _filter_discovery
> +	_nvme_discover "${nvme_trtype}" | _filter_discovery
Same here for nvme_trtype.
>   
>   	for ((i = iterations - 1; i >= 0; i--)); do
>   		_remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-$i"
> diff --git a/tests/nvme/003 b/tests/nvme/003
> index 6ea6a23b7942..68f823011d7d 100755
> --- a/tests/nvme/003
> +++ b/tests/nvme/003
> @@ -21,7 +21,7 @@ test() {
>   	_setup_nvmet
>   
>   	local port
> -	port="$(_create_nvmet_port "loop")"
> +	port="$(_create_nvmet_port "${nvme_trtype}")"
>   
>   	local loop_dev
>   	loop_dev="$(losetup -f)"
> @@ -29,7 +29,7 @@ test() {
>   	_create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}"
>   	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
>   
> -	_nvme_connect_subsys "loop" "nqn.2014-08.org.nvmexpress.discovery"
> +	_nvme_connect_subsys "${nvme_trtype}" "nqn.2014-08.org.nvmexpress.discovery"
>   
Same here for nvme_trtype.
>   	# This is ugly but checking for the absence of error messages is ...
>   	sleep 10
> diff --git a/tests/nvme/004 b/tests/nvme/004

> diff --git a/tests/nvme/018 b/tests/nvme/018
> index 4863274cc525..43340d3c4d25 100755
> --- a/tests/nvme/018
> +++ b/tests/nvme/018
> @@ -29,12 +29,12 @@ test() {
>   
>   	_create_nvmet_subsystem "${subsys_name}" "${file_path}" \
>   		 "91fdba0d-f87b-4c25-b80f-db7be1418b9e"
> -	port="$(_create_nvmet_port "loop")"
> +	port="$(_create_nvmet_port ${nvme_trtype})"
>   	_add_nvmet_subsys_to_port "${port}" "${subsys_name}"
>   
> -	_nvme_connect_subsys "loop" "${subsys_name}"
> +	_nvme_connect_subsys ${nvme_trtype} "${subsys_name}"
>   
> -	nvmedev="$(_find_nvme_loop_dev)"
> +	nvmedev="$(_find_nvme_dev)"
>   	cat "/sys/block/${nvmedev}n1/uuid"
>   	cat "/sys/block/${nvmedev}n1/wwid"
>   
> diff --git a/tests/nvme/019 b/tests/nvme/019
> index 19c5b4755387..98d82ae21b42 100755
> --- a/tests/nvme/019
> +++ b/tests/nvme/019
> @@ -33,12 +33,12 @@ test() {
>   
>   	_create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \
>   		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
> -	port="$(_create_nvmet_port "loop")"
> +	port="$(_create_nvmet_port ${nvme_trtype})"> diff --git a/tests/nvme/004 b/tests/nvme/004
> index 7ea539fda55e..af434674beaa 100755
> --- a/tests/nvme/004
> +++ b/tests/nvme/004
> @@ -22,7 +22,7 @@ test() {
>   	_setup_nvmet
>   
>   	local port
> -	port="$(_create_nvmet_port "loop")"
> +	port="$(_create_nvmet_port ${nvme_trtype})"
>   
>   	truncate -s 1G "$TMPDIR/img"
>   
> @@ -33,10 +33,10 @@ test() {
>   		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
>   	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
>   
> -	_nvme_connect_subsys "loop" "blktests-subsystem-1"
> +	_nvme_connect_subsys ${nvme_trtype} "blktests-subsystem-1"
>   
>   	local nvmedev
> -	nvmedev="$(_find_nvme_loop_dev)"
> +	nvmedev="$(_find_nvme_dev)"
>   	cat "/sys/block/${nvmedev}n1/uuid"
>   	cat "/sys/block/${nvmedev}n1/wwid"

Since we are touching nvmedev can we move above uuid and wwid to
a wrapper something like _nvme_show_uuid_wwid ${nvmedev}n1 ?

>
> @@ -36,12 +36,12 @@ test() {
>   
>   	loop_dev="$(losetup -f --show "$TMPDIR/img")"
>   
> -	port="$(_create_nvmet_port "loop")"
> +	port="$(_create_nvmet_port ${nvme_trtype})"
>   
>   	for ((i = 0; i < iterations; i++)); do
>   		_create_nvmet_subsystem "${subsys}$i" "${loop_dev}"
>   		_add_nvmet_subsys_to_port "${port}" "${subsys}$i"
> -		_nvme_connect_subsys "loop" "${subsys}$i"
> +		_nvme_connect_subsys ${nvme_trtype} "${subsys}$i"
Same here for nvme_trtype as first comment.
>   		_nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1
>   		_remove_nvmet_subsystem_from_port "${port}" "${subsys}$i"
>   		_remove_nvmet_subsystem "${subsys}$i"
> diff --git a/tests/nvme/rc b/tests/nvme/rc
> index 6d57cf591300..191f0497416a 100644
> --- a/tests/nvme/rc
> +++ b/tests/nvme/rc
> @@ -6,6 +6,9 @@
>   
>   . common/rc
>   
> +def_traddr="127.0.0.1"
> +def_adrfam="ipv4"
> +def_trsvcid="4420"
>   nvme_trtype=${nvme_trtype:-"loop"}
>   
>   _nvme_requires() {
> @@ -62,8 +65,8 @@ _cleanup_nvmet() {
>   	for dev in /sys/class/nvme/nvme*; do
>   		dev="$(basename "$dev")"
>   		transport="$(cat "/sys/class/nvme/${dev}/transport")"
> -		if [[ "$transport" == "loop" ]]; then
> -			echo "WARNING: Test did not clean up loop device: ${dev}"
> +		if [[ "$transport" == "${nvme_trtype}" ]]; then
> +			echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}"
>   			_nvme_disconnect_ctrl "${dev}"
>   		fi
>   	done
> @@ -87,14 +90,20 @@ _cleanup_nvmet() {
>   	shopt -u nullglob
>   	trap SIGINT
>   
> -	modprobe -r nvme-loop 2>/dev/null
> +	modprobe -r nvme-${nvme_trtype} 2>/dev/null
> +	if [[ "${nvme_trtype}" != "loop" ]]; then
> +		modprobe -r nvmet-${nvme_trtype} 2>/dev/null
This is not from your patch but I'd keep the error message it has
turned out to be useful for me when debugging refcount problem 
especially unload and load scenario.

> +	fi
>   	modprobe -r nvmet 2>/dev/null
>   }
>   
>   _setup_nvmet() {
>   	_register_test_cleanup _cleanup_nvmet
>   	modprobe nvmet
> -	modprobe nvme-loop
> +	if [[ "${nvme_trtype}" != "loop" ]]; then
> +		modprobe nvmet-${nvme_trtype}
> +	fi
> +	modprobe nvme-${nvme_trtype}
>   }
>   
>   _nvme_disconnect_ctrl() {
> @@ -112,20 +121,33 @@ _nvme_disconnect_subsys() {
>   _nvme_connect_subsys() {
>   	local trtype="$1"
>   	local subsysnqn="$2"
> +	local traddr="${3:-$def_traddr}"
> +	local trsvcid="${4:-$def_trsvcid}"
>   
>   	cmd="nvme connect -t ${trtype} -n ${subsysnqn}"
> +	if [[ "${trtype}" != "loop" ]]; then
> +		cmd=$cmd" -a ${traddr} -s ${trsvcid}"
> +	fi
>   	eval $cmd
>   }
>   
>   _nvme_discover() {
>   	local trtype="$1"
> +	local traddr="${2:-$def_traddr}"
> +	local trsvcid="${3:-$def_trsvcid}"
>   
>   	cmd="nvme discover -t ${trtype}"
> +	if [[ "${trtype}" != "loop" ]]; then
> +		cmd=$cmd" -a ${traddr} -s ${trsvcid}"
> +	fi
>   	eval $cmd
>   }
>   
>   _create_nvmet_port() {
>   	local trtype="$1"
> +	local traddr="${2:-$def_traddr}"
> +	local adrfam="${3:-$def_adrfam}"
> +	local trsvcid="${4:-$def_trsvcid}"
>   
>   	local port
>   	for ((port = 0; ; port++)); do
> @@ -136,6 +158,9 @@ _create_nvmet_port() {
>   
>   	mkdir "${NVMET_CFS}/ports/${port}"
>   	echo "${trtype}" > "${NVMET_CFS}/ports/${port}/addr_trtype"
> +	echo "${traddr}" > "${NVMET_CFS}/ports/${port}/addr_traddr"
> +	echo "${adrfam}" > "${NVMET_CFS}/ports/${port}/addr_adrfam"
> +	echo "${trsvcid}" > "${NVMET_CFS}/ports/${port}/addr_trsvcid"

Do we need argument count check before we apply these to configfs ?
>   
>   	echo "${port}"
>   }
> @@ -207,13 +232,13 @@ _remove_nvmet_subsystem_from_port() {
>   	rm "${NVMET_CFS}/ports/${port}/subsystems/${nvmet_subsystem}"
>   }
>   
> -_find_nvme_loop_dev() {
> +_find_nvme_dev() {
>   	local dev
>   	local transport
>   	for dev in /sys/class/nvme/nvme*; do
>   		dev="$(basename "$dev")"
>   		transport="$(cat "/sys/class/nvme/${dev}/transport")"
> -		if [[ "$transport" == "loop" ]]; then
> +		if [[ "$transport" == "${nvme_trtype}" ]]; then
>   			echo "$dev"
>   			for ((i = 0; i < 10; i++)); do
>   				if [[ -e /sys/block/$dev/uuid &&
> @@ -233,6 +258,6 @@ _filter_discovery() {
>   }
>   
>   _discovery_genctr() {
> -	_nvme_discover "loop" |
> +	_nvme_discover "${nvme_trtype}" |
>   		sed -n -e 's/^.*Generation counter \([0-9]\+\).*$/\1/p'
>   }
> 


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 4/7] tests/nvme: restrict tests to specific transports
  2020-08-06 19:15 ` [PATCH v2 4/7] tests/nvme: restrict tests to specific transports Sagi Grimberg
@ 2020-08-07  3:15   ` Chaitanya Kulkarni
  2020-08-07 17:21     ` Sagi Grimberg
  0 siblings, 1 reply; 26+ messages in thread
From: Chaitanya Kulkarni @ 2020-08-07  3:15 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig

On 8/6/20 12:15, Sagi Grimberg wrote:
> diff --git a/tests/nvme/027 b/tests/nvme/027
> index 805a3c63eba2..53766775e096 100755
> --- a/tests/nvme/027
> +++ b/tests/nvme/027
> @@ -12,6 +12,7 @@ QUICK=1
>   requires() {
>   	_nvme_requires
>   	_have_modules loop
> +	_require_nvme_trtype_not_pci
>   }
>   
>   test() {
> diff --git a/tests/nvme/028 b/tests/nvme/028
> index c9bd3dde7f20..6fbf0d6d7938 100755
> --- a/tests/nvme/028
> +++ b/tests/nvme/028
> @@ -12,6 +12,7 @@ QUICK=1
>   requires() {
>   	_nvme_requires
>   	_have_modules loop
> +	_require_nvme_trtype_not_pci
>   }
>   
>   test() {
> diff --git a/tests/nvme/029 b/tests/nvme/029
> index 7bf904b16edc..7a4fd8d6d4c5 100755
> --- a/tests/nvme/029
> +++ b/tests/nvme/029
> @@ -13,6 +13,7 @@ QUICK=1
>   requires() {
>   	_nvme_requires
>   	_have_modules loop
> +	_require_nvme_trtype_not_pci
>   }
>   
>   test_user_io()
> diff --git a/tests/nvme/030 b/tests/nvme/030
> index 220b29f42962..44f3b56dec4e 100755
> --- a/tests/nvme/030
> +++ b/tests/nvme/030
> @@ -12,6 +12,7 @@ QUICK=1
>   requires() {
>   	_nvme_requires
>   	_have_modules loop
> +	_require_nvme_trtype_not_pci
>   }
>   
>   
> diff --git a/tests/nvme/031 b/tests/nvme/031
> index 001f9d2b0b3a..a5714982b5d9 100755
> --- a/tests/nvme/031
> +++ b/tests/nvme/031
> @@ -20,6 +20,7 @@ QUICK=1
>   requires() {
>   	_nvme_requires
>   	_have_modules loop
> +	_require_nvme_trtype_not_pci
>   }
>   
>   test() {
> diff --git a/tests/nvme/rc b/tests/nvme/rc
> index 191f0497416a..a2cb0c0add93 100644
> --- a/tests/nvme/rc
> +++ b/tests/nvme/rc
> @@ -46,6 +46,22 @@ _require_test_dev_is_nvme() {
>   	return 0
>   }
>   
> +_require_nvme_trtype_is_loop() {
> +	if [[ "${nvme_trtype}" != "loop" ]]; then
> +		SKIP_REASON="nvme_trtype=${nvme_trtype} is not supported in this test"
> +		return 1
> +	fi
> +	return 0
> +}
> +
> +_require_nvme_trtype_not_pci() {
> +	if [[ "${nvme_trtype}" == "pci" ]]; then
> +		SKIP_REASON="nvme_trtype=${nvme_trtype} is not supported in this test"
> +		return 1
> +	fi
> +	return 0
> +}
> +
how about instead of not_pci  if we can requires_nvme_trtype_fabrics -> 
returns true for loop/rdma/tcp etc ?

It is a same thing, just my preference to void not.
>   _cleanup_nvmet() {
>   	local dev
>   	local port
> -- 2.25.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 5/7] nvme: support nvme-tcp when runinng tests
  2020-08-06 19:15 ` [PATCH v2 5/7] nvme: support nvme-tcp when runinng tests Sagi Grimberg
@ 2020-08-07  3:16   ` Chaitanya Kulkarni
  2020-08-07 23:46     ` Sagi Grimberg
  0 siblings, 1 reply; 26+ messages in thread
From: Chaitanya Kulkarni @ 2020-08-07  3:16 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig

On 8/6/20 12:15, Sagi Grimberg wrote:
> +	tcp)
> +		_have_modules nvmet nvme-core nvme-tcp nvmet-tcp
> +		_have_configfs
> +		;;
>   	
Same as previous nvme-core nvmet configfs can use a helper.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload
  2020-08-06 19:15 ` [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload Sagi Grimberg
@ 2020-08-07  3:18   ` Chaitanya Kulkarni
  2020-08-07 14:03   ` Bart Van Assche
  1 sibling, 0 replies; 26+ messages in thread
From: Chaitanya Kulkarni @ 2020-08-07  3:18 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig

On 8/6/20 12:15, Sagi Grimberg wrote:
> There is no need to retry module unload for rdma_rxe
> and siw. This also creates a dependency on
> tests/nvmeof/rc which prevents it from using in
> other test subsystems.
> 
> Signed-off-by: Sagi Grimberg<sagi@grimberg.me>

You might want to CC Bart for this patch.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload
  2020-08-06 19:15 ` [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload Sagi Grimberg
  2020-08-07  3:18   ` Chaitanya Kulkarni
@ 2020-08-07 14:03   ` Bart Van Assche
  2020-08-07 17:23     ` Sagi Grimberg
  1 sibling, 1 reply; 26+ messages in thread
From: Bart Van Assche @ 2020-08-07 14:03 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni

On 2020-08-06 12:15, Sagi Grimberg wrote:
> There is no need to retry module unload for rdma_rxe
> and siw. This also creates a dependency on
> tests/nvmeof/rc which prevents it from using in
> other test subsystems.

If it wouldn't be necessary to retry module unload I wouldn't have
introduced a loop.

How about moving the unload_module() function definitions from tests/srp/rc
and tests/nvmeof-mp/rc into common/rc instead?

Thanks,

Bart.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 1/7] nvme: consolidate nvme requirements based on transport type
  2020-08-07  2:41   ` Chaitanya Kulkarni
@ 2020-08-07 17:14     ` Sagi Grimberg
  0 siblings, 0 replies; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-07 17:14 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig


>> diff --git a/tests/nvme/rc b/tests/nvme/rc
>> index 6ffa971b4308..320aa4b2b475 100644
>> --- a/tests/nvme/rc
>> +++ b/tests/nvme/rc
>> @@ -6,6 +6,25 @@
>>    
>>    . common/rc
>>    
>> +nvme_trtype=${nvme_trtype:-"loop"}
>> +
>> +_nvme_requires() {
>> +	_have_program nvme
>> +	case ${nvme_trtype} in
>> +	loop)
>> +		_have_modules nvmet nvme-core nvme-loop
>> +		_have_configfs
> We should just move nvmet nvme-core configfs _have_nvme_fabrics_common
> which are common for all the transports to avoid the duplication.

That's a minor duplication, not sure it warrants consolidation...

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 2/7] nvme: consolidate some nvme-cli utility functions
  2020-08-07  2:53   ` Chaitanya Kulkarni
@ 2020-08-07 17:15     ` Sagi Grimberg
  2020-08-08  1:47       ` Chaitanya Kulkarni
  0 siblings, 1 reply; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-07 17:15 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig



On 8/6/20 7:53 PM, Chaitanya Kulkarni wrote:
> On 8/6/20 12:15, Sagi Grimberg wrote:
>>    
>> @@ -97,6 +97,33 @@ _setup_nvmet() {
>>    	modprobe nvme-loop
>>    }
>>    
>> +_nvme_disconnect_ctrl() {
>> +	local ctrl="$1"
>> +
>> +	nvme disconnect -d ${ctrl}
>> +}
>> +
>> +_nvme_disconnect_subsys() {
>> +	local subsysnqn="$1"
>> +
>> +	nvme disconnect -n ${subsysnqn}
>> +}
>> +
>> +_nvme_connect_subsys() {
>> +	local trtype="$1"
>> +	local subsysnqn="$2"
>> +
>> +	cmd="nvme connect -t ${trtype} -n ${subsysnqn}"
>> +	eval $cmd
>> +}
>> +
>> +_nvme_discover() {
>> +	local trtype="$1"
>> +
>> +	cmd="nvme discover -t ${trtype}"
>> +	eval $cmd
>> +}
>> +
>>    _create_nvmet_port() {
>>    	local trtype="$1"
>>    
>> @@ -206,6 +233,6 @@ _filter_discovery() {
>>    }
>>    
>>    _discovery_genctr() {
>> -	nvme discover -t loop |
>> +	_nvme_discover "loop" |
>>    		sed -n -e 's/^.*Generation counter \([0-9]\+\).*$/\1/p'
>>    }
>> -- 2.25.1
> 
> I'm okay with having a wrapper for disconnect but for connect and
> discover command it can have many arguments having a call in the
> test-case might loose the readability.

That's why these has default values.

> The downside is it will need argument count handling in the future
> and makes things not easier when user want to skip certain
> parameters, closest example would be _create_nvmet_ns().
> 
> Also if we are adding wrappers why not move $FULL 2>&1 to avoid
> duplication ?

Not exactly sure what you meant

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 3/7] nvme: make tests transport type agnostic
  2020-08-07  3:09   ` Chaitanya Kulkarni
@ 2020-08-07 17:19     ` Sagi Grimberg
  2020-08-10 17:35       ` Chaitanya Kulkarni
  0 siblings, 1 reply; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-07 17:19 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig


>> diff --git a/tests/nvme/002 b/tests/nvme/002
>> index 999e222705bf..8540623497c7 100755
>> --- a/tests/nvme/002
>> +++ b/tests/nvme/002
>> @@ -21,7 +21,7 @@ test() {
>>    
>>    	local iterations=1000
>>    	local port
>> -	port="$(_create_nvmet_port "loop")"
>> +	port="$(_create_nvmet_port ${nvme_trtype})"
> Is there a way to directly use nvme_trtype especially in rc ?
> if not disregard this comment.

I didn't want to do this, because a test can create multiple ports.
But maybe it could have a default value?

>> @@ -33,10 +33,10 @@ test() {
>>    		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
>>    	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
>>    
>> -	_nvme_connect_subsys "loop" "blktests-subsystem-1"
>> +	_nvme_connect_subsys ${nvme_trtype} "blktests-subsystem-1"
>>    
>>    	local nvmedev
>> -	nvmedev="$(_find_nvme_loop_dev)"
>> +	nvmedev="$(_find_nvme_dev)"
>>    	cat "/sys/block/${nvmedev}n1/uuid"
>>    	cat "/sys/block/${nvmedev}n1/wwid"
> 
> Since we are touching nvmedev can we move above uuid and wwid to
> a wrapper something like _nvme_show_uuid_wwid ${nvmedev}n1 ?

Doesn't help the patch set cause, so it can be added incrementally.

> 
>>
>> @@ -36,12 +36,12 @@ test() {
>>    
>>    	loop_dev="$(losetup -f --show "$TMPDIR/img")"
>>    
>> -	port="$(_create_nvmet_port "loop")"
>> +	port="$(_create_nvmet_port ${nvme_trtype})"
>>    
>>    	for ((i = 0; i < iterations; i++)); do
>>    		_create_nvmet_subsystem "${subsys}$i" "${loop_dev}"
>>    		_add_nvmet_subsys_to_port "${port}" "${subsys}$i"
>> -		_nvme_connect_subsys "loop" "${subsys}$i"
>> +		_nvme_connect_subsys ${nvme_trtype} "${subsys}$i"
> Same here for nvme_trtype as first comment.
>>    		_nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1
>>    		_remove_nvmet_subsystem_from_port "${port}" "${subsys}$i"
>>    		_remove_nvmet_subsystem "${subsys}$i"
>> diff --git a/tests/nvme/rc b/tests/nvme/rc
>> index 6d57cf591300..191f0497416a 100644
>> --- a/tests/nvme/rc
>> +++ b/tests/nvme/rc
>> @@ -6,6 +6,9 @@
>>    
>>    . common/rc
>>    
>> +def_traddr="127.0.0.1"
>> +def_adrfam="ipv4"
>> +def_trsvcid="4420"
>>    nvme_trtype=${nvme_trtype:-"loop"}
>>    
>>    _nvme_requires() {
>> @@ -62,8 +65,8 @@ _cleanup_nvmet() {
>>    	for dev in /sys/class/nvme/nvme*; do
>>    		dev="$(basename "$dev")"
>>    		transport="$(cat "/sys/class/nvme/${dev}/transport")"
>> -		if [[ "$transport" == "loop" ]]; then
>> -			echo "WARNING: Test did not clean up loop device: ${dev}"
>> +		if [[ "$transport" == "${nvme_trtype}" ]]; then
>> +			echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}"
>>    			_nvme_disconnect_ctrl "${dev}"
>>    		fi
>>    	done
>> @@ -87,14 +90,20 @@ _cleanup_nvmet() {
>>    	shopt -u nullglob
>>    	trap SIGINT
>>    
>> -	modprobe -r nvme-loop 2>/dev/null
>> +	modprobe -r nvme-${nvme_trtype} 2>/dev/null
>> +	if [[ "${nvme_trtype}" != "loop" ]]; then
>> +		modprobe -r nvmet-${nvme_trtype} 2>/dev/null
> This is not from your patch but I'd keep the error message it has
> turned out to be useful for me when debugging refcount problem
> especially unload and load scenario.

Again, I'd like to avoid doing things that are outside the scope
of what this is trying to achieve because it is not a small change.

We can add it incrementally.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 4/7] tests/nvme: restrict tests to specific transports
  2020-08-07  3:15   ` Chaitanya Kulkarni
@ 2020-08-07 17:21     ` Sagi Grimberg
  0 siblings, 0 replies; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-07 17:21 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig


>> +_require_nvme_trtype_is_loop() {
>> +	if [[ "${nvme_trtype}" != "loop" ]]; then
>> +		SKIP_REASON="nvme_trtype=${nvme_trtype} is not supported in this test"
>> +		return 1
>> +	fi
>> +	return 0
>> +}
>> +
>> +_require_nvme_trtype_not_pci() {
>> +	if [[ "${nvme_trtype}" == "pci" ]]; then
>> +		SKIP_REASON="nvme_trtype=${nvme_trtype} is not supported in this test"
>> +		return 1
>> +	fi
>> +	return 0
>> +}
>> +
> how about instead of not_pci  if we can requires_nvme_trtype_fabrics ->
> returns true for loop/rdma/tcp etc ?
> 
> It is a same thing, just my preference to void not.

Fine with that.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload
  2020-08-07 14:03   ` Bart Van Assche
@ 2020-08-07 17:23     ` Sagi Grimberg
  2020-08-07 17:34       ` Bart Van Assche
  0 siblings, 1 reply; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-07 17:23 UTC (permalink / raw)
  To: Bart Van Assche, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni


>> There is no need to retry module unload for rdma_rxe
>> and siw. This also creates a dependency on
>> tests/nvmeof/rc which prevents it from using in
>> other test subsystems.
> 
> If it wouldn't be necessary to retry module unload I wouldn't have
> introduced a loop.

I thought it was to work-around a driver issue as these drivers
traditionally had plenty of stability issues.

To be honest this retry loop to me indicated that either the
driver has a bug or the test. But maybe there is a need I
am not seeing.

> How about moving the unload_module() function definitions from tests/srp/rc
> and tests/nvmeof-mp/rc into common/rc instead?

Don't have an issue with that.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload
  2020-08-07 17:23     ` Sagi Grimberg
@ 2020-08-07 17:34       ` Bart Van Assche
  2020-08-07 17:50         ` Sagi Grimberg
  0 siblings, 1 reply; 26+ messages in thread
From: Bart Van Assche @ 2020-08-07 17:34 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni

On 2020-08-07 10:23, Sagi Grimberg wrote:
> 
>>> There is no need to retry module unload for rdma_rxe
>>> and siw. This also creates a dependency on
>>> tests/nvmeof/rc which prevents it from using in
>>> other test subsystems.
>>
>> If it wouldn't be necessary to retry module unload I wouldn't have
>> introduced a loop.
> 
> I thought it was to work-around a driver issue as these drivers
> traditionally had plenty of stability issues.
> 
> To be honest this retry loop to me indicated that either the
> driver has a bug or the test. But maybe there is a need I
> am not seeing.

That loop was introduced a long time ago. I haven't tried to root-cause
it but my guess is that the loop is necessary because the module refcount
only drops to zero a short time after the first attempt to unload these
kernel modules.

Bart.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload
  2020-08-07 17:34       ` Bart Van Assche
@ 2020-08-07 17:50         ` Sagi Grimberg
  0 siblings, 0 replies; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-07 17:50 UTC (permalink / raw)
  To: Bart Van Assche, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig, Chaitanya Kulkarni


>>>> There is no need to retry module unload for rdma_rxe
>>>> and siw. This also creates a dependency on
>>>> tests/nvmeof/rc which prevents it from using in
>>>> other test subsystems.
>>>
>>> If it wouldn't be necessary to retry module unload I wouldn't have
>>> introduced a loop.
>>
>> I thought it was to work-around a driver issue as these drivers
>> traditionally had plenty of stability issues.
>>
>> To be honest this retry loop to me indicated that either the
>> driver has a bug or the test. But maybe there is a need I
>> am not seeing.
> 
> That loop was introduced a long time ago. I haven't tried to root-cause
> it but my guess is that the loop is necessary because the module refcount
> only drops to zero a short time after the first attempt to unload these
> kernel modules.

Didn't see any of that in the nvme testing...

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 5/7] nvme: support nvme-tcp when runinng tests
  2020-08-07  3:16   ` Chaitanya Kulkarni
@ 2020-08-07 23:46     ` Sagi Grimberg
  2020-08-08  1:49       ` Chaitanya Kulkarni
  0 siblings, 1 reply; 26+ messages in thread
From: Sagi Grimberg @ 2020-08-07 23:46 UTC (permalink / raw)
  To: Chaitanya Kulkarni, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig


>> +	tcp)
>> +		_have_modules nvmet nvme-core nvme-tcp nvmet-tcp
>> +		_have_configfs
>> +		;;
>>    	
> Same as previous nvme-core nvmet configfs can use a helper.

So for every trtype instead of having:

	_have_modules nvmet nvme-core <trtype specific>
	_have_configfs

You will have:
	_have_nvme_fabrics_common
	_have_modules <trtype specific>

Don't see it as an improvement...

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 2/7] nvme: consolidate some nvme-cli utility functions
  2020-08-07 17:15     ` Sagi Grimberg
@ 2020-08-08  1:47       ` Chaitanya Kulkarni
  0 siblings, 0 replies; 26+ messages in thread
From: Chaitanya Kulkarni @ 2020-08-08  1:47 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig

On 8/7/20 10:15, Sagi Grimberg wrote:
>> I'm okay with having a wrapper for disconnect but for connect and
>> discover command it can have many arguments having a call in the
>> test-case might loose the readability.
> That's why these has default values.
Okay.
> 
>> The downside is it will need argument count handling in the future
>> and makes things not easier when user want to skip certain
>> parameters, closest example would be _create_nvmet_ns().
>>
>> Also if we are adding wrappers why not move $FULL 2>&1 to avoid
>> duplication ?
> Not exactly sure what you meant
> 
Leave it for now.


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 5/7] nvme: support nvme-tcp when runinng tests
  2020-08-07 23:46     ` Sagi Grimberg
@ 2020-08-08  1:49       ` Chaitanya Kulkarni
  0 siblings, 0 replies; 26+ messages in thread
From: Chaitanya Kulkarni @ 2020-08-08  1:49 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig

On 8/7/20 16:46, Sagi Grimberg wrote:
> So for every trtype instead of having:
> 
> 	_have_modules nvmet nvme-core <trtype specific>
> 	_have_configfs
> 
> You will have:
> 	_have_nvme_fabrics_common
> 	_have_modules <trtype specific>
> 
> Don't see it as an improvement...

Okay, we can ignore this.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 3/7] nvme: make tests transport type agnostic
  2020-08-07 17:19     ` Sagi Grimberg
@ 2020-08-10 17:35       ` Chaitanya Kulkarni
  0 siblings, 0 replies; 26+ messages in thread
From: Chaitanya Kulkarni @ 2020-08-10 17:35 UTC (permalink / raw)
  To: Sagi Grimberg, linux-nvme, linux-block, Omar Sandoval
  Cc: Keith Busch, Johannes Thumshirn, Christoph Hellwig

On 8/7/20 10:19 AM, Sagi Grimberg wrote:
> 
>>> diff --git a/tests/nvme/002 b/tests/nvme/002
>>> index 999e222705bf..8540623497c7 100755
>>> --- a/tests/nvme/002
>>> +++ b/tests/nvme/002
>>> @@ -21,7 +21,7 @@ test() {
>>>     
>>>     	local iterations=1000
>>>     	local port
>>> -	port="$(_create_nvmet_port "loop")"
>>> +	port="$(_create_nvmet_port ${nvme_trtype})"
>> Is there a way to directly use nvme_trtype especially in rc ?
>> if not disregard this comment.
> 
> I didn't want to do this, because a test can create multiple ports.
> But maybe it could have a default value?
> 
>>> @@ -33,10 +33,10 @@ test() {
>>>     		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
>>>     	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
>>>     
>>> -	_nvme_connect_subsys "loop" "blktests-subsystem-1"
>>> +	_nvme_connect_subsys ${nvme_trtype} "blktests-subsystem-1"
>>>     
>>>     	local nvmedev
>>> -	nvmedev="$(_find_nvme_loop_dev)"
>>> +	nvmedev="$(_find_nvme_dev)"
>>>     	cat "/sys/block/${nvmedev}n1/uuid"
>>>     	cat "/sys/block/${nvmedev}n1/wwid"
>>
>> Since we are touching nvmedev can we move above uuid and wwid to
>> a wrapper something like _nvme_show_uuid_wwid ${nvmedev}n1 ?
> 
> Doesn't help the patch set cause, so it can be added incrementally.
Okay.
> 
>>
>>>
>>> @@ -36,12 +36,12 @@ test() {
>>>     
>>>     	loop_dev="$(losetup -f --show "$TMPDIR/img")"
>>>     
>>> -	port="$(_create_nvmet_port "loop")"
>>> +	port="$(_create_nvmet_port ${nvme_trtype})"
>>>     
>>>     	for ((i = 0; i < iterations; i++)); do
>>>     		_create_nvmet_subsystem "${subsys}$i" "${loop_dev}"
>>>     		_add_nvmet_subsys_to_port "${port}" "${subsys}$i"
>>> -		_nvme_connect_subsys "loop" "${subsys}$i"
>>> +		_nvme_connect_subsys ${nvme_trtype} "${subsys}$i"
>> Same here for nvme_trtype as first comment.
>>>     		_nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1
>>>     		_remove_nvmet_subsystem_from_port "${port}" "${subsys}$i"
>>>     		_remove_nvmet_subsystem "${subsys}$i"
>>> diff --git a/tests/nvme/rc b/tests/nvme/rc
>>> index 6d57cf591300..191f0497416a 100644
>>> --- a/tests/nvme/rc
>>> +++ b/tests/nvme/rc
>>> @@ -6,6 +6,9 @@
>>>     
>>>     . common/rc
>>>     
>>> +def_traddr="127.0.0.1"
>>> +def_adrfam="ipv4"
>>> +def_trsvcid="4420"
>>>     nvme_trtype=${nvme_trtype:-"loop"}
>>>     
>>>     _nvme_requires() {
>>> @@ -62,8 +65,8 @@ _cleanup_nvmet() {
>>>     	for dev in /sys/class/nvme/nvme*; do
>>>     		dev="$(basename "$dev")"
>>>     		transport="$(cat "/sys/class/nvme/${dev}/transport")"
>>> -		if [[ "$transport" == "loop" ]]; then
>>> -			echo "WARNING: Test did not clean up loop device: ${dev}"
>>> +		if [[ "$transport" == "${nvme_trtype}" ]]; then
>>> +			echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}"
>>>     			_nvme_disconnect_ctrl "${dev}"
>>>     		fi
>>>     	done
>>> @@ -87,14 +90,20 @@ _cleanup_nvmet() {
>>>     	shopt -u nullglob
>>>     	trap SIGINT
>>>     
>>> -	modprobe -r nvme-loop 2>/dev/null
>>> +	modprobe -r nvme-${nvme_trtype} 2>/dev/null
>>> +	if [[ "${nvme_trtype}" != "loop" ]]; then
>>> +		modprobe -r nvmet-${nvme_trtype} 2>/dev/null
>> This is not from your patch but I'd keep the error message it has
>> turned out to be useful for me when debugging refcount problem
>> especially unload and load scenario.
> 
> Again, I'd like to avoid doing things that are outside the scope
> of what this is trying to achieve because it is not a small change.
> 
> We can add it incrementally.
That make sense, we can do it incrementally.
> 


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-08-10 17:35 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-06 19:15 [PATCH v2 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
2020-08-06 19:15 ` [PATCH v2 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
2020-08-07  2:41   ` Chaitanya Kulkarni
2020-08-07 17:14     ` Sagi Grimberg
2020-08-06 19:15 ` [PATCH v2 2/7] nvme: consolidate some nvme-cli utility functions Sagi Grimberg
2020-08-07  2:53   ` Chaitanya Kulkarni
2020-08-07 17:15     ` Sagi Grimberg
2020-08-08  1:47       ` Chaitanya Kulkarni
2020-08-06 19:15 ` [PATCH v2 3/7] nvme: make tests transport type agnostic Sagi Grimberg
2020-08-07  3:09   ` Chaitanya Kulkarni
2020-08-07 17:19     ` Sagi Grimberg
2020-08-10 17:35       ` Chaitanya Kulkarni
2020-08-06 19:15 ` [PATCH v2 4/7] tests/nvme: restrict tests to specific transports Sagi Grimberg
2020-08-07  3:15   ` Chaitanya Kulkarni
2020-08-07 17:21     ` Sagi Grimberg
2020-08-06 19:15 ` [PATCH v2 5/7] nvme: support nvme-tcp when runinng tests Sagi Grimberg
2020-08-07  3:16   ` Chaitanya Kulkarni
2020-08-07 23:46     ` Sagi Grimberg
2020-08-08  1:49       ` Chaitanya Kulkarni
2020-08-06 19:15 ` [PATCH v2 6/7] common/multipath-over-rdma: don't retry module unload Sagi Grimberg
2020-08-07  3:18   ` Chaitanya Kulkarni
2020-08-07 14:03   ` Bart Van Assche
2020-08-07 17:23     ` Sagi Grimberg
2020-08-07 17:34       ` Bart Van Assche
2020-08-07 17:50         ` Sagi Grimberg
2020-08-06 19:15 ` [PATCH v2 7/7] nvme: support rdma transport type Sagi Grimberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).