2015-09-21 15:52:41 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
testdir=$(readlink -f $(dirname $0))
|
2018-03-22 22:18:32 +00:00
|
|
|
rootdir=$(readlink -f $testdir/../..)
|
2018-01-02 21:44:48 +00:00
|
|
|
source $rootdir/scripts/common.sh
|
2018-02-27 22:14:08 +00:00
|
|
|
source $rootdir/test/common/autotest_common.sh
|
2015-09-21 15:52:41 +00:00
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function nvme_identify() {
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/identify -i 0
|
2020-03-16 16:32:39 +00:00
|
|
|
for bdf in $(get_nvme_bdfs); do
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:${bdf}" -i 0
|
2019-12-04 22:02:00 +00:00
|
|
|
done
|
|
|
|
timing_exit identify
|
|
|
|
}
|
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function nvme_perf() {
|
2019-12-04 22:02:00 +00:00
|
|
|
# enable no shutdown notification option
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/perf -q 128 -w read -o 12288 -t 1 -LL -i 0 -N
|
|
|
|
$SPDK_EXAMPLE_DIR/perf -q 128 -w write -o 12288 -t 1 -LL -i 0
|
2019-12-04 22:02:00 +00:00
|
|
|
if [ -b /dev/ram0 ]; then
|
|
|
|
# Test perf with AIO device
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/perf /dev/ram0 -q 128 -w read -o 12288 -t 1 -LL -i 0
|
2019-12-04 22:02:00 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function nvme_fio_test() {
|
2020-06-03 13:24:50 +00:00
|
|
|
PLUGIN_DIR=$rootdir/examples/nvme/fio_plugin
|
|
|
|
ran_fio=false
|
2020-03-16 16:32:39 +00:00
|
|
|
for bdf in $(get_nvme_bdfs); do
|
2021-12-01 14:15:12 +00:00
|
|
|
if ! "$SPDK_EXAMPLE_DIR/identify" -r "trtype:PCIe traddr:${bdf}" | grep -qE "^Namespace ID:[0-9]+"; then
|
2020-06-03 13:24:50 +00:00
|
|
|
continue
|
|
|
|
fi
|
2021-01-21 15:54:04 +00:00
|
|
|
if $SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:${bdf}" | grep -q "Extended Data LBA"; then
|
|
|
|
bs=4160
|
|
|
|
else
|
|
|
|
bs=4096
|
|
|
|
fi
|
|
|
|
fio_nvme $PLUGIN_DIR/example_config.fio --filename="trtype=PCIe traddr=${bdf//:/.}" --bs="$bs"
|
2020-06-03 13:24:50 +00:00
|
|
|
ran_fio=true
|
2019-12-04 22:02:00 +00:00
|
|
|
done
|
2020-06-03 13:24:50 +00:00
|
|
|
$ran_fio || (echo "No valid NVMe drive found. Failing test." && false)
|
2019-12-04 22:02:00 +00:00
|
|
|
}
|
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function nvme_multi_secondary() {
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x1 &
|
2019-12-04 22:02:00 +00:00
|
|
|
pid0=$!
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x2 &
|
2019-12-04 22:02:00 +00:00
|
|
|
pid1=$!
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x4
|
2019-12-04 22:02:00 +00:00
|
|
|
wait $pid0
|
|
|
|
wait $pid1
|
|
|
|
}
|
|
|
|
|
2019-06-12 07:48:32 +00:00
|
|
|
if [ $(uname) = Linux ]; then
|
2018-01-02 21:52:43 +00:00
|
|
|
# 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
|
|
|
|
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
|
2020-03-16 16:32:39 +00:00
|
|
|
for bdf in $(get_nvme_bdfs); do
|
2019-07-10 11:27:45 +00:00
|
|
|
for name in $(get_nvme_name_from_bdf $bdf); do
|
|
|
|
if [ "$name" != "" ]; then
|
|
|
|
mountpoints=$(lsblk /dev/$name --output MOUNTPOINT -n | wc -w)
|
2019-06-11 13:04:06 +00:00
|
|
|
if [ "$mountpoints" = "0" ]; then
|
2019-07-10 11:27:45 +00:00
|
|
|
blkname=$name
|
|
|
|
break 2
|
2019-06-11 13:04:06 +00:00
|
|
|
fi
|
2018-01-02 21:52:43 +00:00
|
|
|
fi
|
2019-06-11 13:04:06 +00:00
|
|
|
done
|
2018-01-02 21:52:43 +00:00
|
|
|
done
|
2017-10-13 17:19:43 +00:00
|
|
|
|
2018-01-02 21:52:43 +00: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
|
2018-11-28 08:27:07 +00:00
|
|
|
sleep 1
|
2018-01-02 21:52:43 +00:00
|
|
|
$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 17:19:43 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-06-12 07:48:32 +00:00
|
|
|
if [ $(uname) = Linux ]; then
|
2019-05-02 08:18:13 +00:00
|
|
|
trap "kill_stub -9; exit 1" SIGINT SIGTERM EXIT
|
2020-01-22 23:57:39 +00:00
|
|
|
start_stub "-s 4096 -i 0 -m 0xE"
|
2017-06-15 23:29:35 +00:00
|
|
|
fi
|
|
|
|
|
2019-12-19 23:03:30 +00:00
|
|
|
run_test "nvme_reset" $testdir/reset/reset -q 64 -w write -s 4096 -t 5
|
|
|
|
run_test "nvme_identify" nvme_identify
|
|
|
|
run_test "nvme_perf" nvme_perf
|
2021-12-06 06:00:59 +00:00
|
|
|
run_test "nvme_hello_world" $SPDK_EXAMPLE_DIR/hello_world -i 0
|
2021-12-02 05:25:20 +00:00
|
|
|
run_test "nvme_deallocated_value" $testdir/deallocated_value/deallocated_value -i 0
|
2019-12-19 23:03:30 +00:00
|
|
|
run_test "nvme_sgl" $testdir/sgl/sgl
|
|
|
|
run_test "nvme_e2edp" $testdir/e2edp/nvme_dp
|
2020-06-02 00:42:50 +00:00
|
|
|
run_test "nvme_reserve" $testdir/reserve/reserve
|
2019-12-19 23:03:30 +00:00
|
|
|
run_test "nvme_err_injection" $testdir/err_injection/err_injection
|
2021-12-02 03:04:19 +00:00
|
|
|
run_test "nvme_overhead" $testdir/overhead/overhead -s 4096 -t 1 -H -i 0
|
2020-05-11 22:02:01 +00:00
|
|
|
run_test "nvme_arbitration" $SPDK_EXAMPLE_DIR/arbitration -t 3 -i 0
|
2018-05-17 17:32:42 +00:00
|
|
|
|
2019-10-29 01:05:10 +00:00
|
|
|
if [ $(uname) != "FreeBSD" ]; then
|
2019-12-19 23:03:30 +00:00
|
|
|
run_test "nvme_startup" $testdir/startup/startup -t 1000000
|
|
|
|
run_test "nvme_multi_secondary" nvme_multi_secondary
|
2017-06-15 23:29:35 +00:00
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
kill_stub
|
|
|
|
fi
|
2020-06-03 13:24:50 +00:00
|
|
|
|
|
|
|
if [[ $CONFIG_FIO_PLUGIN == y ]]; then
|
|
|
|
run_test "nvme_fio" nvme_fio_test
|
|
|
|
fi
|