On Aug 10, 2023 / 18:21, Yi Zhang wrote: > Hi Daniel/Shinichiro > Thanks for looking into this issue, I checked the 047 code, and we are > missing _find_nvme_dev after the second connect, and the below change > could fix this issue now. > > diff --git a/tests/nvme/047 b/tests/nvme/047 > index 6a7599b..8c0a024 100755 > --- a/tests/nvme/047 > +++ b/tests/nvme/047 > @@ -52,6 +52,8 @@ test() { > --nr-write-queues 1 \ > --nr-poll-queues 1 || echo FAIL > > + nvmedev=$(_find_nvme_dev "${subsys_name}") > + > _run_fio_rand_io --filename="/dev/${nvmedev}n1" --size="${rand_io_size}" > > _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 > > Ah, I overlooked that the test case calls _nvme_connect_subsys twice. Good to know that the above changes avoid the failure. Having said that, the fix above does not look the best. As discussed in another e-mail, _find_nvme_dev() just does 1 second wait, and it actually does not check readiness of the device. This needs fix. Also I think the check and wait should move from _find_nvme_dev()to _nvme_connect_subsys(). Could you try the patch below and see if it avoid the failure? 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 }