[PATCH blktests 1/2] common/nvme: add '--no-wait-ns' argument to _nvme_connect_subsys()
Yi Zhang
yi.zhang at redhat.com
Fri Aug 22 08:10:52 PDT 2025
The default behavior of _nvme_connect_subsys is just wait for the
controller ready, but sometimes the namespace was not ready after
_nvme_connect_subsys especially on RT kernel, it's better we can
have namespace ready in _nvme_connect_subsys, so
1) re-use the the function _nvme_ns_ready to check namespace ready
2) add one new argument `--no-wait-ns` to skip for the cases that
don't need wait for namespace ready
3) update to use "return 1" for controller failure check and "return 2"
for namespace failure check
After this change, it will avoids the failures like below which easy to
be reproduced on rt kernel:
nvme/010 (tr=loop bd=file) (run data verification fio job) [failed]
runtime 21.644s ... 9.787s
--- tests/nvme/010.out 2025-07-26 14:42:07.918582261 +0000
+++ /root/blktests/results/nodev_tr_loop_bd_file/nvme/010.out.bad 2025-07-30 03:01:35.276827933 +0000
@@ -1,3 +1,7 @@
Running nvme/010
+fio: pid=0, err=21/file:filesetup.c:150, func=unlink, error=Is a directory
+fio exited with status 1
+fio: pid=0, err=21/file:filesetup.c:150, func=unlink, error=Is a directory
+4;fio-3.35;verify;0;21;0;0;0;0;0;0;0.000000;0.000000;0;0;0.000000;0.000000;1.000000%=0;5.000000%=0;10.000000%=0;20.000000%=0;30.000000%=0;40.000000%=0;50.000000%=0;60.000000%=0;70.000000%=0;80.000000%=0;90.000000%=0;95.000000%=0;99.000000%=0;99.500000%=0;99.900000%=0;99.950000%=0;99.990000%=0;0%=0;0%=0;0%=0;0;0;0.000000;0.000000;0;0;0.000000%;0.000000;0.000000;0;0;0;0;0;0;0.000000;0.000000;0;0;0.000000;0.000000;1.000000%=0;5.000000%=0;10.000000%=0;20.000000%=0;30.000000%=0;40.000000%=0;50.000000%=0;60.000000%=0;70.000000%=0;80.000000%=0;90.000000%=0;95.000000%=0;99.000000%=0;99.500000%=0;99.900000%=0;99.950000%=0;99.990000%=0;0%=0;0%=0;0%=0;0;0;0.000000;0.000000;0;0;0.000000%;0.000000;0.000000;0;0;0;0;0;0;0.000000;0.000000;0;0;0.000000;0.000000;1.000000%=0;5.000000%=0;10.000000%=0;20.000000%=0;30.000000%=0;40.000000%=0;50.000000%=0;60.000000%=0;70.000000%=0;80.000000%=0;90.000000%=0;95.000000%=0;99.000000%=0;99.500000%=0;99.900000%=0;99.950000%=0;99.990000%=0;0%=0;0%=0;0%=0;0;0;0.000000;0.000000;0;0;0.000000%;0.000000;0.000000;0.000000%;0.000000%;0;0;0;0.0%;0.0%;0.0%;0.0%;0.0%;0.0%;0.0%;nan%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%;0.00%
disconnected 1 controller(s)
Test complete
nvme/012 (tr=loop bd=file) (run mkfs and data verification fio) [failed]
runtime 21.731s ... 9.372s
--- tests/nvme/012.out 2025-07-26 14:42:07.918582261 +0000
+++ /root/blktests/results/nodev_tr_loop_bd_file/nvme/012.out.bad 2025-07-30 03:02:01.436992167 +0000
@@ -1,3 +1,4 @@
Running nvme/012
+FAIL: fio verify failed
disconnected 1 controller(s)
Test complete
nvme/019 (tr=loop bd=file) (test NVMe DSM Discard command) [failed]
runtime 9.477s ... 8.982s
--- tests/nvme/019.out 2025-07-26 14:42:07.918582261 +0000
+++ /root/blktests/results/nodev_tr_loop_bd_file/nvme/019.out.bad 2025-07-30 03:02:57.567344555 +0000
@@ -1,4 +1,32 @@
Running nvme/019
-NVMe DSM: success
+/dev is not a block or character device
+Usage: nvme dsm <device> [OPTIONS]
+
+The Dataset Management command is used by the host to
+indicate attributes for ranges of logical blocks. This includes
...
(Run 'diff -u tests/nvme/019.out /root/blktests/results/nodev_tr_loop_bd_file/nvme/019.out.bad' to see the entire diff)
nvme/021 (tr=loop bd=file) (test NVMe list command) [failed]
runtime 9.188s ... 8.884s
--- tests/nvme/021.out 2025-07-26 14:42:07.918582261 +0000
+++ /root/blktests/results/nodev_tr_loop_bd_file/nvme/021.out.bad 2025-07-31 09:04:48.415419449 +0000
@@ -1,2 +1,3 @@
Running nvme/021
+ERROR: device not listed
Test complete
nvme/023 (tr=loop bd=file) (test NVMe smart-log command) [failed]
runtime 9.070s ... 8.991s
--- tests/nvme/023.out 2025-07-26 14:42:07.918582261 +0000
+++ /root/blktests/results/nodev_tr_loop_bd_file/nvme/023.out.bad 2025-07-30 03:03:39.747609389 +0000
@@ -1,2 +1,3 @@
Running nvme/023
+ERROR: smart-log bdev-ns failed
Test complete
nvme/026 (tr=loop bd=file) (test NVMe ns-descs) [failed]
runtime 9.573s ... 9.020s
--- tests/nvme/026.out 2025-07-26 14:42:07.918582261 +0000
+++ /root/blktests/results/nodev_tr_loop_bd_file/nvme/026.out.bad 2025-07-30 03:04:00.117737295 +0000
@@ -1,2 +1,3 @@
Running nvme/026
+ERROR: ns-desc failed
Test complete
nvme/047 (tr=tcp) (test different queue types for fabric transponvme/047 (tr=tcp) (test different queue types for fabric transports) [failed]3.669s ...
runtime 3.669s ... 2.890s
--- tests/nvme/047.out 2025-07-26 14:42:07.918582261 +0000
+++ /root/blktests/results/nodev_tr_tcp/nvme/047.out.bad 2025-07-31 13:24:14.993729267 +0000
@@ -1,2 +1,3 @@
Running nvme/047
+common/fio: line 197: Error: '/dev/nvme0n1' does not exist or is not accessible: syntax error in expression (error token is ": '/dev/nvme0n1' does not exist or is not accessible")
Test complete
Link: https://github.com/linux-blktests/blktests/issues/193
Signed-off-by: Yi Zhang <yi.zhang at redhat.com>
---
common/nvme | 39 +++++++++++++++++++++++++++++++++++----
1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/common/nvme b/common/nvme
index 791868c..8de41fa 100644
--- a/common/nvme
+++ b/common/nvme
@@ -284,6 +284,7 @@ _nvme_connect_subsys() {
local reconnect_delay=""
local ctrl_loss_tmo=""
local no_wait=false
+ local no_wait_ns=false
local hdr_digest=false
local data_digest=false
local tls=false
@@ -291,6 +292,7 @@ _nvme_connect_subsys() {
local port
local i
local -a ARGS
+ local ret=0
while [[ $# -gt 0 ]]; do
case $1 in
@@ -346,6 +348,10 @@ _nvme_connect_subsys() {
no_wait=true
shift 1
;;
+ --no-wait-ns)
+ no_wait_ns=true
+ shift 1
+ ;;
--hdr-digest)
hdr_digest=true
shift 1
@@ -432,14 +438,23 @@ _nvme_connect_subsys() {
if [[ ${no_wait} = false ]]; then
local ctrldev
- ctrldev=$(echo "${connect}" | sed -n 's/.*device.:.\(nvme[0-9]*\)./\1/p')
+ ctrldev=$(echo "${connect}" | sed -n 's/.*device.:.\(nvme[0-9]*\)./\1/p')
udevadm settle
for ((i = 0; i < 10; i++)); do
- _nvme_ctrl_ready "${ctrldev}" "${subsysnqn}" && return 0
+ _nvme_ctrl_ready "${ctrldev}" "${subsysnqn}" && break
sleep .1
done
- return 1
+ [ $i -eq 10 ] && ret=1
+ if [[ ${no_wait_ns} = false ]]; then
+ for ((i = 0; i < 10; i++)); do
+ _nvme_ns_ready "${subsysnqn}" && break
+ sleep .1
+ done
+ [ $i -eq 10 ] && ret=2
+ fi
+
fi
+ return "$ret"
}
_nvme_disconnect_subsys() {
@@ -462,7 +477,6 @@ _nvme_disconnect_subsys() {
grep -o "disconnected.*"
}
-
_nvme_ctrl_ready() {
local ctrldev="${1}"
local subsysnqn="${2:-$def_subsysnqn}"
@@ -476,6 +490,23 @@ _nvme_ctrl_ready() {
return 1
}
+_nvme_ns_ready() {
+ local subsysnqn="${1}"
+ local ns_path ns_id dev
+ local cfs_path="${NVMET_CFS}/subsystems/$subsysnqn"
+
+ dev=$(_find_nvme_dev "$subsysnqn")
+ for ns_path in "${cfs_path}/namespaces/"*; do
+ ns_id=${ns_path##*/}
+ if [[ ! -b /dev/${dev}n${ns_id} ||
+ ! -e /sys/block/${dev}n${ns_id}/uuid ||
+ ! -e /sys/block/${dev}n${ns_id}/wwid ]]; then
+ return 1
+ fi
+ done
+ return 0
+}
+
_remote_wwnn() {
local -i port=${1}
--
2.45.1
More information about the Linux-nvme
mailing list