1#!/usr/bin/env bash 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright (C) 2022 Intel Corporation 4# All rights reserved. 5# 6 7testdir=$(readlink -f $(dirname $0)) 8rootdir=$(readlink -f $testdir/../../..) 9source $rootdir/test/common/autotest_common.sh 10source $rootdir/test/iscsi_tgt/common.sh 11 12iscsitestinit 13 14BDEV_SIZE=64 15BDEV_NEW_SIZE=128 16BLOCK_SIZE=512 17RESIZE_SOCK="/var/tmp/spdk-resize.sock" 18 19timing_enter start_iscsi_tgt 20 21# Remove the sock file first 22rm -f $RESIZE_SOCK 23 24"${ISCSI_APP[@]}" -m 0x2 -p 1 -s 512 --wait-for-rpc & 25pid=$! 26echo "iSCSI target launched. pid: $pid" 27trap 'killprocess $pid; iscsitestfini; exit 1' SIGINT SIGTERM EXIT 28waitforlisten $pid 29$rpc_py framework_start_init 30echo "iscsi_tgt is listening. Running tests..." 31 32timing_exit start_iscsi_tgt 33 34$rpc_py iscsi_create_portal_group $PORTAL_TAG $TARGET_IP:$ISCSI_PORT 35$rpc_py iscsi_create_initiator_group $INITIATOR_TAG $INITIATOR_NAME $NETMASK 36$rpc_py bdev_null_create Null0 $BDEV_SIZE $BLOCK_SIZE 37# "Null0:0" ==> use Null0 blockdev for LUN0 38# "1:2" ==> map PortalGroup1 to InitiatorGroup2 39# "64" ==> iSCSI queue depth 64 40# "-d" ==> disable CHAP authentication 41$rpc_py iscsi_create_target_node disk1 disk1_alias 'Null0:0' $PORTAL_TAG:$INITIATOR_TAG 256 -d 42sleep 1 43trap 'killprocess $pid; iscsitestfini; exit 1' SIGINT SIGTERM EXIT 44 45# Start bdevperf with another sock file and iSCSI initiator 46"$rootdir/build/examples/bdevperf" -r $RESIZE_SOCK --json <(initiator_json_config) -q 16 -o 4096 -w read -t 5 -R -s 128 -z & 47bdevperf_pid=$! 48waitforlisten $bdevperf_pid $RESIZE_SOCK 49# Resize the Bdev from iSCSI target 50$rpc_py bdev_null_resize Null0 $BDEV_NEW_SIZE 51# Obtain the Bdev from bdevperf with iSCSI initiator 52num_block=$($rpc_py -s $RESIZE_SOCK bdev_get_bdevs | grep num_blocks | sed 's/[^[:digit:]]//g') 53# Size is not changed as no IO sent yet and resize notification is deferred. 54total_size=$((num_block * BLOCK_SIZE / 1048576)) 55if [ $total_size != $BDEV_SIZE ]; then 56 echo "resize failed" 57 exit 1 58fi 59sleep 2 60# Start the bdevperf IO 61$rootdir/examples/bdev/bdevperf/bdevperf.py -s $RESIZE_SOCK perform_tests 62# Obtain the Bdev from bdevperf with iSCSI initiator 63num_block=$($rpc_py -s $RESIZE_SOCK bdev_get_bdevs | grep num_blocks | sed 's/[^[:digit:]]//g') 64# Get the new bdev size in MiB. 65total_size=$((num_block * BLOCK_SIZE / 1048576)) 66if [ $total_size != $BDEV_NEW_SIZE ]; then 67 echo "resize failed" 68 exit 1 69fi 70 71trap - SIGINT SIGTERM EXIT 72killprocess $bdevperf_pid 73killprocess $pid 74 75iscsitestfini 76