xref: /spdk/test/ftl/fio.sh (revision 1b566ac7d9e9159257b881d7dc5675cd9b7e1961)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2018 Intel Corporation
4#  All rights reserved.
5#
6testdir=$(readlink -f $(dirname $0))
7rootdir=$(readlink -f $testdir/../..)
8source $rootdir/test/common/autotest_common.sh
9source $testdir/common.sh
10
11declare -A suite
12suite['basic']='randw-verify randw-verify-j2 randw-verify-depth128'
13suite['extended']='drive-prep randw-verify-qd128-ext randw-verify-qd2048-ext randw randr randrw unmap'
14suite['nightly']='drive-prep randw-verify-qd256-nght randw-verify-qd256-nght randw-verify-qd256-nght'
15
16rpc_py=$rootdir/scripts/rpc.py
17
18fio_kill() {
19	killprocess $svcpid
20	rm -f $FTL_JSON_CONF
21}
22
23device=$1
24cache_device=$2
25tests=${suite[$3]}
26uuid=$4
27timeout=240
28
29if [[ $CONFIG_FIO_PLUGIN != y ]]; then
30	echo "FIO not available"
31	exit 1
32fi
33
34if [ -z "$tests" ]; then
35	echo "Invalid test suite '$2'"
36	exit 1
37fi
38
39export FTL_BDEV_NAME=ftl0
40export FTL_JSON_CONF=$testdir/config/ftl.json
41
42trap "fio_kill; exit 1" SIGINT SIGTERM EXIT
43
44"$SPDK_BIN_DIR/spdk_tgt" -m 7 &
45svcpid=$!
46waitforlisten $svcpid
47
48split_bdev=$(create_base_bdev nvme0 $device $((1024 * 101)))
49nv_cache=$(create_nv_cache_bdev nvc0 $cache_device $split_bdev)
50
51l2p_percentage=60
52if [ $SPDK_TEST_FTL_NIGHTLY -eq 1 ]; then
53	l2p_percentage=12
54fi
55
56l2p_dram_size_mb=$(($(get_bdev_size $split_bdev) * l2p_percentage / 100 / 1024))
57
58if [ -z "$uuid" ]; then
59	# First FTL creation takes longer due to scrubbing, so extending the timeout
60	$rpc_py -t $timeout bdev_ftl_create -b ftl0 -d $split_bdev -c $nv_cache --l2p_dram_limit $l2p_dram_size_mb
61else
62	$rpc_py bdev_ftl_create -b ftl0 -d $split_bdev -c $nv_cache -u $uuid --l2p_dram_limit $l2p_dram_size_mb
63fi
64
65waitforbdev ftl0
66
67(
68	echo '{"subsystems": ['
69	$rpc_py save_subsystem_config -n bdev
70	echo ']}'
71) > $FTL_JSON_CONF
72
73$rpc_py bdev_ftl_unload -b ftl0
74
75killprocess $svcpid
76trap - SIGINT SIGTERM EXIT
77
78for test in ${tests}; do
79	timing_enter $test
80	fio_bdev $testdir/config/fio/$test.fio
81	timing_exit $test
82done
83
84rm -f $FTL_JSON_CONF
85remove_shm
86