2018-05-08 02:11:10 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
testdir=$(readlink -f $(dirname $0))
|
|
|
|
rootdir=$(readlink -f $testdir/../../..)
|
|
|
|
source $rootdir/test/common/autotest_common.sh
|
|
|
|
source $rootdir/test/iscsi_tgt/common.sh
|
|
|
|
|
2019-05-06 22:46:30 +00:00
|
|
|
# $1 = "iso" - triggers isolation mode (setting up required environment).
|
|
|
|
# $2 = test type posix or vpp. defaults to posix.
|
|
|
|
iscsitestinit $1 $2
|
|
|
|
|
2019-04-24 12:59:33 +00:00
|
|
|
function run_fio() {
|
|
|
|
local bdev_name=$1
|
2019-09-11 08:28:07 +00:00
|
|
|
local iostats=$($rpc_py bdev_get_iostat -b $bdev_name)
|
2019-04-24 12:59:33 +00:00
|
|
|
local run_time=5
|
|
|
|
|
|
|
|
local start_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats")
|
|
|
|
local start_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats")
|
|
|
|
|
2019-05-24 22:58:19 +00:00
|
|
|
$fio_py -p iscsi -i 1024 -d 128 -t randread -r $run_time
|
2019-04-24 12:59:33 +00:00
|
|
|
|
2019-09-11 08:28:07 +00:00
|
|
|
iostats=$($rpc_py bdev_get_iostat -b $bdev_name)
|
2019-04-24 12:59:33 +00:00
|
|
|
local end_io_count=$(jq -r '.bdevs[0].num_read_ops' <<< "$iostats")
|
|
|
|
local end_bytes_read=$(jq -r '.bdevs[0].bytes_read' <<< "$iostats")
|
|
|
|
|
2019-11-05 09:28:35 +00:00
|
|
|
IOPS_RESULT=$(((end_io_count-start_io_count)/run_time))
|
|
|
|
BANDWIDTH_RESULT=$(((end_bytes_read-start_bytes_read)/run_time))
|
2019-04-24 12:59:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function verify_qos_limits() {
|
|
|
|
local result=$1
|
|
|
|
local limit=$2
|
|
|
|
|
|
|
|
[ "$(bc <<< "$result > $limit*0.85")" -eq 1 ] && \
|
|
|
|
[ "$(bc <<< "$result < $limit*1.05")" -eq 1 ]
|
2018-05-08 02:11:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z "$TARGET_IP" ]; then
|
|
|
|
echo "TARGET_IP not defined in environment"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$INITIATOR_IP" ]; then
|
|
|
|
echo "INITIATOR_IP not defined in environment"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
timing_enter qos
|
|
|
|
|
|
|
|
MALLOC_BDEV_SIZE=64
|
2018-08-27 20:51:55 +00:00
|
|
|
MALLOC_BLOCK_SIZE=512
|
2019-04-24 11:20:29 +00:00
|
|
|
IOPS_RESULT=
|
|
|
|
BANDWIDTH_RESULT=
|
2018-09-11 13:26:14 +00:00
|
|
|
rpc_py="$rootdir/scripts/rpc.py"
|
|
|
|
fio_py="$rootdir/scripts/fio.py"
|
2018-05-08 02:11:10 +00:00
|
|
|
|
|
|
|
timing_enter start_iscsi_tgt
|
|
|
|
|
|
|
|
$ISCSI_APP &
|
|
|
|
pid=$!
|
|
|
|
echo "Process pid: $pid"
|
2019-08-09 08:46:01 +00:00
|
|
|
trap 'killprocess $pid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT
|
2018-05-08 02:11:10 +00:00
|
|
|
waitforlisten $pid
|
|
|
|
echo "iscsi_tgt is listening. Running tests..."
|
|
|
|
|
|
|
|
timing_exit start_iscsi_tgt
|
|
|
|
|
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
|
2019-08-09 11:15:35 +00:00
|
|
|
$rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE
|
2018-05-08 02:11:10 +00:00
|
|
|
# "Malloc0:0" ==> use Malloc0 blockdev for LUN0
|
|
|
|
# "1:2" ==> map PortalGroup1 to InitiatorGroup2
|
|
|
|
# "64" ==> iSCSI queue depth 64
|
|
|
|
# "-d" ==> disable CHAP authentication
|
2019-09-05 10:35:18 +00:00
|
|
|
$rpc_py iscsi_create_target_node Target1 Target1_alias 'Malloc0:0' $PORTAL_TAG:$INITIATOR_TAG 64 -d
|
2018-05-08 02:11:10 +00:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
|
|
|
|
iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
|
|
|
|
|
2019-08-09 08:46:01 +00:00
|
|
|
trap 'iscsicleanup; killprocess $pid; iscsitestfini $1 $2; exit 1' SIGINT SIGTERM EXIT
|
2018-05-08 02:11:10 +00:00
|
|
|
|
2019-04-24 11:20:29 +00:00
|
|
|
# Run FIO without any QOS limits to determine the raw performance
|
2019-04-24 12:59:33 +00:00
|
|
|
run_fio Malloc0
|
2019-03-06 20:02:15 +00:00
|
|
|
|
2019-04-24 11:20:29 +00:00
|
|
|
# Set IOPS/bandwidth limit to 50% of the actual unrestrained performance.
|
2019-11-05 09:28:35 +00:00
|
|
|
IOPS_LIMIT=$((IOPS_RESULT/2))
|
|
|
|
BANDWIDTH_LIMIT=$((BANDWIDTH_RESULT/2))
|
2019-04-24 11:20:29 +00:00
|
|
|
# Set READ bandwidth limit to 50% of the RW bandwidth limit to be able
|
|
|
|
# to differentiate those two.
|
2019-11-05 09:28:35 +00:00
|
|
|
READ_BANDWIDTH_LIMIT=$((BANDWIDTH_LIMIT/2))
|
2018-05-08 02:11:10 +00:00
|
|
|
|
2019-04-24 11:20:29 +00:00
|
|
|
# Also round them down to nearest multiple of either 1000 IOPS or 1MB BW
|
|
|
|
# which are the minimal QoS granularities
|
2019-11-05 09:28:35 +00:00
|
|
|
IOPS_LIMIT=$((IOPS_LIMIT/1000*1000))
|
|
|
|
BANDWIDTH_LIMIT_MB=$((BANDWIDTH_LIMIT/1024/1024))
|
|
|
|
BANDWIDTH_LIMIT=$((BANDWIDTH_LIMIT_MB*1024*1024))
|
|
|
|
READ_BANDWIDTH_LIMIT_MB=$((READ_BANDWIDTH_LIMIT/1024/1024))
|
|
|
|
READ_BANDWIDTH_LIMIT=$((READ_BANDWIDTH_LIMIT_MB*1024*1024))
|
2018-05-08 02:11:10 +00:00
|
|
|
|
2019-04-24 11:20:29 +00:00
|
|
|
# Limit the I/O rate by RPC, then confirm the observed rate matches.
|
2019-09-11 10:32:34 +00:00
|
|
|
$rpc_py bdev_set_qos_limit Malloc0 --rw_ios_per_sec $IOPS_LIMIT
|
2019-04-24 12:59:33 +00:00
|
|
|
run_fio Malloc0
|
|
|
|
verify_qos_limits $IOPS_RESULT $IOPS_LIMIT
|
2018-05-08 02:11:10 +00:00
|
|
|
|
2019-04-24 11:20:29 +00:00
|
|
|
# Now disable the rate limiting, and confirm the observed rate is not limited anymore.
|
2019-09-11 10:32:34 +00:00
|
|
|
$rpc_py bdev_set_qos_limit Malloc0 --rw_ios_per_sec 0
|
2019-04-24 12:59:33 +00:00
|
|
|
run_fio Malloc0
|
|
|
|
[ "$IOPS_RESULT" -gt "$IOPS_LIMIT" ]
|
2018-11-06 12:34:17 +00:00
|
|
|
|
2019-04-24 11:20:29 +00:00
|
|
|
# Limit the I/O rate again.
|
2019-09-11 10:32:34 +00:00
|
|
|
$rpc_py bdev_set_qos_limit Malloc0 --rw_ios_per_sec $IOPS_LIMIT
|
2019-04-24 12:59:33 +00:00
|
|
|
run_fio Malloc0
|
|
|
|
verify_qos_limits $IOPS_RESULT $IOPS_LIMIT
|
|
|
|
|
2019-04-24 11:20:29 +00:00
|
|
|
echo "I/O rate limiting tests successful"
|
2018-11-06 12:34:17 +00:00
|
|
|
|
2019-04-24 11:20:29 +00:00
|
|
|
# Limit the I/O bandwidth rate by RPC, then confirm the observed rate matches.
|
2019-09-11 10:32:34 +00:00
|
|
|
$rpc_py bdev_set_qos_limit Malloc0 --rw_ios_per_sec 0 --rw_mbytes_per_sec $BANDWIDTH_LIMIT_MB
|
2019-04-24 12:59:33 +00:00
|
|
|
run_fio Malloc0
|
|
|
|
verify_qos_limits $BANDWIDTH_RESULT $BANDWIDTH_LIMIT
|
2019-04-24 11:20:29 +00:00
|
|
|
|
|
|
|
# Now disable the bandwidth rate limiting, and confirm the observed rate is not limited anymore.
|
2019-09-11 10:32:34 +00:00
|
|
|
$rpc_py bdev_set_qos_limit Malloc0 --rw_mbytes_per_sec 0
|
2019-04-24 12:59:33 +00:00
|
|
|
run_fio Malloc0
|
|
|
|
[ "$BANDWIDTH_RESULT" -gt "$BANDWIDTH_LIMIT" ]
|
2019-04-24 11:20:29 +00:00
|
|
|
|
|
|
|
# Limit the I/O bandwidth rate again with both read/write and read/only.
|
2019-09-11 10:32:34 +00:00
|
|
|
$rpc_py bdev_set_qos_limit Malloc0 --rw_mbytes_per_sec $BANDWIDTH_LIMIT_MB --r_mbytes_per_sec $READ_BANDWIDTH_LIMIT_MB
|
2019-04-24 12:59:33 +00:00
|
|
|
run_fio Malloc0
|
|
|
|
verify_qos_limits $BANDWIDTH_RESULT $READ_BANDWIDTH_LIMIT
|
|
|
|
|
2019-04-24 11:20:29 +00:00
|
|
|
echo "I/O bandwidth limiting tests successful"
|
2018-11-06 12:34:17 +00:00
|
|
|
|
2018-05-08 02:11:10 +00:00
|
|
|
iscsicleanup
|
2019-09-05 10:52:14 +00:00
|
|
|
$rpc_py iscsi_delete_target_node 'iqn.2016-06.io.spdk:Target1'
|
2018-05-08 02:11:10 +00:00
|
|
|
|
|
|
|
rm -f ./local-job0-0-verify.state
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
killprocess $pid
|
|
|
|
|
2019-05-06 22:46:30 +00:00
|
|
|
iscsitestfini $1 $2
|
2018-05-08 02:11:10 +00:00
|
|
|
timing_exit qos
|