2018-03-22 04:02:17 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-11-02 15:49:40 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright (C) 2018 Intel Corporation
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
2019-06-10 09:35:52 +00:00
|
|
|
testdir=$(readlink -f $(dirname $0))
|
|
|
|
rootdir=$(readlink -f $testdir/../../..)
|
|
|
|
source $rootdir/test/common/autotest_common.sh
|
|
|
|
source $rootdir/test/iscsi_tgt/common.sh
|
|
|
|
|
|
|
|
rpc_py="$rootdir/scripts/rpc.py -s $testdir/rpc_iscsi.sock"
|
2018-03-22 04:02:17 +00:00
|
|
|
|
|
|
|
BLK_SIZE=4096
|
|
|
|
RW=randrw
|
|
|
|
MIX=100
|
|
|
|
IODEPTH=128
|
|
|
|
RUNTIME=60
|
|
|
|
RAMP_TIME=10
|
2020-03-02 19:55:44 +00:00
|
|
|
FIO_PATH=$CONFIG_FIO_SOURCE_DIR
|
2018-03-22 04:02:17 +00:00
|
|
|
DISKNO="ALL"
|
|
|
|
CPUMASK=0x02
|
|
|
|
NUM_JOBS=1
|
|
|
|
ISCSI_TGT_CM=0x02
|
|
|
|
|
2021-11-25 01:40:59 +00:00
|
|
|
# Performance test for iscsi_tgt, run on devices with proper hardware support (target and initiator)
|
2020-05-07 11:27:06 +00:00
|
|
|
function usage() {
|
|
|
|
[[ -n $2 ]] && (
|
|
|
|
echo "$2"
|
|
|
|
echo ""
|
|
|
|
)
|
2018-03-22 04:02:17 +00:00
|
|
|
echo "Usage: $(basename $1) [options]"
|
|
|
|
echo "-h, --help Print help and exit"
|
|
|
|
echo " --fiopath=PATH Path to fio directory on initiator. [default=$FIO_PATH]"
|
|
|
|
echo " --disk_no=INT,ALL Number of disks to test on, if =ALL then test on all found disks. [default=$DISKNO]"
|
|
|
|
echo " --target_ip=IP The IP address of target used for test."
|
|
|
|
echo " --initiator_ip=IP The IP address of initiator used for test."
|
|
|
|
echo " --init_mgmnt_ip=IP The IP address of initiator used for communication."
|
|
|
|
echo " --iscsi_tgt_mask=HEX iscsi_tgt core mask. [default=$ISCSI_TGT_CM]"
|
|
|
|
}
|
|
|
|
|
|
|
|
while getopts 'h-:' optchar; do
|
|
|
|
case "$optchar" in
|
|
|
|
-)
|
2020-05-07 11:27:06 +00:00
|
|
|
case "$OPTARG" in
|
|
|
|
help)
|
|
|
|
usage $0
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
fiopath=*) FIO_BIN="${OPTARG#*=}" ;;
|
|
|
|
disk_no=*) DISKNO="${OPTARG#*=}" ;;
|
|
|
|
target_ip=*) TARGET_IP="${OPTARG#*=}" ;;
|
|
|
|
initiator_ip=*) INITIATOR_IP="${OPTARG#*=}" ;;
|
|
|
|
init_mgmnt_ip=*) IP_I_SSH="${OPTARG#*=}" ;;
|
|
|
|
iscsi_tgt_mask=*) ISCSI_TGT_CM="${OPTARG#*=}" ;;
|
|
|
|
*)
|
|
|
|
usage $0 echo "Invalid argument '$OPTARG'"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
h)
|
|
|
|
usage $0
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage $0 "Invalid argument '$optchar'"
|
|
|
|
exit 1
|
|
|
|
;;
|
2018-03-22 04:02:17 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$TARGET_IP" ]; then
|
|
|
|
error "No IP address of iscsi target is given"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$INITIATOR_IP" ]; then
|
|
|
|
error "No IP address of iscsi initiator is given"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$IP_I_SSH" ]; then
|
|
|
|
error "No IP address of initiator is given"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $EUID -ne 0 ]; then
|
|
|
|
error "INFO: This script must be run with root privileges"
|
|
|
|
fi
|
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function ssh_initiator() {
|
2020-05-14 08:33:11 +00:00
|
|
|
# shellcheck disable=SC2029
|
|
|
|
# (we want to expand $@ immediately, not on the VM)
|
2018-03-22 04:02:17 +00:00
|
|
|
ssh -i $HOME/.ssh/spdk_vhost_id_rsa root@$IP_I_SSH "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
NETMASK=$INITIATOR_IP/32
|
|
|
|
iscsi_fio_results="$testdir/perf_output/iscsi_fio.json"
|
|
|
|
rm -rf $iscsi_fio_results
|
|
|
|
mkdir -p $testdir/perf_output
|
|
|
|
touch $iscsi_fio_results
|
|
|
|
|
|
|
|
timing_enter run_iscsi_app
|
2020-05-11 21:15:03 +00:00
|
|
|
$SPDK_BIN_DIR/iscsi_tgt -m $ISCSI_TGT_CM -r $testdir/rpc_iscsi.sock --wait-for-rpc &
|
2018-03-22 04:02:17 +00:00
|
|
|
pid=$!
|
2019-08-09 08:46:01 +00:00
|
|
|
trap 'rm -f $testdir/perf.job; killprocess $pid; print_backtrace; exit 1' ERR SIGTERM SIGABRT
|
2018-03-22 04:02:17 +00:00
|
|
|
waitforlisten "$pid" "$testdir/rpc_iscsi.sock"
|
2019-09-11 11:15:34 +00:00
|
|
|
$rpc_py iscsi_set_options -b "iqn.2016-06.io.spdk" -f "/usr/local/etc/spdk/auth.conf" -o 30 -i -l 0 -a 16
|
2019-09-11 13:30:14 +00:00
|
|
|
$rpc_py framework_start_init
|
2020-10-21 10:59:09 +00:00
|
|
|
$rootdir/scripts/gen_nvme.sh | $rpc_py load_subsystem_config
|
2018-03-22 04:02:17 +00:00
|
|
|
sleep 1
|
|
|
|
timing_exit run_iscsi_app
|
|
|
|
|
|
|
|
timing_enter iscsi_config
|
2019-09-11 09:29:55 +00:00
|
|
|
bdevs=($($rpc_py bdev_get_bdevs | jq -r '.[].name'))
|
2019-09-30 09:24:11 +00:00
|
|
|
if [[ $DISKNO == "ALL" ]] || [[ $DISKNO == "all" ]]; then
|
2018-03-22 04:02:17 +00:00
|
|
|
DISKNO=${#bdevs[@]}
|
2019-09-30 09:24:11 +00:00
|
|
|
elif [[ $DISKNO -gt ${#bdevs[@]} ]] || [[ ! $DISKNO =~ ^[0-9]+$ ]]; then
|
2018-03-22 04:02:17 +00:00
|
|
|
error "Required device number ($DISKNO) is not a valid number or it's larger than the number of devices found (${#bdevs[@]})"
|
|
|
|
fi
|
|
|
|
|
2019-09-09 10:35:30 +00:00
|
|
|
$rpc_py iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT
|
2019-09-03 08:53:37 +00:00
|
|
|
$rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
|
2018-03-22 04:02:17 +00:00
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
for ((i = 0; i < DISKNO; i++)); do
|
2019-09-05 10:35:18 +00:00
|
|
|
$rpc_py iscsi_create_target_node Target${i} Target${i}_alias "${bdevs[i]}:0" "$PORTAL_TAG:$INITIATOR_TAG" 64 -d
|
2018-03-22 04:02:17 +00:00
|
|
|
done
|
|
|
|
|
2020-01-14 12:03:17 +00:00
|
|
|
ssh_initiator "cat > perf.job" < $testdir/perf.job
|
2018-03-22 04:02:17 +00:00
|
|
|
rm -f $testdir/perf.job
|
|
|
|
timing_exit iscsi_config
|
|
|
|
|
|
|
|
timing_enter iscsi_initiator
|
2020-05-07 11:27:06 +00:00
|
|
|
ssh_initiator bash -s - $FIO_PATH $TARGET_IP < $testdir/iscsi_initiator.sh
|
2018-03-22 04:02:17 +00:00
|
|
|
timing_exit iscsi_initiator
|
|
|
|
|
|
|
|
ssh_initiator "cat perf_output/iscsi_fio.json" > $iscsi_fio_results
|
|
|
|
ssh_initiator "rm -rf perf_output perf.job"
|
|
|
|
|
|
|
|
killprocess $pid
|