From: Nilay Shroff <nilay@linux.ibm.com>
To: linux-nvme@lists.infradead.org
Cc: shinichiro.kawasaki@wdc.com, chaitanyak@nvidia.com, hch@lst.de,
kbusch@kernel.org, sagi@grimberg.me, axboe@kernel.dk,
gjoyce@linux.ibm.com
Subject: [PATCHv2 blktests 1/2] nvme/052: move nvmf_wait_for_ns() to common/nvme
Date: Wed, 4 Dec 2024 17:17:47 +0530 [thread overview]
Message-ID: <20241204114755.190660-2-nilay@linux.ibm.com> (raw)
In-Reply-To: <20241204114755.190660-1-nilay@linux.ibm.com>
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@nvidia.com>
Signed-off-by: Nilay Shroff <nilay@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
next prev parent reply other threads:[~2024-12-04 11:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 11:47 [PATCHv2 blktests 0/2] add nvme test for creating sleep while atomic kernel BUG Nilay Shroff
2024-12-04 11:47 ` Nilay Shroff [this message]
2024-12-04 11:47 ` [PATCHv2 blktests 2/2] nvme: add test for writing to file-ns just after disabling it Nilay Shroff
2024-12-05 7:32 ` Chaitanya Kulkarni
2024-12-05 9:40 ` Nilay Shroff
2024-12-05 10:47 ` Daniel Wagner
2024-12-05 11:06 ` Nilay Shroff
2024-12-05 11:20 ` Daniel Wagner
2024-12-06 1:49 ` Shinichiro Kawasaki
2024-12-06 1:53 ` Shinichiro Kawasaki
2024-12-06 10:54 ` Nilay Shroff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241204114755.190660-2-nilay@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=axboe@kernel.dk \
--cc=chaitanyak@nvidia.com \
--cc=gjoyce@linux.ibm.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=shinichiro.kawasaki@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox