Skip to content

Commit

Permalink
nvme/{033-037}: timeout while waiting for nvme passthru namespace device
Browse files Browse the repository at this point in the history
Avoid waiting indefinitely for nvme passthru namespace block device
to appear. Wait for up to 5 seconds and during this time if namespace
device doesn't appear then bail out and FAIL the test.

Signed-off-by: Nilay Shroff <[email protected]>
Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
  • Loading branch information
shroffni authored and kawasaki committed Oct 4, 2024
1 parent 80430af commit f09f239
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
7 changes: 5 additions & 2 deletions tests/nvme/033
Original file line number Diff line number Diff line change
Expand Up @@ -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: Failed to find passthru target namespace"
else
compare_dev_info "${nsdev}"
fi

_nvme_disconnect_subsys
_nvmet_passthru_target_cleanup
Expand Down
8 changes: 5 additions & 3 deletions tests/nvme/034
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ test_device() {

_setup_nvmet

local ctrldev
local nsdev

_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: Failed to find passthru target namespace"
else
_run_fio_verify_io --size="${NVME_IMG_SIZE}" --filename="${nsdev}"
fi

_nvme_disconnect_subsys
_nvmet_passthru_target_cleanup
Expand Down
6 changes: 3 additions & 3 deletions tests/nvme/035
Original file line number Diff line number Diff line change
Expand Up @@ -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: Failed to find passthru target namespace"
elif ! _xfs_run_fio_verify_io "${nsdev}" "${NVME_IMG_SIZE}"; then
echo "FAIL: fio verify failed"
fi

Expand Down
11 changes: 8 additions & 3 deletions tests/nvme/036
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ test_device() {
_setup_nvmet

local ctrldev
local nsdev

_nvmet_passthru_target_setup
nsdev=$(_nvmet_passthru_target_connect)

ctrldev=$(_find_nvme_dev "${def_subsysnqn}")
if [[ -z "$nsdev" ]]; then
echo "FAIL: Failed to find passthru target namespace"
else
ctrldev=$(_find_nvme_dev "${def_subsysnqn}")

if ! nvme reset "/dev/${ctrldev}" >> "$FULL" 2>&1; then
echo "ERROR: reset failed"
if ! nvme reset "/dev/${ctrldev}" >> "$FULL" 2>&1; then
echo "ERROR: reset failed"
fi
fi

_nvme_disconnect_subsys
Expand Down
7 changes: 6 additions & 1 deletion tests/nvme/037
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test_device() {

local subsys="blktests-subsystem-"
local iterations=10
local ctrldev
local nsdev

for ((i = 0; i < iterations; i++)); do
_nvmet_passthru_target_setup --subsysnqn "${subsys}${i}"
Expand All @@ -37,6 +37,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: Failed to find passthru target namespace"
break
fi
done

echo "Test complete"
Expand Down
9 changes: 8 additions & 1 deletion tests/nvme/rc
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ _nvmet_passthru_target_setup() {

_nvmet_passthru_target_connect() {
local subsysnqn="$def_subsysnqn"
local timeout="5"
local count="0"

while [[ $# -gt 0 ]]; do
case $1 in
Expand All @@ -414,7 +416,12 @@ _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
while [ ! -b "${nsdev}" ]; do
sleep 1
if ((++count >= timeout)); then
return 1
fi
done

echo "${nsdev}"
}
Expand Down

0 comments on commit f09f239

Please sign in to comment.