diff mbox series

[blktests,04/11] nvme: Search for specific subsysnqn in _find_nvme_loop_dev

Message ID 20200827194912.6135-5-logang@deltatee.com (mailing list archive)
State New, archived
Headers show
Series NVMe Target Passthru Block Tests | expand

Commit Message

Logan Gunthorpe Aug. 27, 2020, 7:49 p.m. UTC
This ensures we find the correct nvme loop device if others
exist on a given system (which is generally not expected on
test systems).

Additionally, this will be required in the upcomming test nvme/036
which will have controllers racing with ones being destroyed.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
 tests/nvme/004 | 2 +-
 tests/nvme/005 | 2 +-
 tests/nvme/008 | 2 +-
 tests/nvme/009 | 2 +-
 tests/nvme/010 | 2 +-
 tests/nvme/011 | 2 +-
 tests/nvme/012 | 2 +-
 tests/nvme/013 | 2 +-
 tests/nvme/014 | 2 +-
 tests/nvme/015 | 2 +-
 tests/nvme/018 | 2 +-
 tests/nvme/019 | 2 +-
 tests/nvme/020 | 2 +-
 tests/nvme/021 | 2 +-
 tests/nvme/022 | 2 +-
 tests/nvme/023 | 2 +-
 tests/nvme/024 | 2 +-
 tests/nvme/025 | 2 +-
 tests/nvme/026 | 2 +-
 tests/nvme/027 | 2 +-
 tests/nvme/028 | 2 +-
 tests/nvme/029 | 2 +-
 tests/nvme/rc  | 7 ++++---
 23 files changed, 26 insertions(+), 25 deletions(-)
diff mbox series

Patch

diff --git a/tests/nvme/004 b/tests/nvme/004
index 0debcd9c7049..0bda90f60dd2 100755
--- a/tests/nvme/004
+++ b/tests/nvme/004
@@ -35,7 +35,7 @@  test() {
 	nvme connect -t loop -n blktests-subsystem-1
 
 	local nvmedev
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "blktests-subsystem-1")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/005 b/tests/nvme/005
index 8c79d234bb1d..82d920596439 100755
--- a/tests/nvme/005
+++ b/tests/nvme/005
@@ -36,7 +36,7 @@  test() {
 	nvme connect -t loop -n blktests-subsystem-1
 
 	local nvmedev
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "blktests-subsystem-1")
 
 	udevadm settle
 
diff --git a/tests/nvme/008 b/tests/nvme/008
index 71ff4d962b00..bd0e2f2e6d5b 100755
--- a/tests/nvme/008
+++ b/tests/nvme/008
@@ -36,7 +36,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/009 b/tests/nvme/009
index 25c7da2ab854..9d93888f5c91 100755
--- a/tests/nvme/009
+++ b/tests/nvme/009
@@ -32,7 +32,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/010 b/tests/nvme/010
index 25c79089e092..5a47b1f02b35 100755
--- a/tests/nvme/010
+++ b/tests/nvme/010
@@ -36,7 +36,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/011 b/tests/nvme/011
index ad360d095ffc..0b1465984dde 100755
--- a/tests/nvme/011
+++ b/tests/nvme/011
@@ -34,7 +34,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/012 b/tests/nvme/012
index 1dae795d17ac..fd0bfc491cfa 100755
--- a/tests/nvme/012
+++ b/tests/nvme/012
@@ -37,7 +37,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/013 b/tests/nvme/013
index c7b0f16ef504..bed00482f2f5 100755
--- a/tests/nvme/013
+++ b/tests/nvme/013
@@ -35,7 +35,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/014 b/tests/nvme/014
index c255d5f12205..96e1dc39407f 100755
--- a/tests/nvme/014
+++ b/tests/nvme/014
@@ -36,7 +36,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/015 b/tests/nvme/015
index a8497a2ba400..dc129b6aff36 100755
--- a/tests/nvme/015
+++ b/tests/nvme/015
@@ -32,7 +32,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/018 b/tests/nvme/018
index 67d89a6f0b24..9544f0ba0b73 100755
--- a/tests/nvme/018
+++ b/tests/nvme/018
@@ -34,7 +34,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/019 b/tests/nvme/019
index a8b0204ec0eb..92dc25fbbd8b 100755
--- a/tests/nvme/019
+++ b/tests/nvme/019
@@ -38,7 +38,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/020 b/tests/nvme/020
index b480ee1b92d0..eea19a11b4b3 100755
--- a/tests/nvme/020
+++ b/tests/nvme/020
@@ -34,7 +34,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/021 b/tests/nvme/021
index bbee54d16ff1..880ef3df6cdf 100755
--- a/tests/nvme/021
+++ b/tests/nvme/021
@@ -33,7 +33,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/022 b/tests/nvme/022
index 9ba07c1cc50f..c6ba18472afc 100755
--- a/tests/nvme/022
+++ b/tests/nvme/022
@@ -33,7 +33,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/023 b/tests/nvme/023
index ed2a5ad7653f..9161e81b95e9 100755
--- a/tests/nvme/023
+++ b/tests/nvme/023
@@ -36,7 +36,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/024 b/tests/nvme/024
index 538580947c5c..99588b000b30 100755
--- a/tests/nvme/024
+++ b/tests/nvme/024
@@ -33,7 +33,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/025 b/tests/nvme/025
index 0039fefa5007..d640e43ac350 100755
--- a/tests/nvme/025
+++ b/tests/nvme/025
@@ -33,7 +33,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/026 b/tests/nvme/026
index 7e89d840529c..10488952feb5 100755
--- a/tests/nvme/026
+++ b/tests/nvme/026
@@ -33,7 +33,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/027 b/tests/nvme/027
index 4d293beb8b47..47a1ec1c34c0 100755
--- a/tests/nvme/027
+++ b/tests/nvme/027
@@ -33,7 +33,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/028 b/tests/nvme/028
index 1280107ed5df..845b52759c6e 100755
--- a/tests/nvme/028
+++ b/tests/nvme/028
@@ -33,7 +33,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/029 b/tests/nvme/029
index 65eb40031888..b56c131016c5 100755
--- a/tests/nvme/029
+++ b/tests/nvme/029
@@ -69,7 +69,7 @@  test() {
 
 	nvme connect -t loop -n "${subsys_name}"
 
-	nvmedev="$(_find_nvme_loop_dev)"
+	nvmedev=$(_find_nvme_loop_dev "${subsys_name}")
 	cat "/sys/block/${nvmedev}n1/uuid"
 	cat "/sys/block/${nvmedev}n1/wwid"
 
diff --git a/tests/nvme/rc b/tests/nvme/rc
index 6ffa971b4308..8865d543f4c1 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -162,12 +162,13 @@  _remove_nvmet_subsystem_from_port() {
 }
 
 _find_nvme_loop_dev() {
+	local subsys=$1
+	local subsysnqn
 	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
+		subsysnqn="$(cat "/sys/class/nvme/${dev}/subsysnqn")"
+		if [[ "$subsysnqn" == "$subsys" ]]; then
 			echo "$dev"
 			for ((i = 0; i < 10; i++)); do
 				if [[ -e /sys/block/$dev/uuid &&