linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports
@ 2020-09-03 23:53 Sagi Grimberg
  2020-09-03 23:53 ` [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
                   ` (9 more replies)
  0 siblings, 10 replies; 25+ messages in thread
From: Sagi Grimberg @ 2020-09-03 23:53 UTC (permalink / raw)
  To: linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig

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 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 v6:
- fix _nvme_discover wrong use of subsysnqn that is never passed
- move shellcheck fixes to the correct patches (not fix in subsequent patches)
Changes from v5:
- fix shellcheck errors
Changes from v4:
- removed extra paranthesis
- load either rdma_rxe or siw for rdma transport tests
Changes from v3:
- remove unload_module from tests/srp/rc
- fixed test run cmd
Changes from v2:
- changed patch 6 to move unload_module to common/rc
- changed helper to be named _require_nvme_trtype_is_fabrics
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: move module_unload to common
  nvme: support rdma transport type

 common/rc          |  13 +++++
 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      | 127 ++++++++++++++++++++++++++++++++++++++++++---
 tests/nvmeof-mp/rc |  13 -----
 tests/srp/rc       |  13 -----
 35 files changed, 327 insertions(+), 192 deletions(-)

-- 
2.25.1


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

* [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type
  2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
@ 2020-09-03 23:53 ` Sagi Grimberg
  2020-09-04  0:18   ` Chaitanya Kulkarni
  2020-09-14 21:51   ` Omar Sandoval
  2020-09-03 23:53 ` [PATCH v7 2/7] nvme: consolidate some nvme-cli utility functions Sagi Grimberg
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 25+ messages in thread
From: Sagi Grimberg @ 2020-09-03 23:53 UTC (permalink / raw)
  To: linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig

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 325f2b656613..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 && _have_program nvme
+	_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


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

* [PATCH v7 2/7] nvme: consolidate some nvme-cli utility functions
  2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
  2020-09-03 23:53 ` [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
@ 2020-09-03 23:53 ` Sagi Grimberg
  2020-09-04  0:19   ` Chaitanya Kulkarni
  2020-09-03 23:53 ` [PATCH v7 3/7] nvme: make tests transport type agnostic Sagi Grimberg
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Sagi Grimberg @ 2020-09-03 23:53 UTC (permalink / raw)
  To: linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig

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..92779e8d28ca 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..83d1b2ff9cb0 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..1a3eedd634cf 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..f26adebe1b3b 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..91673974ecaa 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..ec586ec08780 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..e8055541746a 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..7e89c8e7b38e 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..72cf93210bb9 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..d70bd02df666 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..2d83c4258f2a 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..118a261f3845 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..a2b22adfc6b9 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..7ec146ec7414 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..2dee7d190006 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..58ee7c916f9d 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..2615ab6b74b0 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..33f66c975553 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..e223107a226b 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..190bac07dae6 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..62c07478e8ce 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..d760430518df 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..40e894f89578 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..23feabf9f871 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..bb67249c2947 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..184a2f177d2d 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..7053553cb837 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..e02cb3c346ee 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"
+
+	ARGS=(-t "${trtype}" -n "${subsysnqn}")
+	nvme connect "${ARGS[@]}"
+}
+
+_nvme_discover() {
+	local trtype="$1"
+
+	ARGS=(-t "${trtype}")
+	nvme discover "${ARGS[@]}"
+}
+
 _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


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

* [PATCH v7 3/7] nvme: make tests transport type agnostic
  2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
  2020-09-03 23:53 ` [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
  2020-09-03 23:53 ` [PATCH v7 2/7] nvme: consolidate some nvme-cli utility functions Sagi Grimberg
