From: Ming Lei <ming.lei@redhat.com>
To: Omar Sandoval <osandov@fb.com>
Cc: linux-block@vger.kernel.org, Ming Lei <ming.lei@redhat.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org
Subject: [PATCH] block/001: wait until device is added
Date: Tue, 24 Aug 2021 11:17:53 +0800 [thread overview]
Message-ID: <20210824031753.1397579-1-ming.lei@redhat.com> (raw)
Writing to the scan attribute of scsi host is usually one sync scan, but
devices in this sync scan may be delay added if there is concurrent
asnyc scan.
So wait until the device is added in block/001 for avoiding to fail
the test.
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
tests/block/001 | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tests/block/001 b/tests/block/001
index 51ec9d8..01356d0 100755
--- a/tests/block/001
+++ b/tests/block/001
@@ -21,15 +21,20 @@ stress_scsi_debug() {
return
fi
- local host target
+ local host target target_path
for target in "${SCSI_DEBUG_TARGETS[@]}"; do
(
host="${target%%:*}"
scan="${target#*:}"
scan="${scan//:/ }"
+ target_path="/sys/class/scsi_device/${target}"
while [[ ! -e "$TMPDIR/stop" ]]; do
echo "${scan}" > "/sys/class/scsi_host/host${host}/scan"
- echo 1 > "/sys/class/scsi_device/${target}/device/delete"
+ while [ ! -d ${target_path} ]; do
+ sleep 0.01;
+ [[ -e "$TMPDIR/stop" ]] && break
+ done
+ [ -d ${target_path} ] && echo 1 > ${target_path}/device/delete
done
) &
done
--
2.31.1
next reply other threads:[~2021-08-24 3:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 3:17 Ming Lei [this message]
2021-08-25 0:56 ` [PATCH] block/001: wait until device is added Omar Sandoval
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=20210824031753.1397579-1-ming.lei@redhat.com \
--to=ming.lei@redhat.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=osandov@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.