2015-09-21 08:52:41 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-01-05 15:31:56 -07:00
|
|
|
set -e
|
|
|
|
|
2015-09-21 08:52:41 -07:00
|
|
|
testdir=$(readlink -f $(dirname $0))
|
2018-03-22 15:18:32 -07:00
|
|
|
rootdir=$(readlink -f $testdir/../..)
|
2018-01-02 14:44:48 -07:00
|
|
|
source $rootdir/scripts/common.sh
|
2018-02-27 15:14:08 -07:00
|
|
|
source $rootdir/test/common/autotest_common.sh
|
2015-09-21 08:52:41 -07:00
|
|
|
|
2017-10-13 10:19:43 -07:00
|
|
|
function get_nvme_name_from_bdf {
|
|
|
|
lsblk -d --output NAME
|
2018-01-16 13:52:40 +08:00
|
|
|
nvme_devs=$(lsblk -d --output NAME | grep "^nvme") || true
|
|
|
|
if [ -z "$nvme_devs" ]; then
|
2017-10-13 10:19:43 -07:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
for dev in $nvme_devs; do
|
2017-12-15 11:54:25 -07:00
|
|
|
link_name=$(readlink /sys/block/$dev/device/device) || true
|
|
|
|
if [ -z "$link_name" ]; then
|
|
|
|
link_name=$(readlink /sys/block/$dev/device)
|
|
|
|
fi
|
|
|
|
bdf=$(basename "$link_name")
|
2017-10-13 10:19:43 -07:00
|
|
|
if [ "$bdf" = "$1" ]; then
|
|
|
|
eval "$2=$dev"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2015-10-08 12:40:44 -07:00
|
|
|
timing_enter nvme
|
|
|
|
|
2018-01-02 14:52:43 -07:00
|
|
|
if [ `uname` = Linux ]; then
|
|
|
|
# check that our setup.sh script does not bind NVMe devices to uio/vfio if they
|
|
|
|
# have an active mountpoint
|
|
|
|
$rootdir/scripts/setup.sh reset
|
|
|
|
# give kernel nvme driver some time to create the block devices before we start looking for them
|
|
|
|
sleep 1
|
|
|
|
blkname=''
|
|
|
|
# first, find an NVMe device that does not have an active mountpoint already;
|
|
|
|
# this covers rare case where someone is running this test script on a system
|
|
|
|
# that has a mounted NVMe filesystem
|
|
|
|
#
|
|
|
|
# note: more work probably needs to be done to properly handle devices with multiple
|
|
|
|
# namespaces
|
2018-01-02 14:44:48 -07:00
|
|
|
for bdf in $(iter_pci_class_code 01 08 02); do
|
2018-01-02 14:52:43 -07:00
|
|
|
get_nvme_name_from_bdf "$bdf" blkname
|
|
|
|
if [ "$blkname" != "" ]; then
|
|
|
|
mountpoints=$(lsblk /dev/$blkname --output MOUNTPOINT -n | wc -w)
|
|
|
|
if [ "$mountpoints" = "0" ]; then
|
|
|
|
break
|
|
|
|
else
|
|
|
|
blkname=''
|
|
|
|
fi
|
2017-10-13 10:19:43 -07:00
|
|
|
fi
|
2018-01-02 14:52:43 -07:00
|
|
|
done
|
2017-10-13 10:19:43 -07:00
|
|
|
|
2018-01-02 14:52:43 -07:00
|
|
|
# if we found an NVMe block device without an active mountpoint, create and mount
|
|
|
|
# a filesystem on it for purposes of testing the setup.sh script
|
|
|
|
if [ "$blkname" != "" ]; then
|
|
|
|
parted -s /dev/$blkname mklabel gpt
|
|
|
|
# just create a 100MB partition - this tests our ability to detect mountpoints
|
|
|
|
# on partitions of the device, not just the device itself; it also is faster
|
|
|
|
# since we don't trim and initialize the whole namespace
|
|
|
|
parted -s /dev/$blkname mkpart primary 1 100
|
|
|
|
sleep 1
|
|
|
|
mkfs.ext4 -F /dev/${blkname}p1
|
|
|
|
mkdir -p /tmp/nvmetest
|
|
|
|
mount /dev/${blkname}p1 /tmp/nvmetest
|
|
|
|
$rootdir/scripts/setup.sh
|
|
|
|
driver=$(basename $(readlink /sys/bus/pci/devices/$bdf/driver))
|
|
|
|
# check that the nvme driver is still loaded against the device
|
|
|
|
if [ "$driver" != "nvme" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
umount /tmp/nvmetest
|
|
|
|
rmdir /tmp/nvmetest
|
|
|
|
# write zeroes to the device to blow away the partition table and filesystem
|
|
|
|
dd if=/dev/zero of=/dev/$blkname oflag=direct bs=1M count=1
|
|
|
|
$rootdir/scripts/setup.sh
|
|
|
|
driver=$(basename $(readlink /sys/bus/pci/devices/$bdf/driver))
|
|
|
|
# check that the nvme driver is not loaded against the device
|
|
|
|
if [ "$driver" = "nvme" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
$rootdir/scripts/setup.sh
|
2017-10-13 10:19:43 -07:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-06-15 16:29:35 -07:00
|
|
|
if [ `uname` = Linux ]; then
|
|
|
|
start_stub "-s 2048 -i 0 -m 0xF"
|
2017-07-05 10:03:31 -07:00
|
|
|
trap "kill_stub; exit 1" SIGINT SIGTERM EXIT
|
2017-06-15 16:29:35 -07:00
|
|
|
fi
|
|
|
|
|
2016-03-23 13:34:31 -07:00
|
|
|
if [ $RUN_NIGHTLY -eq 1 ]; then
|
2017-11-30 15:38:34 -07:00
|
|
|
# TODO: temporarily disabled - temperature AER doesn't fire on emulated controllers
|
|
|
|
#timing_enter aer
|
|
|
|
#$testdir/aer/aer
|
|
|
|
#timing_exit aer
|
2017-02-15 13:09:10 -07:00
|
|
|
|
|
|
|
timing_enter reset
|
|
|
|
$testdir/reset/reset -q 64 -w write -s 4096 -t 2
|
2017-12-18 14:20:41 -07:00
|
|
|
report_test_completion "nightly_nvme_reset"
|
2017-02-15 13:09:10 -07:00
|
|
|
timing_exit reset
|
2016-03-23 13:34:31 -07:00
|
|
|
fi
|
2015-09-21 08:52:41 -07:00
|
|
|
|
2015-10-08 12:40:44 -07:00
|
|
|
timing_enter identify
|
2017-06-15 16:29:35 -07:00
|
|
|
$rootdir/examples/nvme/identify/identify -i 0
|
2018-01-02 14:44:48 -07:00
|
|
|
for bdf in $(iter_pci_class_code 01 08 02); do
|
2017-06-15 16:29:35 -07:00
|
|
|
$rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:${bdf}" -i 0
|
2017-01-13 14:20:35 +08:00
|
|
|
done
|
2015-10-08 12:40:44 -07:00
|
|
|
timing_exit identify
|
2015-09-21 08:52:41 -07:00
|
|
|
|
2015-10-08 12:40:44 -07:00
|
|
|
timing_enter perf
|
2018-08-17 12:16:56 +02:00
|
|
|
$rootdir/examples/nvme/perf/perf -q 128 -w read -o 12288 -t 1 -LL -i 0
|
2017-10-31 23:07:07 +08:00
|
|
|
if [ -b /dev/ram0 ]; then
|
|
|
|
# Test perf with AIO device
|
2018-08-17 12:16:56 +02:00
|
|
|
$rootdir/examples/nvme/perf/perf /dev/ram0 -q 128 -w read -o 12288 -t 1 -LL -i 0
|
2017-12-18 14:20:41 -07:00
|
|
|
report_test_completion "nvme_perf"
|
2017-10-31 23:07:07 +08:00
|
|
|
fi
|
2015-10-08 12:40:44 -07:00
|
|
|
timing_exit perf
|
|
|
|
|
2016-01-22 16:39:55 +08:00
|
|
|
timing_enter reserve
|
|
|
|
$rootdir/examples/nvme/reserve/reserve
|
|
|
|
timing_exit reserve
|
|
|
|
|
2016-07-19 09:33:46 -07:00
|
|
|
timing_enter hello_world
|
|
|
|
$rootdir/examples/nvme/hello_world/hello_world
|
|
|
|
timing_exit
|
|
|
|
|
2017-09-20 15:53:38 -07:00
|
|
|
timing_enter deallocated_value
|
|
|
|
$testdir/deallocated_value/deallocated_value
|
|
|
|
timing_exit deallocated_value
|
|
|
|
|
2017-06-15 16:29:35 -07:00
|
|
|
timing_enter sgl
|
|
|
|
$testdir/sgl/sgl
|
|
|
|
timing_exit sgl
|
|
|
|
|
|
|
|
timing_enter e2edp
|
|
|
|
$testdir/e2edp/nvme_dp
|
|
|
|
timing_exit e2edp
|
|
|
|
|
2018-05-17 13:32:42 -04:00
|
|
|
timing_enter err_injection
|
|
|
|
$testdir/err_injection/err_injection
|
|
|
|
timing_exit err_injection
|
|
|
|
|
2016-08-01 13:18:22 -07:00
|
|
|
timing_enter overhead
|
2018-03-22 15:18:32 -07:00
|
|
|
$testdir/overhead/overhead -s 4096 -t 1 -H
|
2016-08-01 13:18:22 -07:00
|
|
|
timing_exit overhead
|
|
|
|
|
2017-06-15 16:29:35 -07:00
|
|
|
timing_enter arbitration
|
|
|
|
$rootdir/examples/nvme/arbitration/arbitration -t 3 -i 0
|
|
|
|
timing_exit arbitration
|
|
|
|
|
2017-07-05 10:49:50 -07:00
|
|
|
if [ `uname` = Linux ]; then
|
|
|
|
timing_enter multi_secondary
|
2018-08-17 12:16:56 +02:00
|
|
|
$rootdir/examples/nvme/perf/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x1 &
|
2017-07-05 10:49:50 -07:00
|
|
|
pid0=$!
|
2018-08-17 12:16:56 +02:00
|
|
|
$rootdir/examples/nvme/perf/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x2 &
|
2017-07-05 10:49:50 -07:00
|
|
|
pid1=$!
|
2018-08-17 12:16:56 +02:00
|
|
|
$rootdir/examples/nvme/perf/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x4
|
2017-07-05 10:49:50 -07:00
|
|
|
wait $pid0
|
|
|
|
wait $pid1
|
2017-12-18 14:20:41 -07:00
|
|
|
report_test_completion "nvme_multi_secondary"
|
2017-07-05 10:49:50 -07:00
|
|
|
timing_exit multi_secondary
|
|
|
|
fi
|
|
|
|
|
2017-06-15 16:29:35 -07:00
|
|
|
if [ `uname` = Linux ]; then
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
kill_stub
|
|
|
|
fi
|
2017-06-13 11:50:32 -07:00
|
|
|
PLUGIN_DIR=$rootdir/examples/nvme/fio_plugin
|
|
|
|
|
2016-04-12 20:58:29 -04:00
|
|
|
if [ -d /usr/src/fio ]; then
|
|
|
|
timing_enter fio_plugin
|
2018-01-02 14:44:48 -07:00
|
|
|
for bdf in $(iter_pci_class_code 01 08 02); do
|
2017-06-12 13:08:19 +08:00
|
|
|
# Only test when ASAN is not enabled. If ASAN is enabled, we cannot test.
|
|
|
|
if [ $SPDK_RUN_ASAN -eq 0 ]; then
|
|
|
|
LD_PRELOAD=$PLUGIN_DIR/fio_plugin /usr/src/fio/fio $PLUGIN_DIR/example_config.fio --filename="trtype=PCIe traddr=${bdf//:/.} ns=1"
|
2017-12-18 14:20:41 -07:00
|
|
|
report_test_completion "bdev_fio"
|
2017-06-12 13:08:19 +08:00
|
|
|
fi
|
2016-04-12 20:58:29 -04:00
|
|
|
break
|
|
|
|
done
|
|
|
|
|
|
|
|
timing_exit fio_plugin
|
|
|
|
fi
|
|
|
|
|
2015-10-08 12:40:44 -07:00
|
|
|
timing_exit nvme
|