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 11rpc_py=$rootdir/scripts/rpc.py 12 13function at_ftl_exit() { 14 killprocess "$spdk_tgt_pid" 15 16 # delete any created lvols of the base device 17 if [[ -n $device ]]; then 18 "$rootdir/build/bin/spdk_tgt" & 19 spdk_tgt_pid=$! 20 waitforlisten "$spdk_tgt_pid" 21 "$rpc_py" bdev_nvme_attach_controller -b nvme0 -t PCIe -a $device 22 clear_lvols 23 killprocess "$spdk_tgt_pid" 24 fi 25 26 # restore original driver 27 $rootdir/scripts/setup.sh reset 28 remove_shm 29} 30 31trap 'at_ftl_exit' SIGINT SIGTERM EXIT 32 33# Bind device to vfio/uio driver before testing 34PCI_ALLOWED="$device" PCI_BLOCKED="" DRIVER_OVERRIDE="" $rootdir/scripts/setup.sh 35 36"$rootdir/build/bin/spdk_tgt" --wait-for-rpc & 37spdk_tgt_pid=$! 38waitforlisten "$spdk_tgt_pid" 39 40$rpc_py bdev_set_options -d 41$rpc_py framework_start_init 42 43"$rpc_py" load_subsystem_config -j <($rootdir/scripts/gen_nvme.sh) 44 45# 5GiB minimum for cache device 46cache_size=$((5 * 1024 * 1024 * 1024 / 4096)) 47cache_disks=$("$rpc_py" bdev_get_bdevs | jq -r ".[] | select(.md_size==64 and .zoned == false and .num_blocks >= $cache_size).driver_specific.nvme[].pci_address") 48for disk in $cache_disks; do 49 nv_cache=$disk 50 break 51done 52 53if [ -z "$nv_cache" ]; then 54 echo "Couldn't find NVMe device to be used as non-volatile cache" 55 exit 1 56fi 57 58# 5GiB minimum for base device (will be thin provisioned to 100GiB if necessary - it's enough for basic tests) 59base_size=$((5 * 1024 * 1024 * 1024 / 4096)) 60base_disks=$("$rpc_py" bdev_get_bdevs | jq -r ".[] | select(.driver_specific.nvme[0].pci_address!=\"$nv_cache\" and .zoned == false and .num_blocks >= $base_size).driver_specific.nvme[].pci_address") 61for disk in $base_disks; do 62 device=$disk 63 break 64done 65 66killprocess "$spdk_tgt_pid" 67 68if [ -z "$device" ]; then 69 echo "Couldn't find NVMe device to be used as base device" 70 exit 1 71fi 72 73run_test "ftl_fio_basic" $testdir/fio.sh $device $nv_cache basic 74run_test "ftl_bdevperf" $testdir/bdevperf.sh $device $nv_cache 75run_test "ftl_trim" $testdir/trim.sh $device $nv_cache 76run_test "ftl_restore" $testdir/restore.sh -c $nv_cache $device 77run_test "ftl_dirty_shutdown" $testdir/dirty_shutdown.sh -c $nv_cache $device 78run_test "ftl_upgrade_shutdown" $testdir/upgrade_shutdown.sh $device $nv_cache 79 80if [[ $RUN_NIGHTLY -eq 1 ]]; then 81 run_test "ftl_restore_fast" $testdir/restore.sh -f -c $nv_cache $device 82fi 83