Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH blktests] nvme/rc: fix nvme device readiness check after _nvme_connect_subsys
@ 2023-08-11  1:23 Shin'ichiro Kawasaki
  2023-08-11  5:26 ` Chaitanya Kulkarni
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Shin'ichiro Kawasaki @ 2023-08-11  1:23 UTC (permalink / raw)
  To: linux-block, linux-nvme
  Cc: Yi Zhang, Daniel Wagner, Bart Van Assche,
	Shin'ichiro Kawasaki

The helper function _nvme_connect_subsys() creates a nvme device. It may
take some time after the function call until the device gets ready for
I/O. So it is expected that the test cases call _find_nvme_dev() after
_nvme_connect_subsys() before I/O. _find_nvme_dev() returns the path of
the created device, and it also waits for uuid and wwid sysfs attributes
of the created device get ready. This wait works as the wait for the
device I/O readiness.

However, this wait by _find_nvme_dev() has two problems. The first
problem is missing call of _find_nvme_dev(). The test case nvme/047
calls _nvme_connect_subsys() twice, but _find_nvme_dev() is called only
for the first _nvme_connect_subsys() call. This causes too early I/O to
the device with tcp transport [1]. Fix this by moving the code for
device readiness wait from _find_nvme_dev() to _nvme_connect_subsys().

The second problem is wrong paths for the sysfs attributes. The paths
do not include namespace index, so the check for the attributes always
fail. Still _find_nvme_dev() does 1 second wait and allows the device
get ready for I/O in most cases, but this is not intended behavior.
Fix the paths by adding the namespace index.

On top of the checks for sysfs attributes, add check for the created
device file. This ensures that the create device is ready for I/O.

[1] https://lore.kernel.org/linux-block/CAHj4cs9GNohGUjohNw93jrr8JGNcRYC-ienAZz+sa7az1RK77w@mail.gmail.com/

Fixes: c766fccf3aff ("Make the NVMe tests more reliable")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 tests/nvme/rc | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/tests/nvme/rc b/tests/nvme/rc
index 4f3a994..d09e7b4 100644
--- a/tests/nvme/rc
+++ b/tests/nvme/rc
@@ -425,6 +425,7 @@ _nvme_connect_subsys() {
 	local keep_alive_tmo=""
 	local reconnect_delay=""
 	local ctrl_loss_tmo=""
+	local dev i
 
 	while [[ $# -gt 0 ]]; do
 		case $1 in
@@ -529,6 +530,16 @@ _nvme_connect_subsys() {
 	fi
 
 	nvme connect "${ARGS[@]}" 2> /dev/null
+
+	dev=$(_find_nvme_dev "$subsysnqn")
+	for ((i = 0; i < 10; i++)); do
+		if [[ -b /dev/${dev}n1 &&
+			      -e /sys/block/${dev}n1/uuid &&
+			      -e /sys/block/${dev}n1/wwid ]]; then
+			return
+		fi
+		sleep .1
+	done
 }
 
 _nvme_discover() {
@@ -739,13 +750,6 @@ _find_nvme_dev() {
 		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 &&
-					-e /sys/block/$dev/wwid ]]; then
-					return
-				fi
-				sleep .1
-			done
 		fi
 	done
 }
-- 
2.40.1



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

end of thread, other threads:[~2023-08-17  7:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11  1:23 [PATCH blktests] nvme/rc: fix nvme device readiness check after _nvme_connect_subsys Shin'ichiro Kawasaki
2023-08-11  5:26 ` Chaitanya Kulkarni
2023-08-11  6:37 ` Daniel Wagner
2023-08-16 12:04   ` Shinichiro Kawasaki
2023-08-16 14:14     ` Daniel Wagner
2023-08-17  7:17       ` Shinichiro Kawasaki
2023-08-14  9:37 ` Sagi Grimberg
2023-08-16 12:11   ` Shinichiro Kawasaki
2023-08-17  4:23     ` Yi Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox