xref: /spdk/test/nvmf/target/zcopy.sh (revision 8000cedbe310faea476a70ce9edab027a0b20939)
1#!/usr/bin/env bash
2
3testdir=$(readlink -f $(dirname $0))
4rootdir=$(readlink -f $testdir/../../..)
5
6source $rootdir/test/common/autotest_common.sh
7source $rootdir/test/nvmf/common.sh
8
9nvmftestinit
10nvmfappstart -m 0x2
11
12if [ "$TEST_TRANSPORT" != tcp ]; then
13	echo "Unsupported transport: $TEST_TRANSPORT"
14	exit 0
15fi
16
17# Enable zero-copy and set in-capsule data size to zero to make sure all requests are using
18# zero-copy
19$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS -c 0 --zcopy
20
21$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 -m 10
22$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT \
23	-a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
24$rpc_py nvmf_subsystem_add_listener discovery -t $TEST_TRANSPORT \
25	-a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
26$rpc_py bdev_malloc_create 32 4096 -b malloc0
27$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 malloc0 -n 1
28
29# First send IO with verification
30$rootdir/build/examples/bdevperf --json <(gen_nvmf_target_json) \
31	-t 10 -q 128 -w verify -o 8192
32
33# Then send IO in the background while pausing/resuming the subsystem
34$rootdir/build/examples/bdevperf --json <(gen_nvmf_target_json) \
35	-t 5 -q 128 -w randrw -M 50 -o 8192 &
36perfpid=$!
37
38while kill -0 $perfpid; do
39	# Add the same namespace again.  It'll fail, but will also pause/resume the subsystem and
40	# the namespace forcing the IO requests to be queued/resubmitted.
41	$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 malloc0 -n 1 &> /dev/null || :
42done
43
44wait $perfpid
45
46# Verify that aborting requests serviced through zero-copy works too
47$rpc_py nvmf_subsystem_remove_ns nqn.2016-06.io.spdk:cnode1 1
48$rpc_py bdev_delay_create -b malloc0 -d delay0 -r 1000000 -t 1000000 -w 1000000 -n 1000000
49$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 delay0 -n 1
50
51$SPDK_EXAMPLE_DIR/abort -c 0x1 -t 5 -q 64 -w randrw -M 50 -l warning \
52	-r "trtype:$TEST_TRANSPORT adrfam:IPv4 traddr:$NVMF_FIRST_TARGET_IP trsvcid:$NVMF_PORT ns:1"
53
54trap - SIGINT SIGTERM EXIT
55nvmftestfini
56