xref: /spdk/test/nvmf/target/wait_for_buf.sh (revision 260d18d143d309088d3b30dc49024c5cd64360ff)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2024 Dell Inc, or its subsidiaries.
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/nvmf/common.sh
11
12nvmftestinit
13nvmfappstart --wait-for-rpc
14
15subnqn="nqn.2024-07.io.spdk:cnode0"
16perf="$SPDK_BIN_DIR/spdk_nvme_perf"
17
18# set the number of available small iobuf entries low enough to trigger buffer allocation retry scenario
19$rpc_py accel_set_options --small-cache-size 0 --large-cache-size 0
20$rpc_py iobuf_set_options --small-pool-count 154 --small_bufsize=8192
21$rpc_py framework_start_init
22$rpc_py bdev_malloc_create -b Malloc0 32 512
23$rpc_py nvmf_create_transport "$NVMF_TRANSPORT_OPTS" -u 8192 -n 24 -b 24
24$rpc_py nvmf_create_subsystem "$subnqn" -a -s SPDK00000000000001
25$rpc_py nvmf_subsystem_add_ns "$subnqn" Malloc0
26$rpc_py nvmf_subsystem_add_listener "$subnqn" -t "$TEST_TRANSPORT" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
27
28# 131072 (io size) = 16*8192 (io_unit_size). We have 24 buffers available, so only the very first request can allocate
29# all required buffers at once, following requests must wait and go through the iobuf queuing scenario.
30$perf -q 4 -o 131072 -w randread -t 1 -r "trtype:${TEST_TRANSPORT} adrfam:IPv4 traddr:${NVMF_FIRST_TARGET_IP} trsvcid:${NVMF_PORT}"
31
32retry_count=$($rpc_py iobuf_get_stats | jq -r '.[] | select(.module == "nvmf_TCP") | .small_pool.retry')
33if [[ $retry_count -eq 0 ]]; then
34	return 1
35fi
36
37trap - SIGINT SIGTERM EXIT
38nvmftestfini
39