]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/test/nvme/nvme.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / test / nvme / nvme.sh
CommitLineData
11fdf7f2
TL
1#!/usr/bin/env bash
2
3set -e
4
5testdir=$(readlink -f $(dirname $0))
6rootdir=$(readlink -f $testdir/../..)
7source $rootdir/scripts/common.sh
8source $rootdir/test/common/autotest_common.sh
9
10function get_nvme_name_from_bdf {
11 lsblk -d --output NAME
12 nvme_devs=$(lsblk -d --output NAME | grep "^nvme") || true
13 if [ -z "$nvme_devs" ]; then
14 return
15 fi
16 for dev in $nvme_devs; do
17 link_name=$(readlink /sys/block/$dev/device/device) || true
18 if [ -z "$link_name" ]; then
19 link_name=$(readlink /sys/block/$dev/device)
20 fi
21 bdf=$(basename "$link_name")
22 if [ "$bdf" = "$1" ]; then
23 eval "$2=$dev"
24 return
25 fi
26 done
27}
28
29timing_enter nvme
30
31if [ `uname` = Linux ]; then
32 # check that our setup.sh script does not bind NVMe devices to uio/vfio if they
33 # have an active mountpoint
34 $rootdir/scripts/setup.sh reset
35 # give kernel nvme driver some time to create the block devices before we start looking for them
36 sleep 1
37 blkname=''
38 # first, find an NVMe device that does not have an active mountpoint already;
39 # this covers rare case where someone is running this test script on a system
40 # that has a mounted NVMe filesystem
41 #
42 # note: more work probably needs to be done to properly handle devices with multiple
43 # namespaces
44 for bdf in $(iter_pci_class_code 01 08 02); do
45 get_nvme_name_from_bdf "$bdf" blkname
46 if [ "$blkname" != "" ]; then
47 mountpoints=$(lsblk /dev/$blkname --output MOUNTPOINT -n | wc -w)
48 if [ "$mountpoints" = "0" ]; then
49 break
50 else
51 blkname=''
52 fi
53 fi
54 done
55
56 # if we found an NVMe block device without an active mountpoint, create and mount
57 # a filesystem on it for purposes of testing the setup.sh script
58 if [ "$blkname" != "" ]; then
59 parted -s /dev/$blkname mklabel gpt
60 # just create a 100MB partition - this tests our ability to detect mountpoints
61 # on partitions of the device, not just the device itself; it also is faster
62 # since we don't trim and initialize the whole namespace
63 parted -s /dev/$blkname mkpart primary 1 100
64 sleep 1
65 mkfs.ext4 -F /dev/${blkname}p1
66 mkdir -p /tmp/nvmetest
67 mount /dev/${blkname}p1 /tmp/nvmetest
9f95a23c 68 sleep 1
11fdf7f2
TL
69 $rootdir/scripts/setup.sh
70 driver=$(basename $(readlink /sys/bus/pci/devices/$bdf/driver))
71 # check that the nvme driver is still loaded against the device
72 if [ "$driver" != "nvme" ]; then
73 exit 1
74 fi
75 umount /tmp/nvmetest
76 rmdir /tmp/nvmetest
77 # write zeroes to the device to blow away the partition table and filesystem
78 dd if=/dev/zero of=/dev/$blkname oflag=direct bs=1M count=1
79 $rootdir/scripts/setup.sh
80 driver=$(basename $(readlink /sys/bus/pci/devices/$bdf/driver))
81 # check that the nvme driver is not loaded against the device
82 if [ "$driver" = "nvme" ]; then
83 exit 1
84 fi
85 else
86 $rootdir/scripts/setup.sh
87 fi
88fi
89
90if [ `uname` = Linux ]; then
91 start_stub "-s 4096 -i 0 -m 0xF"
9f95a23c 92 trap "kill_stub -9; exit 1" SIGINT SIGTERM EXIT
11fdf7f2
TL
93fi
94
9f95a23c
TL
95timing_enter reset
96$testdir/reset/reset -q 64 -w write -s 4096 -t 2
97timing_exit reset
11fdf7f2
TL
98
99timing_enter identify
100$rootdir/examples/nvme/identify/identify -i 0
101for bdf in $(iter_pci_class_code 01 08 02); do
102 $rootdir/examples/nvme/identify/identify -r "trtype:PCIe traddr:${bdf}" -i 0
103done
104timing_exit identify
105
106timing_enter perf
107$rootdir/examples/nvme/perf/perf -q 128 -w read -o 12288 -t 1 -LL -i 0
108if [ -b /dev/ram0 ]; then
109 # Test perf with AIO device
110 $rootdir/examples/nvme/perf/perf /dev/ram0 -q 128 -w read -o 12288 -t 1 -LL -i 0
111 report_test_completion "nvme_perf"
112fi
113timing_exit perf
114
115timing_enter reserve
116$rootdir/examples/nvme/reserve/reserve
117timing_exit reserve
118
119timing_enter hello_world
120$rootdir/examples/nvme/hello_world/hello_world
121timing_exit
122
123timing_enter deallocated_value
124$testdir/deallocated_value/deallocated_value
125timing_exit deallocated_value
126
127timing_enter sgl
128$testdir/sgl/sgl
129timing_exit sgl
130
131timing_enter e2edp
132$testdir/e2edp/nvme_dp
133timing_exit e2edp
134
135timing_enter err_injection
136$testdir/err_injection/err_injection
137timing_exit err_injection
138
139timing_enter overhead
140$testdir/overhead/overhead -s 4096 -t 1 -H
141timing_exit overhead
142
143timing_enter arbitration
144$rootdir/examples/nvme/arbitration/arbitration -t 3 -i 0
145timing_exit arbitration
146
147if [ `uname` = Linux ]; then
148 timing_enter multi_secondary
149 $rootdir/examples/nvme/perf/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x1 &
150 pid0=$!
151 $rootdir/examples/nvme/perf/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x2 &
152 pid1=$!
153 $rootdir/examples/nvme/perf/perf -i 0 -q 16 -w read -o 4096 -t 3 -c 0x4
154 wait $pid0
155 wait $pid1
156 report_test_completion "nvme_multi_secondary"
157 timing_exit multi_secondary
158fi
159
160if [ `uname` = Linux ]; then
161 trap - SIGINT SIGTERM EXIT
162 kill_stub
163fi
11fdf7f2 164
9f95a23c
TL
165if [ -d /usr/src/fio ] && [ $SPDK_RUN_ASAN -eq 0 ]; then
166 # Only test when ASAN is not enabled. If ASAN is enabled, we cannot test.
11fdf7f2 167 timing_enter fio_plugin
9f95a23c 168 PLUGIN_DIR=$rootdir/examples/nvme/fio_plugin
11fdf7f2 169 for bdf in $(iter_pci_class_code 01 08 02); do
9f95a23c
TL
170 fio_nvme $PLUGIN_DIR/example_config.fio --filename="trtype=PCIe traddr=${bdf//:/.} ns=1"
171 report_test_completion "bdev_fio"
11fdf7f2 172 done
11fdf7f2
TL
173 timing_exit fio_plugin
174fi
175
176timing_exit nvme