]> www.infradead.org Git - users/hch/blktests.git/commitdiff
srp tests: Use _{init,exit}_scsi_debug() instead of duplicating these functions
authorBart Van Assche <bvanassche@acm.org>
Tue, 19 May 2020 00:52:53 +0000 (17:52 -0700)
committerOmar Sandoval <osandov@osandov.com>
Tue, 4 Aug 2020 18:46:07 +0000 (11:46 -0700)
This patch does not change any functionality but reduces code duplication.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
common/multipath-over-rdma
tests/srp/rc

index 6ebf0c551b845f83206325f36e360fb69ce402a4..eb85c5ee751bf634f989ae12abda07ccabb5a270 100644 (file)
@@ -476,18 +476,6 @@ stop_soft_rdma() {
        } >>"$FULL"
 }
 
-# /dev/sd... device node assigned to the scsi_debug kernel module.
-scsi_debug_dev_path() {
-       local bd="" d
-
-       for d in /sys/bus/pseudo/drivers/scsi_debug/adapter*/host*/target*/*/block/*; do
-               [ -e "$d" ] || continue
-               bd=${d/*\//}
-       done
-       [ -n "$bd" ] || return 1
-       echo "/dev/$bd"
-}
-
 # Look up the block device below the filesystem for directory $1.
 block_dev_of_dir() {
        df "$1" | {
index 4013e951476714446d033ce4decab9703511faf1..57ca7b2e4dd9deabb41c6c796be1f507705cb3cf 100755 (executable)
@@ -3,6 +3,7 @@
 # Copyright (c) 2018 Western Digital Corporation or its affiliates
 
 . common/rc
+. common/scsi_debug
 . common/multipath-over-rdma
 
 vdev_path=(/dev/nullb0 /dev/nullb1 scsi_debug_dev_path_will_be_set_later)
@@ -594,16 +595,9 @@ stop_lio_srpt() {
 start_srpt() {
        local bd i
 
-       modprobe scsi_debug delay=0 dif=3 dix=1 dev_size_mb=$((ramdisk_size>>20))
-       for ((i=0;i<10;i++)); do
-               bd=$(scsi_debug_dev_path) && break
-               sleep .1
-       done
-       if [ -z "$bd" ]; then
-               echo "scsi_debug device instance not found"
-               return 1
-       fi
-       vdev_path[2]=$bd
+       _init_scsi_debug delay=0 dev_size_mb=$((ramdisk_size>>20)) dif=3 dix=1\
+               || return $?
+       vdev_path[2]=/dev/${SCSI_DEBUG_DEVICES[0]}
        modprobe ib_uverbs
        modprobe ib_umad
        modprobe rdma_cm
@@ -614,7 +608,7 @@ start_srpt() {
 # Unload the SRP target driver.
 stop_srpt() {
        stop_lio_srpt || return $?
-       unload_module scsi_debug
+       _exit_scsi_debug
 }
 
 start_target() {