summaryrefslogtreecommitdiff
path: root/common/scsi_debug
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-07-27 13:10:43 -0700
committerEryu Guan <guaneryu@gmail.com>2021-08-01 21:28:08 +0800
commit8bd9c9700849db6d1d0c55582a06d828b2b70a4f (patch)
treea3d59736d1336dd0a642be923ba0b639030b4c8e /common/scsi_debug
parent96eefa4a7dbbf81982335cd62fe7bd6a26d69d68 (diff)
common/scsi_debug: use udevadm settle instead of sleeping
The variable UDEV_SETTLE_PROG is already defined and used for lvm to either use `udevadm settle` in case it is available, and if not, use 'sleep 1' otherwise (ancient distros or CONFIG_NET is missing). Use it on scsi_debug to replace the sleep calls sprinkled in place after module removal. The correct thing to do is to just use udevadm settle when available, and only fall back to calling sleep when udevadm is not available or CONFIG_NET is disabled. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Diffstat (limited to 'common/scsi_debug')
-rw-r--r--common/scsi_debug4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/scsi_debug b/common/scsi_debug
index d9aa0bd2..e7988469 100644
--- a/common/scsi_debug
+++ b/common/scsi_debug
@@ -36,7 +36,7 @@ _get_scsi_debug_dev()
echo "scsi_debug options $opts" >> $seqres.full
modprobe scsi_debug $opts
[ $? -eq 0 ] || _fail "scsi_debug modprobe failed"
- sleep 1
+ $UDEV_SETTLE_PROG
device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'`
echo "/dev/$device"
}
@@ -50,7 +50,7 @@ _put_scsi_debug_dev()
# modprobe is only quiet when the module is not found, not when the
# module is in use.
while [ $n -ge 0 ] && ! modprobe -nr scsi_debug >/dev/null 2>&1; do
- sleep 1
+ $UDEV_SETTLE_PROG
n=$((n-1))
done
rmmod scsi_debug || _fail "Could not remove scsi_debug module"