@ 2020-09-03 23:53 ` Sagi Grimberg
  2020-09-04  0:20   ` Chaitanya Kulkarni
  2020-09-03 23:53 ` [PATCH v7 4/7] tests/nvme: restrict tests to specific transports Sagi Grimberg
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Sagi Grimberg @ 2020-09-03 23:53 UTC (permalink / raw)
  To: linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig

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 92779e8d28ca..955f68da026a 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 83d1b2ff9cb0..654ff776f6f9 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 1a3eedd634cf..0a62e3448e7b 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 f26adebe1b3b..e97287a96a4e 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..8fe95461e6cc 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..e712026ba373 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 91673974ecaa..cb36442bda18 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 ec586ec08780..6abca757b4e6 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 e8055541746a..903da818b5ac 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 7e89c8e7b38e..4060e6278d44 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 72cf93210bb9..dd8bceca5373 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 d70bd02df666..059d608a892f 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 2d83c4258f2a..192322862072 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 118a261f3845..353445ad31b9 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 a2b22adfc6b9..f829dedf7baa 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 7ec146ec7414..e552af17ccb9 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 2dee7d190006..73703a286ff8 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 58ee7c916f9d..8ccfface176e 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 2615ab6b74b0..7861d47513e5 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 33f66c975553..52d14f0490b1 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 e223107a226b..111dec92f791 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 190bac07dae6..31f77ff07055 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 62c07478e8ce..5a30b08b9d8e 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 d760430518df..b7903d6ad8f2 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 40e894f89578..721d486bc7de 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 23feabf9f871..6be7d0492d37 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 bb67249c2947..2d89c8fa35de 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 184a2f177d2d..0bface97ccd5 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..91c042ab6b0b 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 7053553cb837..3faa4c171cc8 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 e02cb3c346ee..621686abf80a 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}"
 
 	ARGS=(-t "${trtype}" -n "${subsysnqn}")
+	if [[ "${trtype}" != "loop" ]]; then
+		ARGS+=(-a "${traddr}" -s "${trsvcid}")
+	fi
 	nvme connect "${ARGS[@]}"
 }
 
 _nvme_discover() {
 	local trtype="$1"
+	local traddr="${2:-$def_traddr}"
+	local trsvcid="${3:-$def_trsvcid}"
 
 	ARGS=(-t "${trtype}")
+	if [[ "${trtype}" != "loop" ]]; then
+		ARGS+=(-a "${traddr}" -s "${trsvcid}")
+	fi
 	nvme discover "${ARGS[@]}"
 }
 
 _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


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

* [PATCH v7 4/7] tests/nvme: restrict tests to specific transports
  2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (2 preceding siblings ...)
  2020-09-03 23:53 ` [PATCH v7 3/7] nvme: make tests transport type agnostic Sagi Grimberg
