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