xref: /spdk/test/ftl/ftl.sh (revision b30d57cdad6d2bc75cc1e4e2ebbcebcb0d98dcfa)
1#!/usr/bin/env bash
2
3testdir=$(readlink -f $(dirname $0))
4rootdir=$(readlink -f $testdir/../..)
5source $rootdir/test/common/autotest_common.sh
6source $testdir/common.sh
7
8rpc_py=$rootdir/scripts/rpc.py
9
10function at_ftl_exit() {
11	# restore original driver
12	PCI_ALLOWED="$device" PCI_BLOCKED="" DRIVER_OVERRIDE="$ocssd_original_dirver" $rootdir/scripts/setup.sh
13}
14
15read -r device _ <<< "$OCSSD_PCI_DEVICES"
16
17if [[ -z "$device" ]]; then
18	echo "OCSSD device list is empty."
19	echo "This test require that OCSSD_PCI_DEVICES environment variable to be set"
20	echo "and point to OCSSD devices PCI BDF. You can specify multiple space"
21	echo "separated BDFs in this case first one will be used."
22	exit 1
23fi
24
25ocssd_original_dirver="$(basename $(readlink /sys/bus/pci/devices/$device/driver))"
26
27trap 'at_ftl_exit' SIGINT SIGTERM EXIT
28
29# OCSSD is blocked so bind it to vfio/uio driver before testing
30PCI_ALLOWED="$device" PCI_BLOCKED="" DRIVER_OVERRIDE="" $rootdir/scripts/setup.sh
31
32# Use first regular NVMe disk (non-OC) as non-volatile cache
33nvme_disks=$($rootdir/scripts/gen_nvme.sh | jq -r \
34	".config[] | select(.params.traddr != \"$device\").params.traddr")
35
36for disk in $nvme_disks; do
37	if has_separate_md $disk; then
38		nv_cache=$disk
39		break
40	fi
41done
42
43if [ -z "$nv_cache" ]; then
44	# TODO: once CI has devices with separate metadata support fail the test here
45	echo "Couldn't find NVMe device to be used as non-volatile cache"
46fi
47
48run_test "ftl_bdevperf" $testdir/bdevperf.sh $device
49run_test "ftl_bdevperf_append" $testdir/bdevperf.sh $device --use_append
50
51run_test "ftl_restore" $testdir/restore.sh $device
52if [ -n "$nv_cache" ]; then
53	run_test "ftl_restore_nv_cache" $testdir/restore.sh -c $nv_cache $device
54fi
55
56if [ -n "$nv_cache" ]; then
57	run_test "ftl_dirty_shutdown" $testdir/dirty_shutdown.sh -c $nv_cache $device
58fi
59
60run_test "ftl_json" $testdir/json.sh $device
61
62if [ $SPDK_TEST_FTL_EXTENDED -eq 1 ]; then
63	run_test "ftl_fio_basic" $testdir/fio.sh $device basic
64
65	"$SPDK_BIN_DIR/spdk_tgt" --json <(gen_ftl_nvme_conf) &
66	svcpid=$!
67
68	trap 'killprocess $svcpid; exit 1' SIGINT SIGTERM EXIT
69
70	waitforlisten $svcpid
71
72	$rpc_py bdev_nvme_attach_controller -b nvme0 -a $device -t pcie
73	$rpc_py bdev_ocssd_create -c nvme0 -b nvme0n1 -n 1
74	uuid=$($rpc_py bdev_ftl_create -b ftl0 -d nvme0n1 | jq -r '.uuid')
75	killprocess $svcpid
76
77	trap - SIGINT SIGTERM EXIT
78
79	run_test "ftl_fio_extended" $testdir/fio.sh $device extended $uuid
80fi
81