From: Omar Sandoval <osandov@osandov.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Omar Sandoval <osandov@fb.com>,
linux-block@vger.kernel.org,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH] block/001: wait until device is added
Date: Tue, 24 Aug 2021 17:56:46 -0700 [thread overview]
Message-ID: <YSWVTjSYegn/wGX2@relinquished.localdomain> (raw)
In-Reply-To: <20210824031753.1397579-1-ming.lei@redhat.com>
On Tue, Aug 24, 2021 at 11:17:53AM +0800, Ming Lei wrote:
> 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
Applied, with the shellcheck errors fixed and simplified logic. Thanks.
prev parent reply other threads:[~2021-08-25 0:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 3:17 [PATCH] block/001: wait until device is added Ming Lei
2021-08-25 0:56 ` Omar Sandoval [this message]
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=YSWVTjSYegn/wGX2@relinquished.localdomain \
--to=osandov@osandov.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox