nvme/{033-037}: timeout while waiting for nvme passthru namespace device
Subsystems (2)
PATCH 1/1 nvme/{033-037}: timeout while waiting for nvme passthru namespace device
Avoid waiting indefinitely for nvme passthru namespace block device to appear. Wait for up to 5 seconds and during this time if namespace block device doesn't appear then bail out and FAIL the test.
---
Hi,
You may find more details about this issue here[1].
I found that blktest nvme/033-037 hangs indefinitely when kernel rejects the passthru target namespace due to the duplicate IDs. This patch helps address this issue by ensuring that we bail out and fail the test if for any reason passthru target namspace is not created on the host. The relevant kernel patchv2 to fix the issue with duplicate IDs while using passthru loop target can be found here[2].
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/
Thanks!
--- tests/nvme/033 | 7 +++++-- tests/nvme/034 | 7 +++++-- tests/nvme/035 | 6 +++--- tests/nvme/036 | 14 ++++++++------ tests/nvme/037 | 6 +++++- tests/nvme/rc | 12 +++++++++++- 6 files changed, 37 insertions(+), 15 deletions(-)
tests/nvme/033 +5 -2
@@ -62,8 +62,11 @@ test_device() { _nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - compare_dev_info "${nsdev}" + if [[ -z "$nsdev" ]]; then + echo "FAIL" + else + compare_dev_info "${nsdev}" + fi _nvme_disconnect_subsys _nvmet_passthru_target_cleanup
tests/nvme/034 +5 -2
@@ -32,8 +32,11 @@ test_device() { _nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - _run_fio_verify_io --size="${NVME_IMG_SIZE}" --filename="${nsdev}" + if [[ -z "$nsdev" ]]; then + echo "FAIL" + else + _run_fio_verify_io --size="${NVME_IMG_SIZE}" --filename="${nsdev}" + fi _nvme_disconnect_subsys _nvmet_passthru_target_cleanup
tests/nvme/035 +3 -3
@@ -30,13 +30,13 @@ test_device() { _setup_nvmet - local ctrldev local nsdev _nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - if ! _xfs_run_fio_verify_io "${nsdev}" "${NVME_IMG_SIZE}"; then + if [[ -z "$nsdev" ]]; then + echo "FAIL" + elif ! _xfs_run_fio_verify_io "${nsdev}" "${NVME_IMG_SIZE}"; then echo "FAIL: fio verify failed" fi
tests/nvme/036 +8 -6
@@ -30,13 +30,15 @@ test_device() { _nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - ctrldev=$(_find_nvme_dev "${def_subsysnqn}") - - if ! nvme reset "/dev/${ctrldev}" >> "$FULL" 2>&1; then - echo "ERROR: reset failed" + if [[ -z "$nsdev" ]]; then + echo "FAIL" + else + ctrldev=$(_find_nvme_dev "${def_subsysnqn}") + + if ! nvme reset "/dev/${ctrldev}" >> "$FULL" 2>&1; then + echo "ERROR: reset failed" + fi fi - _nvme_disconnect_subsys _nvmet_passthru_target_cleanup
tests/nvme/037 +5 -1
@@ -27,7 +27,6 @@ test_device() { local subsys="blktests-subsystem-" local iterations=10 - local ctrldev for ((i = 0; i < iterations; i++)); do _nvmet_passthru_target_setup --subsysnqn "${subsys}${i}"
@@ -37,6 +36,11 @@ test_device() { _nvme_disconnect_subsys \ --subsysnqn "${subsys}${i}" >>"${FULL}" 2>&1 _nvmet_passthru_target_cleanup --subsysnqn "${subsys}${i}" + + if [[ -z "$nsdev" ]]; then + echo "FAIL" + break + fi done echo "Test complete"
tests/nvme/rc +11 -1
@@ -394,6 +394,7 @@ _nvmet_passthru_target_setup() { _nvmet_passthru_target_connect() { local subsysnqn="$def_subsysnqn" + local timeout="5" while [[ $# -gt 0 ]]; do case $1 in
@@ -414,9 +415,18 @@ _nvmet_passthru_target_connect() { # The following tests can race with the creation # of the device so ensure the block device exists # before continuing - while [ ! -b "${nsdev}" ]; do sleep 1; done + start_time=$(date +%s) + while [ ! -b "${nsdev}" ]; do + sleep .1 + end_time=$(date +%s) + if ((end_time - start_time > timeout)); then + echo "" + return 1 + fi + done echo "${nsdev}" + return 0 } _nvmet_passthru_target_cleanup() {
Signature · 1 line
2.45.2
Quoted 19 lines · Nilay Shroff
Avoid waiting indefinitely for nvme passthru namespace block device to appear. Wait for up to 5 seconds and during this time if namespace block device doesn't appear then bail out and FAIL the test.
Signed-off-by Nilay Shroff <[email protected]>---
Hi,You may find more details about this issue here[1].
I found that blktest nvme/033-037 hangs indefinitely when kernel rejects the passthru target namespace due to the duplicate IDs. This patch helps address this issue by ensuring that we bail out and fail the test if for any reason passthru target namspace is not created on the host. The relevant kernel patchv2 to fix the issue with duplicate IDs while using passthru loop target can be found here[2].
Quoted 4 lines
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/Thanks!
Thanks for the patch :) It's bad that you stumbled into the infinite while loop in _nvmet_passthru_target_connect(). I agree that it should be fixed.
Please find my comments in line.
Quoted 14 lines
--- tests/nvme/033 | 7 +++++-- tests/nvme/034 | 7 +++++-- tests/nvme/035 | 6 +++--- tests/nvme/036 | 14 ++++++++------ tests/nvme/037 | 6 +++++- tests/nvme/rc | 12 +++++++++++- 6 files changed, 37 insertions(+), 15 deletions(-)tests/nvme/033 +0
-0
tests/nvme/033 test_device() { · line 66
Quoted 7 lines
tests/nvme/033 +2
-2@@ -62,8 +62,11 @@ test_device() { _nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - compare_dev_info "${nsdev}" + if [[ -z "$nsdev" ]]; then + echo "FAIL"
I think some more specific failure message will be useful. How about "Failed to connect" or so? Same comment for the other test cases 034-037.
Quoted 29 lines
tests/nvme/033 +3
-0+ else + compare_dev_info "${nsdev}" + fi _nvme_disconnect_subsys _nvmet_passthru_target_cleanuptests/nvme/034 +5
-2@@ -32,8 +32,11 @@ test_device() { _nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - _run_fio_verify_io --size="${NVME_IMG_SIZE}" --filename="${nsdev}" + if [[ -z "$nsdev" ]]; then + echo "FAIL" + else + _run_fio_verify_io --size="${NVME_IMG_SIZE}" --filename="${nsdev}" + fi _nvme_disconnect_subsys _nvmet_passthru_target_cleanuptests/nvme/035 +0
-0
tests/nvme/035 test_device() { · line 33
Quoted 4 lines
tests/nvme/035 +0
-1@@ -30,13 +30,13 @@ test_device() { _setup_nvmet - local ctrldev
Good catch :)
tests/nvme/036 test_device() {
Quoted 17 lines
tests/nvme/035 +3
-2local nsdev _nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - if ! _xfs_run_fio_verify_io "${nsdev}" "${NVME_IMG_SIZE}"; then + if [[ -z "$nsdev" ]]; then + echo "FAIL" + elif ! _xfs_run_fio_verify_io "${nsdev}" "${NVME_IMG_SIZE}"; then echo "FAIL: fio verify failed" fitests/nvme/036 +0
-0@@ -30,13 +30,15 @@ test_device() {
This could be a good chance to add "local nsdev".
Quoted 8 lines
tests/nvme/036 +0
-5_nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - ctrldev=$(_find_nvme_dev "${def_subsysnqn}") - - if ! nvme reset "/dev/${ctrldev}" >> "$FULL" 2>&1; then - echo "ERROR: reset failed"
tests/nvme/036 test_device() { · line 39
Quoted 10 lines
tests/nvme/036 +8
-1+ if [[ -z "$nsdev" ]]; then + echo "FAIL" + else + ctrldev=$(_find_nvme_dev "${def_subsysnqn}") + + if ! nvme reset "/dev/${ctrldev}" >> "$FULL" 2>&1; then + echo "ERROR: reset failed" + fi fi -
Nit: unnecessary change here.
tests/nvme/037 test_device() { · line 30
Quoted 12 lines
tests/nvme/036 +0
-0_nvme_disconnect_subsys _nvmet_passthru_target_cleanuptests/nvme/037 +0
-1@@ -27,7 +27,6 @@ test_device() { local subsys="blktests-subsystem-" local iterations=10 - local ctrldev
Good catch. And we can add "local nsdev" here.
Quoted 28 lines
tests/nvme/037 +5
-0for ((i = 0; i < iterations; i++)); do _nvmet_passthru_target_setup --subsysnqn "${subsys}${i}"@@ -37,6 +36,11 @@ test_device() { _nvme_disconnect_subsys \ --subsysnqn "${subsys}${i}" >>"${FULL}" 2>&1 _nvmet_passthru_target_cleanup --subsysnqn "${subsys}${i}" + + if [[ -z "$nsdev" ]]; then + echo "FAIL" + break + fi done echo "Test complete"tests/nvme/rc +1
-0@@ -394,6 +394,7 @@ _nvmet_passthru_target_setup() { _nvmet_passthru_target_connect() { local subsysnqn="$def_subsysnqn" + local timeout="5" while [[ $# -gt 0 ]]; do case $1 in
tests/nvme/rc _nvmet_passthru_target_connect() { · line 420
Quoted 7 lines
tests/nvme/rc +3
-1@@ -414,9 +415,18 @@ _nvmet_passthru_target_connect() { # The following tests can race with the creation # of the device so ensure the block device exists # before continuing - while [ ! -b "${nsdev}" ]; do sleep 1; done + start_time=$(date +%s) + while [ ! -b "${nsdev}" ]; do + sleep .1
Is there any reason to have 0.1 second wait duration? When I changed this to "sleep 1", runtime of the test cases did not change on my test system.
tests/nvme/rc _nvmet_passthru_target_connect() { · line 423
Quoted 3 lines
tests/nvme/rc +3
-0+ end_time=$(date +%s) + if ((end_time - start_time > timeout)); then + echo ""
This echo doesn't look required.
tests/nvme/rc _nvmet_passthru_target_connect() { · line 425
Quoted 2 lines
tests/nvme/rc +2
-0+ return 1 + fi
If 1 second wait is okay instead of 0.1 second wait, the if block above can be a bit simpler, like,
if ((++count >= timeout)); then
return 1
fiwhere, "local count=0" should be declared before.
tests/nvme/rc _nvmet_passthru_target_connect() { · line 429
Quoted 4 lines
tests/nvme/rc +2
-0+ done echo "${nsdev}" + return 0
This "return 0" looks redundant. The previous echo succeeds always, then 0 is returned anyway. Also, all of the callers check the failure of this function by referring to the nsdev string echoed. They do not refer to the return code. So, it is not so useful to explicitly show that 0 is returned on success.
Quoted 6 lines
tests/nvme/rc +0
-0} _nvmet_passthru_target_cleanup() {Signature · 1 line
2.45.2
Quoted 23 lines · Shinichiro Kawasaki
Quoted 22 lines · Nilay Shroff
Avoid waiting indefinitely for nvme passthru namespace block device to appear. Wait for up to 5 seconds and during this time if namespace block device doesn't appear then bail out and FAIL the test.
Signed-off-by Nilay Shroff <[email protected]>---
Hi,You may find more details about this issue here[1].
I found that blktest nvme/033-037 hangs indefinitely when kernel rejects the passthru target namespace due to the duplicate IDs. This patch helps address this issue by ensuring that we bail out and fail the test if for any reason passthru target namspace is not created on the host. The relevant kernel patchv2 to fix the issue with duplicate IDs while using passthru loop target can be found here[2].
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/
Quoted 7 lines
Quoted 1 line
Thanks!
Thanks for the patch :) It's bad that you stumbled into the infinite while loop in
_nvmet_passthru_target_connect(). I agree that it should be fixed.Please find my comments in line.
Thank you for your review comments!!
Quoted 16 lines
Quoted 16 lines
--- tests/nvme/033 | 7 +++++-- tests/nvme/034 | 7 +++++-- tests/nvme/035 | 6 +++--- tests/nvme/036 | 14 ++++++++------ tests/nvme/037 | 6 +++++- tests/nvme/rc | 12 +++++++++++- 6 files changed, 37 insertions(+), 15 deletions(-)tests/nvme/033 +0
-0@@ -62,8 +62,11 @@ test_device() { _nvmet_passthru_target_setup
Quoted 8 lines
tests/nvme/033 test_device() { · line 66
Quoted 5 lines
tests/nvme/033 +2
-2nsdev=$(_nvmet_passthru_target_connect) - - compare_dev_info "${nsdev}" + if [[ -z "$nsdev" ]]; then + echo "FAIL"I think some more specific failure message will be useful. How about "Failed to connect" or so? Same comment for the other test cases 034-037.
Agreed, I will add a meaningful error message in next patch.
Quoted 49 lines
Quoted 30 lines
tests/nvme/033 +3
-0+ else + compare_dev_info "${nsdev}" + fi _nvme_disconnect_subsys _nvmet_passthru_target_cleanuptests/nvme/034 +5
-2@@ -32,8 +32,11 @@ test_device() { _nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - _run_fio_verify_io --size="${NVME_IMG_SIZE}" --filename="${nsdev}" + if [[ -z "$nsdev" ]]; then + echo "FAIL" + else + _run_fio_verify_io --size="${NVME_IMG_SIZE}" --filename="${nsdev}" + fi _nvme_disconnect_subsys _nvmet_passthru_target_cleanuptests/nvme/035 +0
-0tests/nvme/035 test_device() { · line 33
Quoted 4 lines
tests/nvme/035 +0
-1@@ -30,13 +30,13 @@ test_device() { _setup_nvmet - local ctrldevGood catch :)
Quoted 12 lines
tests/nvme/035 +3
-2local nsdev _nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - if ! _xfs_run_fio_verify_io "${nsdev}" "${NVME_IMG_SIZE}"; then + if [[ -z "$nsdev" ]]; then + echo "FAIL" + elif ! _xfs_run_fio_verify_io "${nsdev}" "${NVME_IMG_SIZE}"; then echo "FAIL: fio verify failed" fi
Quoted 7 lines
tests/nvme/036 test_device() {
Quoted 5 lines
tests/nvme/036 +0
-0@@ -30,13 +30,15 @@ test_device() {This could be a good chance to add "local nsdev".
Yeah will do.
Quoted 13 lines
Quoted 13 lines
tests/nvme/036 +4
-5_nvmet_passthru_target_setup nsdev=$(_nvmet_passthru_target_connect) - - ctrldev=$(_find_nvme_dev "${def_subsysnqn}") - - if ! nvme reset "/dev/${ctrldev}" >> "$FULL" 2>&1; then - echo "ERROR: reset failed" + if [[ -z "$nsdev" ]]; then + echo "FAIL" + else + ctrldev=$(_find_nvme_dev "${def_subsysnqn}")
Quoted 8 lines
tests/nvme/036 test_device() { · line 39
Quoted 6 lines
tests/nvme/036 +4
-1+ + if ! nvme reset "/dev/${ctrldev}" >> "$FULL" 2>&1; then + echo "ERROR: reset failed" + fi fi -Nit: unnecessary change here.
Okay, will remove this.
Quoted 10 lines
Quoted 10 lines
tests/nvme/036 +0
-0_nvme_disconnect_subsys _nvmet_passthru_target_cleanuptests/nvme/037 +0
-0@@ -27,7 +27,6 @@ test_device() {
Quoted 5 lines
tests/nvme/037 test_device() { · line 30
Quoted 3 lines
tests/nvme/037 +0
-1local subsys="blktests-subsystem-" local iterations=10 - local ctrldevGood catch. And we can add "local nsdev" here.
yes will do.
Quoted 26 lines
Quoted 26 lines
tests/nvme/037 +5
-0for ((i = 0; i < iterations; i++)); do _nvmet_passthru_target_setup --subsysnqn "${subsys}${i}"@@ -37,6 +36,11 @@ test_device() { _nvme_disconnect_subsys \ --subsysnqn "${subsys}${i}" >>"${FULL}" 2>&1 _nvmet_passthru_target_cleanup --subsysnqn "${subsys}${i}" + + if [[ -z "$nsdev" ]]; then + echo "FAIL" + break + fi done echo "Test complete"tests/nvme/rc +1
-0@@ -394,6 +394,7 @@ _nvmet_passthru_target_setup() { _nvmet_passthru_target_connect() { local subsysnqn="$def_subsysnqn" + local timeout="5"
Quoted 14 lines
tests/nvme/rc _nvmet_passthru_target_connect() { · line 420
Quoted 10 lines
tests/nvme/rc +3
-1while [[ $# -gt 0 ]]; do case $1 in@@ -414,9 +415,18 @@ _nvmet_passthru_target_connect() { # The following tests can race with the creation # of the device so ensure the block device exists # before continuing - while [ ! -b "${nsdev}" ]; do sleep 1; done + start_time=$(date +%s) + while [ ! -b "${nsdev}" ]; do + sleep .1Is there any reason to have 0.1 second wait duration? When I changed this to "sleep 1", runtime of the test cases did not change on my test system.
yes you're right there won't be any noticeable change in the runtime of the test unless we run this test in a loop for multiple number of times. I would say that the gain would be only a fraction of a second in this case. So I will use sleep 1 instead of .1 as you suggested.
Quoted 12 lines
tests/nvme/rc _nvmet_passthru_target_connect() { · line 423
Quoted 3 lines
tests/nvme/rc +3
-0+ end_time=$(date +%s) + if ((end_time - start_time > timeout)); then + echo ""This echo doesn't look required.
tests/nvme/rc _nvmet_passthru_target_connect() { · line 425
Quoted 2 lines
tests/nvme/rc +2
-0+ return 1 + fiIf 1 second wait is okay instead of 0.1 second wait, the if block above can be a bit simpler, like,
Quoted 6 lines
if ((++count >= timeout)); then return 1 fiwhere, "local count=0" should be declared before.
yeah with sleep 1 we can make it simple. I will update this in next patch.
Quoted 10 lines
tests/nvme/rc _nvmet_passthru_target_connect() { · line 429
Quoted 4 lines
tests/nvme/rc +2
-0+ done echo "${nsdev}" + return 0This "return 0" looks redundant. The previous echo succeeds always, then 0 is returned anyway. Also, all of the callers check the failure of this function by referring to the nsdev string echoed. They do not refer to the return code. So, it is not so useful to explicitly show that 0 is returned on success.
yes I will incorporate it in the next patch.
Thanks,
--Nilay