[PATCHv2 blktests 1/2] nvme/052: move nvmf_wait_for_ns() to common/nvme
Nilay Shroff
nilay at linux.ibm.com
Wed Dec 4 03:47:47 PST 2024
In a preparation for the use of nvmf_wait_for_ns function from
other nvme test script, move nvmf_wait_for_ns from nvme/052 to
common/nvme file so that we can reuse the nvmf_wait_for_ns from
multiple test scripts.
Reviewed-by: Chaitanya Kulkarni <kch at nvidia.com>
Signed-off-by: Nilay Shroff <nilay at linux.ibm.com>
---
common/nvme | 26 ++++++++++++++++++++++++++
tests/nvme/052 | 30 ++----------------------------
2 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/common/nvme b/common/nvme
index fd472fe..6b8a57a 100644
--- a/common/nvme
+++ b/common/nvme
@@ -483,6 +483,32 @@ _remove_nvmet_port() {
rmdir "${NVMET_CFS}/ports/${port}"
}
+# Wait for the namespace with specified uuid to fulfill the specified condtion,
+# "created" or "removed".
+_nvmf_wait_for_ns() {
+ local ns
+ local timeout="5"
+ local uuid="$1"
+ local condition="$2"
+
+ ns=$(_find_nvme_ns "${uuid}" 2>> "$FULL")
+
+ start_time=$(date +%s)
+ while [[ -z "$ns" && "$condition" == created ]] ||
+ [[ -n "$ns" && "$condition" == removed ]]; do
+ sleep .1
+ end_time=$(date +%s)
+ if (( end_time - start_time > timeout )); then
+ echo "namespace with uuid \"${uuid}\" not " \
+ "${condition} within ${timeout} seconds"
+ return 1
+ fi
+ ns=$(_find_nvme_ns "${uuid}" 2>> "$FULL")
+ done
+
+ return 0
+}
+
_create_nvmet_ns() {
local subsysnqn="${def_subsysnqn}"
local nsid="${def_nsid}"
diff --git a/tests/nvme/052 b/tests/nvme/052
index 8443c90..22d8a9e 100755
--- a/tests/nvme/052
+++ b/tests/nvme/052
@@ -20,32 +20,6 @@ set_conditions() {
_set_nvme_trtype "$@"
}
-# Wait for the namespace with specified uuid to fulfill the specified condtion,
-# "created" or "removed".
-nvmf_wait_for_ns() {
- local ns
- local timeout="5"
- local uuid="$1"
- local condition="$2"
-
- ns=$(_find_nvme_ns "${uuid}" 2>> "$FULL")
-
- start_time=$(date +%s)
- while [[ -z "$ns" && "$condition" == created ]] ||
- [[ -n "$ns" && "$condition" == removed ]]; do
- sleep .1
- end_time=$(date +%s)
- if (( end_time - start_time > timeout )); then
- echo "namespace with uuid \"${uuid}\" not " \
- "${condition} within ${timeout} seconds"
- return 1
- fi
- ns=$(_find_nvme_ns "${uuid}" 2>> "$FULL")
- done
-
- return 0
-}
-
test() {
echo "Running ${TEST_NAME}"
@@ -65,7 +39,7 @@ test() {
uuid=$(_create_nvmet_ns --blkdev "$filepath" --nsid "${nsid}")
# wait until async request is processed and ns is created
- if ! nvmf_wait_for_ns "${uuid}" created; then
+ if ! _nvmf_wait_for_ns "${uuid}" created; then
echo "FAIL"
rm "$filepath"
break
@@ -74,7 +48,7 @@ test() {
_remove_nvmet_ns "${def_subsysnqn}" "${nsid}"
# wait until async request is processed and ns is removed
- if ! nvmf_wait_for_ns "${uuid}" removed; then
+ if ! _nvmf_wait_for_ns "${uuid}" removed; then
echo "FAIL"
rm "$filepath"
break
--
2.45.2
More information about the Linux-nvme
mailing list