From: Ming Lei Date: Tue, 24 Aug 2021 03:17:53 +0000 (+0800) Subject: block/001: wait until device is added X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f3bcd8c4799375937e394416c36a806becccbadb;p=users%2Fsagi%2Fblktests.git block/001: wait until device is added 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" Cc: linux-scsi@vger.kernel.org Signed-off-by: Ming Lei [Omar: fix quoting and simplify logic] Signed-off-by: Omar Sandoval --- diff --git a/tests/block/001 b/tests/block/001 index 51ec9d8..c26792b 100755 --- a/tests/block/001 +++ b/tests/block/001 @@ -29,7 +29,13 @@ stress_scsi_debug() { scan="${scan//:/ }" while [[ ! -e "$TMPDIR/stop" ]]; do echo "${scan}" > "/sys/class/scsi_host/host${host}/scan" - echo 1 > "/sys/class/scsi_device/${target}/device/delete" + while [[ ! -e "$TMPDIR/stop" ]]; do + if [[ -d "/sys/class/scsi_device/${target}" ]]; then + echo 1 > "/sys/class/scsi_device/${target}/device/delete" + break + fi + sleep 0.01 + done done ) & done