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