1#!/usr/bin/env bash 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright (C) 2016 Intel Corporation 4# All rights reserved. 5# 6testdir=$(readlink -f $(dirname $0)) 7rootdir=$(readlink -f $testdir/../../..) 8source $rootdir/test/common/autotest_common.sh 9source $rootdir/test/nvmf/common.sh 10 11MALLOC_BDEV_SIZE=64 12MALLOC_BLOCK_SIZE=512 13 14rpc_py="$rootdir/scripts/rpc.py" 15 16nvmftestinit 17nvmfappstart -m 0xF 18 19$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 20 21malloc_bdevs="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) " 22malloc_bdevs+="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)" 23# Create a RAID-0 bdev from two malloc bdevs 24raid_malloc_bdevs="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) " 25raid_malloc_bdevs+="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)" 26$rpc_py bdev_raid_create -n raid0 -z 64 -r 0 -b "$raid_malloc_bdevs" 27 28#Create a Concat bdev from three malloc bdevs 29concat_malloc_bdevs="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) " 30concat_malloc_bdevs+="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) " 31concat_malloc_bdevs+="$($rpc_py bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)" 32$rpc_py bdev_raid_create -n concat0 -r concat -z 64 -b "$concat_malloc_bdevs" 33 34$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s $NVMF_SERIAL 35for malloc_bdev in $malloc_bdevs; do 36 $rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 "$malloc_bdev" 37done 38$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT 39 40# Append the raid0 bdev into subsystem 41$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 raid0 42 43# Append the concat0 bdev into subsystem 44$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 concat0 45 46$NVME_CONNECT -t $TEST_TRANSPORT -n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT" 47 48waitforserial $NVMF_SERIAL 4 49 50$rootdir/scripts/fio-wrapper -p nvmf -i 4096 -d 1 -t write -r 1 -v 51$rootdir/scripts/fio-wrapper -p nvmf -i 4096 -d 1 -t randwrite -r 1 -v 52$rootdir/scripts/fio-wrapper -p nvmf -i 4096 -d 128 -t write -r 1 -v 53$rootdir/scripts/fio-wrapper -p nvmf -i 4096 -d 128 -t randwrite -r 1 -v 54 55sync 56 57#start hotplug test case 58$rootdir/scripts/fio-wrapper -p nvmf -i 4096 -d 1 -t read -r 10 & 59fio_pid=$! 60 61sleep 3 62 63$rpc_py bdev_raid_delete "concat0" 64$rpc_py bdev_raid_delete "raid0" 65for malloc_bdev in $malloc_bdevs $raid_malloc_bdevs $concat_malloc_bdevs; do 66 $rpc_py bdev_malloc_delete "$malloc_bdev" 67done 68 69fio_status=0 70wait $fio_pid || fio_status=$? 71 72nvme disconnect -n "nqn.2016-06.io.spdk:cnode1" || true 73waitforserial_disconnect "$NVMF_SERIAL" 74 75if [ $fio_status -eq 0 ]; then 76 echo "nvmf hotplug test: fio successful - expected failure" 77 nvmftestfini 78 exit 1 79else 80 echo "nvmf hotplug test: fio failed as expected" 81fi 82 83$rpc_py nvmf_delete_subsystem nqn.2016-06.io.spdk:cnode1 84 85rm -f ./local-job0-0-verify.state 86rm -f ./local-job1-1-verify.state 87rm -f ./local-job2-2-verify.state 88 89trap - SIGINT SIGTERM EXIT 90 91nvmftestfini 92