From d92c1e580aae21d97c3f80280c5167e5a064298d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 18 May 2020 17:52:53 -0700 Subject: [PATCH] srp tests: Use _{init,exit}_scsi_debug() instead of duplicating these functions This patch does not change any functionality but reduces code duplication. Signed-off-by: Bart Van Assche --- common/multipath-over-rdma | 12 ------------ tests/srp/rc | 16 +++++----------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/common/multipath-over-rdma b/common/multipath-over-rdma index 6ebf0c5..eb85c5e 100644 --- a/common/multipath-over-rdma +++ b/common/multipath-over-rdma @@ -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" | { diff --git a/tests/srp/rc b/tests/srp/rc index 4013e95..57ca7b2 100755 --- a/tests/srp/rc +++ b/tests/srp/rc @@ -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() { -- 2.49.0