]> www.infradead.org Git - users/hch/blktests.git/commitdiff
block/001: wait until device is added
authorMing Lei <ming.lei@redhat.com>
Tue, 24 Aug 2021 03:17:53 +0000 (11:17 +0800)
committerOmar Sandoval <osandov@fb.com>
Wed, 25 Aug 2021 00:56:05 +0000 (17:56 -0700)
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>
[Omar: fix quoting and simplify logic]
Signed-off-by: Omar Sandoval <osandov@fb.com>
tests/block/001

index 51ec9d84140123371d2615582db3724231dbfb85..c26792bb458e8157fc8f5de1e27c26dd62d39879 100755 (executable)
@@ -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