2016-10-11 23:42:35 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
testdir=$(readlink -f $(dirname $0))
|
2017-04-04 23:20:16 +00:00
|
|
|
rootdir=$(readlink -f $testdir/../../..)
|
2016-10-11 23:42:35 +00:00
|
|
|
source $rootdir/scripts/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
|
|
|
|
|
|
|
if [ ! -z $1 ]; then
|
|
|
|
DPDK_DIR=$(readlink -f $1)
|
|
|
|
fi
|
|
|
|
|
|
|
|
timing_enter ext4test
|
|
|
|
|
2017-01-25 23:36:40 +00:00
|
|
|
cp $testdir/iscsi.conf.in $testdir/iscsi.conf
|
|
|
|
$rootdir/scripts/gen_nvme.sh >> $testdir/iscsi.conf
|
|
|
|
|
2016-10-11 23:42:35 +00:00
|
|
|
# iSCSI target configuration
|
|
|
|
PORT=3260
|
|
|
|
RPC_PORT=5260
|
|
|
|
INITIATOR_TAG=2
|
|
|
|
INITIATOR_NAME=ALL
|
|
|
|
NETMASK=$INITIATOR_IP/32
|
|
|
|
|
|
|
|
rpc_py="python $rootdir/scripts/rpc.py"
|
|
|
|
|
2017-05-25 20:06:51 +00:00
|
|
|
timing_enter start_iscsi_tgt
|
|
|
|
|
2016-11-23 19:23:56 +00:00
|
|
|
$ISCSI_APP -c $testdir/iscsi.conf &
|
2016-10-11 23:42:35 +00:00
|
|
|
pid=$!
|
|
|
|
echo "Process pid: $pid"
|
|
|
|
|
|
|
|
trap "killprocess $pid; exit 1" SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
waitforlisten $pid ${RPC_PORT}
|
|
|
|
echo "iscsi_tgt is listening. Running tests..."
|
|
|
|
|
2017-05-25 20:06:51 +00:00
|
|
|
timing_exit start_iscsi_tgt
|
|
|
|
|
2016-10-11 23:42:35 +00:00
|
|
|
$rpc_py add_portal_group 1 $TARGET_IP:$PORT
|
|
|
|
$rpc_py add_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK
|
2017-03-17 06:10:32 +00:00
|
|
|
$rpc_py construct_error_bdev 'Malloc0'
|
2016-10-11 23:42:35 +00:00
|
|
|
# "1:2" ==> map PortalGroup1 to InitiatorGroup2
|
|
|
|
# "64" ==> iSCSI queue depth 64
|
|
|
|
# "1 0 0 0" ==> disable CHAP authentication
|
2016-11-23 19:23:56 +00:00
|
|
|
if [ -z "$NO_NVME" ]; then
|
2016-08-29 22:00:32 +00:00
|
|
|
$rpc_py construct_target_node Target0 Target0_alias Nvme0n1:0 1:2 64 1 0 0 0
|
2016-11-23 19:23:56 +00:00
|
|
|
fi
|
2017-03-17 06:10:32 +00:00
|
|
|
$rpc_py construct_target_node Target1 Target1_alias EE_Malloc0:0 1:2 64 1 0 0 0
|
2016-10-11 23:42:35 +00:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$PORT
|
|
|
|
iscsiadm -m node --login -p $TARGET_IP:$PORT
|
|
|
|
|
|
|
|
trap 'for new_dir in `dir -d /mnt/*dir`; do umount $new_dir; rm -rf $new_dir; done; \
|
|
|
|
iscsicleanup; killprocess $pid; exit 1' SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
2017-03-17 06:10:32 +00:00
|
|
|
$rpc_py bdev_inject_error 'all' -n 1000
|
2016-10-11 23:42:35 +00:00
|
|
|
|
|
|
|
devs=$(iscsiadm -m session -P 3 | grep "Attached scsi disk" | awk '{print $4}')
|
|
|
|
|
2017-03-17 06:10:32 +00:00
|
|
|
declare -i failcount=0
|
|
|
|
set +e
|
|
|
|
for dev in $devs; do
|
|
|
|
mkfs.ext4 -F /dev/$dev
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "mkfs successful"
|
|
|
|
else
|
|
|
|
echo "mkfs failed"
|
|
|
|
failcount+=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ $failcount -eq 1 ]; then
|
|
|
|
echo "error injection success"
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
$rpc_py bdev_inject_error 'clear'
|
|
|
|
|
2016-10-11 23:42:35 +00:00
|
|
|
for dev in $devs; do
|
|
|
|
mkfs.ext4 -F /dev/$dev
|
|
|
|
mkdir -p /mnt/${dev}dir
|
2016-10-13 15:41:59 +00:00
|
|
|
mount -o sync /dev/$dev /mnt/${dev}dir
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2017-05-23 21:29:22 +00:00
|
|
|
rsync -qav --exclude=".git" --exclude="dpdk" $rootdir/ /mnt/${dev}dir/spdk
|
2016-10-11 23:42:35 +00:00
|
|
|
|
2016-10-13 15:41:59 +00:00
|
|
|
make -C /mnt/${dev}dir/spdk DPDK_DIR=$DPDK_DIR clean
|
|
|
|
make -C /mnt/${dev}dir/spdk DPDK_DIR=$DPDK_DIR -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
|
|
|
|
|
|
|
stats=( $(cat /sys/block/$dev/stat) )
|
|
|
|
echo ""
|
|
|
|
echo "$dev stats"
|
|
|
|
printf "READ IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \
|
|
|
|
${stats[0]} ${stats[1]} ${stats[2]} ${stats[3]}
|
|
|
|
printf "WRITE IO cnt: % 8u merges: % 8u sectors: % 8u ticks: % 8u\n" \
|
|
|
|
${stats[4]} ${stats[5]} ${stats[6]} ${stats[7]}
|
|
|
|
printf "in flight: % 8u io ticks: % 8u time in queue: % 8u\n" \
|
|
|
|
${stats[8]} ${stats[9]} ${stats[10]}
|
|
|
|
echo ""
|
2016-10-11 23:42:35 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
|
2017-01-25 23:36:40 +00:00
|
|
|
rm -f $testdir/iscsi.conf
|
2016-10-11 23:42:35 +00:00
|
|
|
iscsicleanup
|
|
|
|
killprocess $pid
|
|
|
|
timing_exit ext4test
|