@ 2020-09-03 23:53 ` Sagi Grimberg
  2020-09-04  0:21   ` Chaitanya Kulkarni
  2020-09-14 21:53   ` Omar Sandoval
  2020-09-03 23:53 ` [PATCH v7 5/7] nvme: support nvme-tcp when runinng tests Sagi Grimberg
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 25+ messages in thread
From: Sagi Grimberg @ 2020-09-03 23:53 UTC (permalink / raw)
  To: linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig

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 955f68da026a..ca11c11c9a09 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 654ff776f6f9..101c1841c6df 100755
--- a/tests/nvme/003
+++ b/tests/nvme/003
@@ -13,6 +13,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/004 b/tests/nvme/004
index 0a62e3448e7b..dfca79aab20c 100755
--- a/tests/nvme/004
+++ b/tests/nvme/004
@@ -14,6 +14,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/005 b/tests/nvme/005
index e97287a96a4e..0d5801868bc0 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_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/006 b/tests/nvme/006
index 8fe95461e6cc..9230dc6ed902 100755
--- a/tests/nvme/006
+++ b/tests/nvme/006
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/007 b/tests/nvme/007
index e712026ba373..d53100f3ff7b 100755
--- a/tests/nvme/007
+++ b/tests/nvme/007
@@ -11,6 +11,7 @@ QUICK=1
 
 requires() {
 	_nvme_requires
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/008 b/tests/nvme/008
index cb36442bda18..8616617ad398 100755
--- a/tests/nvme/008
+++ b/tests/nvme/008
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/009 b/tests/nvme/009
index 6abca757b4e6..e91d79065cb1 100755
--- a/tests/nvme/009
+++ b/tests/nvme/009
@@ -11,6 +11,7 @@ QUICK=1
 
 requires() {
 	_nvme_requires
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/010 b/tests/nvme/010
index 903da818b5ac..9d96d7803be3 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_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/011 b/tests/nvme/011
index 4060e6278d44..06dc568fb6ea 100755
--- a/tests/nvme/011
+++ b/tests/nvme/011
@@ -12,6 +12,7 @@ TIMED=1
 requires() {
 	_nvme_requires
 	_have_fio
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/012 b/tests/nvme/012
index dd8bceca5373..8110430e49d4 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_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/013 b/tests/nvme/013
index 059d608a892f..176b11b9ccb5 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_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/014 b/tests/nvme/014
index 192322862072..e3c70364e332 100755
--- a/tests/nvme/014
+++ b/tests/nvme/014
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/015 b/tests/nvme/015
index 353445ad31b9..46fa4f605749 100755
--- a/tests/nvme/015
+++ b/tests/nvme/015
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/016 b/tests/nvme/016
index f829dedf7baa..4eba30223a08 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 e552af17ccb9..f2a95cf276cb 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 73703a286ff8..6d7934d09d99 100755
--- a/tests/nvme/018
+++ b/tests/nvme/018
@@ -13,6 +13,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/019 b/tests/nvme/019
index 8ccfface176e..486b5acff713 100755
--- a/tests/nvme/019
+++ b/tests/nvme/019
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/020 b/tests/nvme/020
index 7861d47513e5..c8053f440e2e 100755
--- a/tests/nvme/020
+++ b/tests/nvme/020
@@ -11,6 +11,7 @@ QUICK=1
 
 requires() {
 	_nvme_requires
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/021 b/tests/nvme/021
index 52d14f0490b1..f543a1d8fd92 100755
--- a/tests/nvme/021
+++ b/tests/nvme/021
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/022 b/tests/nvme/022
index 111dec92f791..e824ed31f6f0 100755
--- a/tests/nvme/022
+++ b/tests/nvme/022
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/023 b/tests/nvme/023
index 31f77ff07055..bdef3dc8abca 100755
--- a/tests/nvme/023
+++ b/tests/nvme/023
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/024 b/tests/nvme/024
index 5a30b08b9d8e..78f779e8a08a 100755
--- a/tests/nvme/024
+++ b/tests/nvme/024
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/025 b/tests/nvme/025
index b7903d6ad8f2..223430965d7e 100755
--- a/tests/nvme/025
+++ b/tests/nvme/025
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/026 b/tests/nvme/026
index 721d486bc7de..7f82284d9c57 100755
--- a/tests/nvme/026
+++ b/tests/nvme/026
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/027 b/tests/nvme/027
index 6be7d0492d37..da96e6c5008d 100755
--- a/tests/nvme/027
+++ b/tests/nvme/027
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/028 b/tests/nvme/028
index 2d89c8fa35de..f826b67623f1 100755
--- a/tests/nvme/028
+++ b/tests/nvme/028
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/029 b/tests/nvme/029
index 0bface97ccd5..5bed9b8e70ae 100755
--- a/tests/nvme/029
+++ b/tests/nvme/029
@@ -13,6 +13,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test_user_io()
diff --git a/tests/nvme/030 b/tests/nvme/030
index 91c042ab6b0b..37df902da895 100755
--- a/tests/nvme/030
+++ b/tests/nvme/030
@@ -12,6 +12,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 
diff --git a/tests/nvme/031 b/tests/nvme/031
index 3faa4c171cc8..36263ca2379c 100755
--- a/tests/nvme/031
+++ b/tests/nvme/031
@@ -20,6 +20,7 @@ QUICK=1
 requires() {
 	_nvme_requires
 	_have_modules loop
+	_require_nvme_trtype_is_fabrics
 }
 
 test() {
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 621686abf80a..3b8754669af7 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_is_fabrics() {
+	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


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

* [PATCH v7 5/7] nvme: support nvme-tcp when runinng tests
  2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (3 preceding siblings ...)
  2020-09-03 23:53 ` [PATCH v7 4/7] tests/nvme: restrict tests to specific transports Sagi Grimberg
@ 2020-09-03 23:53 ` Sagi Grimberg
  2020-09-04  0:21   ` Chaitanya Kulkarni
  2020-09-03 23:53 ` [PATCH v7 6/7] common: move module_unload to common Sagi Grimberg
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Sagi Grimberg @ 2020-09-03 23:53 UTC (permalink / raw)
  To: linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig

run with: nvme_trtype=tcp ./check 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 3b8754669af7..8df00e7d15d0 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


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

* [PATCH v7 6/7] common: move module_unload to common
  2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (4 preceding siblings ...)
  2020-09-03 23:53 ` [PATCH v7 5/7] nvme: support nvme-tcp when runinng tests Sagi Grimberg
@ 2020-09-03 23:53 ` Sagi Grimberg
  2020-09-04  0:22   ` Chaitanya Kulkarni
  2020-09-03 23:53 ` [PATCH v7 7/7] nvme: support rdma transport type Sagi Grimberg
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Sagi Grimberg @ 2020-09-03 23:53 UTC (permalink / raw)
  To: linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig

It creates a dependency between multipath-over-rdma and test/nvmeof/rc
(and test/srp/rc) which is not a natural home for it.

Move it to common helpers.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 common/rc          | 13 +++++++++++++
 tests/nvmeof-mp/rc | 13 -------------
 tests/srp/rc       | 13 -------------
 3 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/common/rc b/common/rc
index 7f02103dc786..cdc0150ea5ea 100644
--- a/common/rc
+++ b/common/rc
@@ -291,3 +291,16 @@ _filter_xfs_io_error() {
 _uptime_s() {
 	awk '{ print int($1) }' /proc/uptime
 }
+
+# Arguments: module to unload ($1) and retry count ($2).
+unload_module() {
+	local i m=$1 rc=${2:-1}
+
+	[ ! -e "/sys/module/$m" ] && return 0
+	for ((i=rc;i>0;i--)); do
+		modprobe -r "$m"
+		[ ! -e "/sys/module/$m" ] && return 0
+		sleep .1
+	done
+	return 1
+}
diff --git a/tests/nvmeof-mp/rc b/tests/nvmeof-mp/rc
index b95adf047a2f..d7a7c878fb19 100755
--- a/tests/nvmeof-mp/rc
+++ b/tests/nvmeof-mp/rc
@@ -149,19 +149,6 @@ remove_mpath_devs() {
 	} &>> "$FULL"
 }
 
-# Arguments: module to unload ($1) and retry count ($2).
-unload_module() {
-	local i m=$1 rc=${2:-1}
-
-	[ ! -e "/sys/module/$m" ] && return 0
-	for ((i=rc;i>0;i--)); do
-		modprobe -r "$m"
-		[ ! -e "/sys/module/$m" ] && return 0
-		sleep .1
-	done
-	return 1
-}
-
 start_nvme_client() {
 	modprobe nvme-core dyndbg=+pmf &&
 		modprobe nvme dyndbg=+pmf &&
diff --git a/tests/srp/rc b/tests/srp/rc
index 72a3bca3b44d..7fc094b8267f 100755
--- a/tests/srp/rc
+++ b/tests/srp/rc
@@ -321,19 +321,6 @@ remove_mpath_devs() {
 	} &>> "$FULL"
 }
 
-# Arguments: module to unload ($1) and retry count ($2).
-unload_module() {
-	local i m=$1 rc=${2:-1}
-
-	[ ! -e "/sys/module/$m" ] && return 0
-	for ((i=rc;i>0;i--)); do
-		modprobe -r "$m"
-		[ ! -e "/sys/module/$m" ] && return 0
-		sleep .1
-	done
-	return 1
-}
-
 # Load the SRP initiator driver with kernel module parameters $1..$n.
 start_srp_ini() {
 	modprobe scsi_transport_srp || return $?
-- 
2.25.1


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

* [PATCH v7 7/7] nvme: support rdma transport type
  2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (5 preceding siblings ...)
  2020-09-03 23:53 ` [PATCH v7 6/7] common: move module_unload to common Sagi Grimberg
@ 2020-09-03 23:53 ` Sagi Grimberg
  2020-09-04  0:23   ` Chaitanya Kulkarni
  2020-09-04 17:00   ` Yi Zhang
  2020-09-04 15:52 ` [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Logan Gunthorpe
                   ` (2 subsequent siblings)
  9 siblings, 2 replies; 25+ messages in thread
From: Sagi Grimberg @ 2020-09-03 23:53 UTC (permalink / raw)
  To: linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig

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

diff --git a/tests/nvme/rc b/tests/nvme/rc
index 8df00e7d15d0..4c5b2e8edf0d 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 || _have_modules 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,16 @@ _setup_nvmet() {
 		modprobe nvmet-"${nvme_trtype}"
 	fi
 	modprobe nvme-"${nvme_trtype}"
+	if [[ "${nvme_trtype}" == "rdma" ]]; then
+		start_soft_rdma
+		for i in $(rdma_network_interfaces)
+		do
+			ipv4_addr=$(get_ipv4_addr "$i")
+			if [ -n "${ipv4_addr}" ]; then
+				def_traddr=${ipv4_addr}
+			fi
+		done
+	fi
 }
 
 _nvme_disconnect_ctrl() {
-- 
2.25.1


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

* Re: [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type
  2020-09-03 23:53 ` [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
@ 2020-09-04  0:18   ` Chaitanya Kulkarni
  2020-09-14 21:51   ` Omar Sandoval
  1 sibling, 0 replies; 25+ messages in thread
From: Chaitanya Kulkarni @ 2020-09-04  0:18 UTC (permalink / raw)
  To: Sagi Grimberg, linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Keith Busch, Christoph Hellwig

On 9/3/20 16:53, Sagi Grimberg wrote:
> 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>

Looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>



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

* Re: [PATCH v7 2/7] nvme: consolidate some nvme-cli utility functions
  2020-09-03 23:53 ` [PATCH v7 2/7] nvme: consolidate some nvme-cli utility functions Sagi Grimberg
@ 2020-09-04  0:19   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 25+ messages in thread
From: Chaitanya Kulkarni @ 2020-09-04  0:19 UTC (permalink / raw)
  To: Sagi Grimberg, linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Keith Busch, Christoph Hellwig

On 9/3/20 16:54, Sagi Grimberg wrote:
> Signed-off-by: Sagi Grimberg<sagi@grimberg.me>

Looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

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

* Re: [PATCH v7 3/7] nvme: make tests transport type agnostic
  2020-09-03 23:53 ` [PATCH v7 3/7] nvme: make tests transport type agnostic Sagi Grimberg
@ 2020-09-04  0:20   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 25+ messages in thread
From: Chaitanya Kulkarni @ 2020-09-04  0:20 UTC (permalink / raw)
  To: Sagi Grimberg, linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Keith Busch, Christoph Hellwig

On 9/3/20 16:54, Sagi Grimberg wrote:
> Pass in nvme_trtype to common routines that can
> support multiple transport types.
> 
> Signed-off-by: Sagi Grimberg<sagi@grimberg.me>

Looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

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

* Re: [PATCH v7 4/7] tests/nvme: restrict tests to specific transports
  2020-09-03 23:53 ` [PATCH v7 4/7] tests/nvme: restrict tests to specific transports Sagi Grimberg
@ 2020-09-04  0:21   ` Chaitanya Kulkarni
  2020-09-14 21:53   ` Omar Sandoval
  1 sibling, 0 replies; 25+ messages in thread
From: Chaitanya Kulkarni @ 2020-09-04  0:21 UTC (permalink / raw)
  To: Sagi Grimberg, linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Keith Busch, Christoph Hellwig

On 9/3/20 16:54, Sagi Grimberg wrote:
> 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>

Looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

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

* Re: [PATCH v7 5/7] nvme: support nvme-tcp when runinng tests
  2020-09-03 23:53 ` [PATCH v7 5/7] nvme: support nvme-tcp when runinng tests Sagi Grimberg
@ 2020-09-04  0:21   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 25+ messages in thread
From: Chaitanya Kulkarni @ 2020-09-04  0:21 UTC (permalink / raw)
  To: Sagi Grimberg, linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Keith Busch, Christoph Hellwig

On 9/3/20 16:54, Sagi Grimberg wrote:
> run with: nvme_trtype=tcp ./check nvme
> 
> Signed-off-by: Sagi Grimberg<sagi@grimberg.me>

Looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

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

* Re: [PATCH v7 6/7] common: move module_unload to common
  2020-09-03 23:53 ` [PATCH v7 6/7] common: move module_unload to common Sagi Grimberg
@ 2020-09-04  0:22   ` Chaitanya Kulkarni
  0 siblings, 0 replies; 25+ messages in thread
From: Chaitanya Kulkarni @ 2020-09-04  0:22 UTC (permalink / raw)
  To: Sagi Grimberg, linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Keith Busch, Christoph Hellwig

On 9/3/20 16:54, Sagi Grimberg wrote:
> It creates a dependency between multipath-over-rdma and test/nvmeof/rc
> (and test/srp/rc) which is not a natural home for it.
> 
> Move it to common helpers.
> 
> Signed-off-by: Sagi Grimberg<sagi@grimberg.me>

Looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

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

* Re: [PATCH v7 7/7] nvme: support rdma transport type
  2020-09-03 23:53 ` [PATCH v7 7/7] nvme: support rdma transport type Sagi Grimberg
@ 2020-09-04  0:23   ` Chaitanya Kulkarni
  2020-09-04 17:00   ` Yi Zhang
  1 sibling, 0 replies; 25+ messages in thread
From: Chaitanya Kulkarni @ 2020-09-04  0:23 UTC (permalink / raw)
  To: Sagi Grimberg, linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Keith Busch, Christoph Hellwig

On 9/3/20 16:54, Sagi Grimberg wrote:
> Signed-off-by: Sagi Grimberg<sagi@grimberg.me>

Looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

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

* Re: [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports
  2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (6 preceding siblings ...)
  2020-09-03 23:53 ` [PATCH v7 7/7] nvme: support rdma transport type Sagi Grimberg
@ 2020-09-04 15:52 ` Logan Gunthorpe
  2020-09-11 22:06 ` Sagi Grimberg
  2020-09-25 17:32 ` Omar Sandoval
  9 siblings, 0 replies; 25+ messages in thread
From: Logan Gunthorpe @ 2020-09-04 15:52 UTC (permalink / raw)
  To: Sagi Grimberg, linux-block, Omar Sandoval
  Cc: linux-nvme, Chaitanya Kulkarni, Keith Busch, Christoph Hellwig



On 2020-09-03 5:53 p.m., Sagi Grimberg wrote:
> 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 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 v6:
> - fix _nvme_discover wrong use of subsysnqn that is never passed
> - move shellcheck fixes to the correct patches (not fix in subsequent patches)
> Changes from v5:
> - fix shellcheck errors
> Changes from v4:
> - removed extra paranthesis
> - load either rdma_rxe or siw for rdma transport tests
> Changes from v3:
> - remove unload_module from tests/srp/rc
> - fixed test run cmd
> Changes from v2:
> - changed patch 6 to move unload_module to common/rc
> - changed helper to be named _require_nvme_trtype_is_fabrics
> 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: move module_unload to common
>   nvme: support rdma transport type

Looks good to me. For the whole series:

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

Thanks,

Logan

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

* Re: [PATCH v7 7/7] nvme: support rdma transport type
  2020-09-03 23:53 ` [PATCH v7 7/7] nvme: support rdma transport type Sagi Grimberg
  2020-09-04  0:23   ` Chaitanya Kulkarni
@ 2020-09-04 17:00   ` Yi Zhang
  1 sibling, 0 replies; 25+ messages in thread
From: Yi Zhang @ 2020-09-04 17:00 UTC (permalink / raw)
  To: Sagi Grimberg, linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig



On 9/4/20 7:53 AM, Sagi Grimberg wrote:
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
> ---
>   tests/nvme/rc | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
>
> diff --git a/tests/nvme/rc b/tests/nvme/rc
> index 8df00e7d15d0..4c5b2e8edf0d 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 || _have_modules 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,16 @@ _setup_nvmet() {
>   		modprobe nvmet-"${nvme_trtype}"
>   	fi
>   	modprobe nvme-"${nvme_trtype}"
> +	if [[ "${nvme_trtype}" == "rdma" ]]; then
> +		start_soft_rdma
> +		for i in $(rdma_network_interfaces)
> +		do
> +			ipv4_addr=$(get_ipv4_addr "$i")
> +			if [ -n "${ipv4_addr}" ]; then
> +				def_traddr=${ipv4_addr}
Do we need add break here if ipv4_addr has value?

> +			fi
> +		done
> +	fi
>   }
>   
>   _nvme_disconnect_ctrl() {


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

* Re: [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports
  2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (7 preceding siblings ...)
  2020-09-04 15:52 ` [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Logan Gunthorpe
@ 2020-09-11 22:06 ` Sagi Grimberg
  2020-09-25 17:32 ` Omar Sandoval
  9 siblings, 0 replies; 25+ messages in thread
From: Sagi Grimberg @ 2020-09-11 22:06 UTC (permalink / raw)
  To: linux-block, Omar Sandoval
  Cc: linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig


> 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 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 v6:
> - fix _nvme_discover wrong use of subsysnqn that is never passed
> - move shellcheck fixes to the correct patches (not fix in subsequent patches)
> Changes from v5:
> - fix shellcheck errors
> Changes from v4:
> - removed extra paranthesis
> - load either rdma_rxe or siw for rdma transport tests
> Changes from v3:
> - remove unload_module from tests/srp/rc
> - fixed test run cmd
> Changes from v2:
> - changed patch 6 to move unload_module to common/rc
> - changed helper to be named _require_nvme_trtype_is_fabrics
> Changes from v1:
> - added patch to remove use of module_unload
> - move trtype agnostic logig helpers in patch #3

Omar, anything left on your end to take this?

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

* Re: [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type
  2020-09-03 23:53 ` [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
  2020-09-04  0:18   ` Chaitanya Kulkarni
@ 2020-09-14 21:51   ` Omar Sandoval
  2020-09-14 22:04     ` Logan Gunthorpe
  1 sibling, 1 reply; 25+ messages in thread
From: Omar Sandoval @ 2020-09-14 21:51 UTC (permalink / raw)
  To: Sagi Grimberg
  Cc: linux-block, linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni,
	Keith Busch, Christoph Hellwig

On Thu, Sep 03, 2020 at 04:53:31PM -0700, Sagi Grimberg wrote:
> 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.

Thanks, Sagi, this is a nice cleanup. Some comments below, though.

> 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

Bash functions return the status of the last executed command, and the
requires function needs to return 0 on success and 1 on failure. So,
this is losing the return value of _nvme_requires. Just chain multiple
checks with && to fix this (here and the other places _nvme_requires was
added with other checks):

requires() {
	_nvme_requires && _have_modules loop
}

> 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

Looks like these two got squashed into one command. It should be
_nvme_requires && _have_fio && _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

Same here, _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

This return swallows the return value of the checks. You can drop it.

> +}
> +
>  group_requires() {
>  	_have_root
>  }
> -- 
> 2.25.1
> 

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

* Re: [PATCH v7 4/7] tests/nvme: restrict tests to specific transports
  2020-09-03 23:53 ` [PATCH v7 4/7] tests/nvme: restrict tests to specific transports Sagi Grimberg
  2020-09-04  0:21   ` Chaitanya Kulkarni
@ 2020-09-14 21:53   ` Omar Sandoval
  1 sibling, 0 replies; 25+ messages in thread
From: Omar Sandoval @ 2020-09-14 21:53 UTC (permalink / raw)
  To: Sagi Grimberg
  Cc: linux-block, linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni,
	Keith Busch, Christoph Hellwig

On Thu, Sep 03, 2020 at 04:53:34PM -0700, Sagi Grimberg wrote:
> 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 955f68da026a..ca11c11c9a09 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

Same comment here, chain these with &&.

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

* Re: [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type
  2020-09-14 21:51   ` Omar Sandoval
@ 2020-09-14 22:04     ` Logan Gunthorpe
  2020-09-14 22:09       ` Omar Sandoval
  0 siblings, 1 reply; 25+ messages in thread
From: Logan Gunthorpe @ 2020-09-14 22:04 UTC (permalink / raw)
  To: Omar Sandoval, Sagi Grimberg
  Cc: linux-block, linux-nvme, Chaitanya Kulkarni, Keith Busch,
	Christoph Hellwig



On 2020-09-14 3:51 p.m., Omar Sandoval wrote:
>> 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
> 
> Bash functions return the status of the last executed command, and the
> requires function needs to return 0 on success and 1 on failure. So,
> this is losing the return value of _nvme_requires. Just chain multiple
> checks with && to fix this (here and the other places _nvme_requires was
> added with other checks):
> 
> requires() {
> 	_nvme_requires && _have_modules loop
> }

I noticed this too during my review, but based on my read of the current
blktest code, the return value of the requires() function is not
actually used. It seems to only check if SKIP_REASON is set.

If we want to ensure the return value of requires() is correct, perhaps
we should check it after we call it and then consult SKIP_REASON? And
WARN or fail if SKIP_REASON is set when requires() didn't return 1.

Also, we need to do more than adding &&s... _nvme_requires() will need
to be fixed up as it calls other _have_x() functions and ignores their
return value.

Logan

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

* Re: [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type
  2020-09-14 22:04     ` Logan Gunthorpe
@ 2020-09-14 22:09       ` Omar Sandoval
  2020-09-14 22:23         ` Logan Gunthorpe
  0 siblings, 1 reply; 25+ messages in thread
From: Omar Sandoval @ 2020-09-14 22:09 UTC (permalink / raw)
  To: Logan Gunthorpe
  Cc: Sagi Grimberg, linux-block, linux-nvme, Chaitanya Kulkarni,
	Keith Busch, Christoph Hellwig

On Mon, Sep 14, 2020 at 04:04:59PM -0600, Logan Gunthorpe wrote:
> 
> 
> On 2020-09-14 3:51 p.m., Omar Sandoval wrote:
> >> 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
> > 
> > Bash functions return the status of the last executed command, and the
> > requires function needs to return 0 on success and 1 on failure. So,
> > this is losing the return value of _nvme_requires. Just chain multiple
> > checks with && to fix this (here and the other places _nvme_requires was
> > added with other checks):
> > 
> > requires() {
> > 	_nvme_requires && _have_modules loop
> > }
> 
> I noticed this too during my review, but based on my read of the current
> blktest code, the return value of the requires() function is not
> actually used. It seems to only check if SKIP_REASON is set.
> 
> If we want to ensure the return value of requires() is correct, perhaps
> we should check it after we call it and then consult SKIP_REASON? And
> WARN or fail if SKIP_REASON is set when requires() didn't return 1.
> 
> Also, we need to do more than adding &&s... _nvme_requires() will need
> to be fixed up as it calls other _have_x() functions and ignores their
> return value.
> 
> Logan

Oops, you're right, I actually changed this a few months ago in
4824ac3f5c4a ("Skip tests based on SKIP_REASON, not return value").
Totally forgot about that :) IMO it's still cleaner to chain them
together.

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

* Re: [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type
  2020-09-14 22:09       ` Omar Sandoval
@ 2020-09-14 22:23         ` Logan Gunthorpe
  2020-09-14 22:25           ` Omar Sandoval
  0 siblings, 1 reply; 25+ messages in thread
From: Logan Gunthorpe @ 2020-09-14 22:23 UTC (permalink / raw)
  To: Omar Sandoval
  Cc: Sagi Grimberg, linux-block, linux-nvme, Chaitanya Kulkarni,
	Keith Busch, Christoph Hellwig



On 2020-09-14 4:09 p.m., Omar Sandoval wrote:
>> I noticed this too during my review, but based on my read of the current
>> blktest code, the return value of the requires() function is not
>> actually used. It seems to only check if SKIP_REASON is set.
>>
>> If we want to ensure the return value of requires() is correct, perhaps
>> we should check it after we call it and then consult SKIP_REASON? And
>> WARN or fail if SKIP_REASON is set when requires() didn't return 1.

> Oops, you're right, I actually changed this a few months ago in
> 4824ac3f5c4a ("Skip tests based on SKIP_REASON, not return value").
> Totally forgot about that :) IMO it's still cleaner to chain them
> together.

In my opinion, this creates a bit of confusion when reading the code.
The &&s make it look like the return value is important when, in fact,
it is not.

It is also easy to make the assumption that adding any bash command to
the && list will skip the test -- however that is not the case and
people may introduce subtle bugs that look correct, but go unnoticed.

Logan

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

* Re: [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type
  2020-09-14 22:23         ` Logan Gunthorpe
@ 2020-09-14 22:25           ` Omar Sandoval
  0 siblings, 0 replies; 25+ messages in thread
From: Omar Sandoval @ 2020-09-14 22:25 UTC (permalink / raw)
  To: Logan Gunthorpe
  Cc: Sagi Grimberg, linux-block, linux-nvme, Chaitanya Kulkarni,
	Keith Busch, Christoph Hellwig

On Mon, Sep 14, 2020 at 04:23:32PM -0600, Logan Gunthorpe wrote:
> 
> 
> On 2020-09-14 4:09 p.m., Omar Sandoval wrote:
> >> I noticed this too during my review, but based on my read of the current
> >> blktest code, the return value of the requires() function is not
> >> actually used. It seems to only check if SKIP_REASON is set.
> >>
> >> If we want to ensure the return value of requires() is correct, perhaps
> >> we should check it after we call it and then consult SKIP_REASON? And
> >> WARN or fail if SKIP_REASON is set when requires() didn't return 1.
> 
> > Oops, you're right, I actually changed this a few months ago in
> > 4824ac3f5c4a ("Skip tests based on SKIP_REASON, not return value").
> > Totally forgot about that :) IMO it's still cleaner to chain them
> > together.
> 
> In my opinion, this creates a bit of confusion when reading the code.
> The &&s make it look like the return value is important when, in fact,
> it is not.
> 
> It is also easy to make the assumption that adding any bash command to
> the && list will skip the test -- however that is not the case and
> people may introduce subtle bugs that look correct, but go unnoticed.
> 
> Logan

Fair enough. Sagi, don't worry about changing this, I'll queue this up
once I try it out.

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

* Re: [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports
  2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
                   ` (8 preceding siblings ...)
  2020-09-11 22:06 ` Sagi Grimberg
@ 2020-09-25 17:32 ` Omar Sandoval
  9 siblings, 0 replies; 25+ messages in thread
From: Omar Sandoval @ 2020-09-25 17:32 UTC (permalink / raw)
  To: Sagi Grimberg
  Cc: linux-block, linux-nvme, Logan Gunthorpe, Chaitanya Kulkarni,
	Keith Busch, Christoph Hellwig

On Thu, Sep 03, 2020 at 04:53:30PM -0700, Sagi Grimberg wrote:
> 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 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.

Applied, thanks Sagi.

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

end of thread, other threads:[~2020-09-25 17:32 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-03 23:53 [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Sagi Grimberg
2020-09-03 23:53 ` [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type Sagi Grimberg
2020-09-04  0:18   ` Chaitanya Kulkarni
2020-09-14 21:51   ` Omar Sandoval
2020-09-14 22:04     ` Logan Gunthorpe
2020-09-14 22:09       ` Omar Sandoval
2020-09-14 22:23         ` Logan Gunthorpe
2020-09-14 22:25           ` Omar Sandoval
2020-09-03 23:53 ` [PATCH v7 2/7] nvme: consolidate some nvme-cli utility functions Sagi Grimberg
2020-09-04  0:19   ` Chaitanya Kulkarni
2020-09-03 23:53 ` [PATCH v7 3/7] nvme: make tests transport type agnostic Sagi Grimberg
2020-09-04  0:20   ` Chaitanya Kulkarni
2020-09-03 23:53 ` [PATCH v7 4/7] tests/nvme: restrict tests to specific transports Sagi Grimberg
2020-09-04  0:21   ` Chaitanya Kulkarni
2020-09-14 21:53   ` Omar Sandoval
2020-09-03 23:53 ` [PATCH v7 5/7] nvme: support nvme-tcp when runinng tests Sagi Grimberg
2020-09-04  0:21   ` Chaitanya Kulkarni
2020-09-03 23:53 ` [PATCH v7 6/7] common: move module_unload to common Sagi Grimberg
2020-09-04  0:22   ` Chaitanya Kulkarni
2020-09-03 23:53 ` [PATCH v7 7/7] nvme: support rdma transport type Sagi Grimberg
2020-09-04  0:23   ` Chaitanya Kulkarni
2020-09-04 17:00   ` Yi Zhang
2020-09-04 15:52 ` [PATCH v7 0/7] blktests: Add support to run nvme tests with tcp/rdma transports Logan Gunthorpe
2020-09-11 22:06 ` Sagi Grimberg
2020-09-25 17:32 ` Omar Sandoval

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).