2016-10-11 23:42:35 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-11-02 15:49:40 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright (C) 2016 Intel Corporation
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
2016-10-11 23:42:35 +00:00
|
|
|
testdir=$(readlink -f $(dirname $0))
|
2017-04-04 23:20:16 +00:00
|
|
|
rootdir=$(readlink -f $testdir/../../..)
|
2018-02-27 22:14:08 +00:00
|
|
|
source $rootdir/test/common/autotest_common.sh
|
2017-05-24 23:29:24 +00:00
|
|
|
source $rootdir/test/iscsi_tgt/common.sh
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2020-08-11 10:36:11 +00:00
|
|
|
iscsitestinit
|
2019-05-06 22:46:30 +00:00
|
|
|
|
2022-09-05 10:48:41 +00:00
|
|
|
# Declare rpc_py here, because its default value points to rpc_cmd function,
|
|
|
|
# which does not tolerate piping arguments into it.
|
|
|
|
rpc_py="$rootdir/scripts/rpc.py"
|
2019-01-31 12:51:30 +00:00
|
|
|
node_base="iqn.2013-06.com.intel.ch.spdk"
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2017-05-25 20:06:51 +00:00
|
|
|
timing_enter start_iscsi_tgt
|
|
|
|
|
2020-02-20 10:24:53 +00:00
|
|
|
"${ISCSI_APP[@]}" --wait-for-rpc &
|
2016-10-11 23:42:35 +00:00
|
|
|
pid=$!
|
|
|
|
echo "Process pid: $pid"
|
|
|
|
|
2020-08-11 10:36:11 +00:00
|
|
|
trap '$rpc_py bdev_split_delete Name0n1 || true; killprocess $pid; iscsitestfini; exit 1' SIGINT SIGTERM EXIT
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2017-11-09 23:33:29 +00:00
|
|
|
waitforlisten $pid
|
2019-09-11 11:15:34 +00:00
|
|
|
$rpc_py iscsi_set_options -o 30 -a 4 -b $node_base
|
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
|
2019-08-09 11:15:35 +00:00
|
|
|
$rpc_py bdev_malloc_create 512 4096 --name Malloc0
|
2016-10-11 23:42:35 +00:00
|
|
|
echo "iscsi_tgt is listening. Running tests..."
|
|
|
|
|
2017-05-25 20:06:51 +00:00
|
|
|
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-16 09:58:53 +00:00
|
|
|
$rpc_py bdev_error_create 'Malloc0'
|
2016-10-11 23:42:35 +00:00
|
|
|
# "1:2" ==> map PortalGroup1 to InitiatorGroup2
|
|
|
|
# "64" ==> iSCSI queue depth 64
|
2018-03-12 04:41:21 +00:00
|
|
|
# "-d" ==> disable CHAP authentication
|
2019-09-05 10:35:18 +00:00
|
|
|
$rpc_py iscsi_create_target_node Target0 Target0_alias EE_Malloc0:0 1:2 64 -d
|
2016-10-11 23:42:35 +00:00
|
|
|
sleep 1
|
|
|
|
|
2018-03-27 13:39:38 +00:00
|
|
|
iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
|
|
|
|
iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
|
2019-06-17 07:23:20 +00:00
|
|
|
waitforiscsidevices 1
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2019-09-16 09:23:41 +00:00
|
|
|
trap 'for new_dir in $(dir -d /mnt/*dir); do umount $new_dir; rm -rf $new_dir; done;
|
2020-08-11 10:36:11 +00:00
|
|
|
iscsicleanup; killprocess $pid; iscsitestfini; exit 1' SIGINT SIGTERM EXIT
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2017-05-22 07:34:02 +00:00
|
|
|
echo "Test error injection"
|
2019-08-16 09:58:53 +00:00
|
|
|
$rpc_py bdev_error_inject_error EE_Malloc0 'all' 'failure' -n 1000
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2017-05-22 07:34:02 +00:00
|
|
|
dev=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2017-03-17 06:10:32 +00:00
|
|
|
set +e
|
2020-03-06 11:47:48 +00:00
|
|
|
waitforfile /dev/${dev}
|
|
|
|
if make_filesystem ext4 /dev/${dev}; then
|
2017-05-22 07:34:02 +00:00
|
|
|
echo "mkfs successful - expected failure"
|
|
|
|
iscsicleanup
|
|
|
|
killprocess $pid
|
|
|
|
exit 1
|
2017-03-17 06:10:32 +00:00
|
|
|
else
|
2017-05-22 07:34:02 +00:00
|
|
|
echo "mkfs failed as expected"
|
2017-03-17 06:10:32 +00:00
|
|
|
fi
|
|
|
|
set -e
|
|
|
|
|
2019-01-31 12:51:30 +00:00
|
|
|
iscsicleanup
|
2019-08-16 09:58:53 +00:00
|
|
|
$rpc_py bdev_error_inject_error EE_Malloc0 'clear' 'failure'
|
2019-09-05 10:52:14 +00:00
|
|
|
$rpc_py iscsi_delete_target_node $node_base:Target0
|
2017-05-22 07:34:02 +00:00
|
|
|
echo "Error injection test done"
|
|
|
|
|
|
|
|
if [ -z "$NO_NVME" ]; then
|
2019-07-08 04:31:44 +00:00
|
|
|
bdev_size=$(get_bdev_size Nvme0n1)
|
2020-05-07 11:27:06 +00:00
|
|
|
split_size=$((bdev_size / 2))
|
2019-07-08 04:31:44 +00:00
|
|
|
if [ $split_size -gt 10000 ]; then
|
|
|
|
split_size=10000
|
|
|
|
fi
|
2019-09-11 11:10:43 +00:00
|
|
|
$rpc_py bdev_split_create Nvme0n1 2 -s $split_size
|
2019-09-05 10:35:18 +00:00
|
|
|
$rpc_py iscsi_create_target_node Target1 Target1_alias Nvme0n1p0:0 1:2 64 -d
|
2017-03-17 06:10:32 +00:00
|
|
|
fi
|
|
|
|
|
2018-03-27 13:39:38 +00:00
|
|
|
iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$ISCSI_PORT
|
|
|
|
iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
|
2019-06-17 07:23:20 +00:00
|
|
|
waitforiscsidevices 1
|
2017-05-22 07:34:02 +00:00
|
|
|
|
|
|
|
devs=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
|
2017-03-17 06:10:32 +00:00
|
|
|
|
2016-10-11 23:42:35 +00:00
|
|
|
for dev in $devs; do
|
2020-03-06 11:47:48 +00:00
|
|
|
make_filesystem ext4 /dev/${dev}
|
2016-10-11 23:42:35 +00:00
|
|
|
mkdir -p /mnt/${dev}dir
|
2020-03-06 11:47:48 +00:00
|
|
|
mount -o sync /dev/${dev} /mnt/${dev}dir
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2018-10-15 19:54:38 +00:00
|
|
|
rsync -qav --exclude=".git" --exclude="*.o" $rootdir/ /mnt/${dev}dir/spdk
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2017-06-01 20:11:08 +00:00
|
|
|
make -C /mnt/${dev}dir/spdk clean
|
2020-04-09 17:54:24 +00:00
|
|
|
(cd /mnt/${dev}dir/spdk && ./configure $(get_config_params))
|
2017-06-01 20:11:08 +00:00
|
|
|
make -C /mnt/${dev}dir/spdk -j16
|
2016-10-11 23:42:35 +00:00
|
|
|
|
|
|
|
# Print out space consumed on target device to help decide
|
|
|
|
# if/when we need to increase the size of the malloc LUN
|
|
|
|
df -h /dev/$dev
|
|
|
|
|
|
|
|
rm -rf /mnt/${dev}dir/spdk
|
|
|
|
done
|
|
|
|
|
|
|
|
for dev in $devs; do
|
|
|
|
umount /mnt/${dev}dir
|
|
|
|
rm -rf /mnt/${dev}dir
|
2016-10-13 15:41:59 +00:00
|
|
|
|
2018-04-18 08:36:46 +00:00
|
|
|
stats=($(cat /sys/block/$dev/stat))
|
2016-10-13 15:41:59 +00:00
|
|
|
echo ""
|
|
|
|
echo "$dev stats"
|
|
|
|
printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \
|
2018-04-18 08:36:46 +00:00
|
|
|
${stats[0]} ${stats[1]} ${stats[2]} ${stats[3]}
|
2016-10-13 15:41:59 +00:00
|
|
|
printf "WRITE IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \
|
2018-04-18 08:36:46 +00:00
|
|
|
${stats[4]} ${stats[5]} ${stats[6]} ${stats[7]}
|
2016-10-13 15:41:59 +00:00
|
|
|
printf "in flight: % 8u io ticks: % 8u time in queue: % 8u\n" \
|
2018-04-18 08:36:46 +00:00
|
|
|
${stats[8]} ${stats[9]} ${stats[10]}
|
2016-10-13 15:41:59 +00:00
|
|
|
echo ""
|
2016-10-11 23:42:35 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
iscsicleanup
|
2019-09-11 11:44:17 +00:00
|
|
|
$rpc_py bdev_split_delete Nvme0n1
|
2019-08-16 09:58:53 +00:00
|
|
|
$rpc_py bdev_error_delete EE_Malloc0
|
2018-07-26 12:54:20 +00:00
|
|
|
|
|
|
|
if [ -z "$NO_NVME" ]; then
|
2019-08-23 15:12:13 +00:00
|
|
|
$rpc_py bdev_nvme_detach_controller Nvme0
|
2018-07-26 12:54:20 +00:00
|
|
|
fi
|
|
|
|
|
2016-10-11 23:42:35 +00:00
|
|
|
killprocess $pid
|
2020-08-11 10:36:11 +00:00
|
|
|
iscsitestfini
|