1# Storage Performance Development Kit 2 3[](https://travis-ci.org/spdk/spdk) 4 5NOTE: The SPDK mailing list has moved to a new location. Please visit 6[this URL](https://lists.linuxfoundation.org/mailman/listinfo/spdk) to subscribe 7at the new location. Subscribers from the old location will not be automatically 8migrated to the new location. 9 10The Storage Performance Development Kit ([SPDK](http://www.spdk.io)) provides a set of tools 11and libraries for writing high performance, scalable, user-mode storage 12applications. It achieves high performance by moving all of the necessary 13drivers into userspace and operating in a polled mode instead of relying on 14interrupts, which avoids kernel context switches and eliminates interrupt 15handling overhead. 16 17The development kit currently includes: 18 19* [NVMe driver](http://www.spdk.io/doc/nvme.html) 20* [I/OAT (DMA engine) driver](http://www.spdk.io/doc/ioat.html) 21* [NVMe over Fabrics target](http://www.spdk.io/doc/nvmf.html) 22* [iSCSI target](http://www.spdk.io/doc/iscsi.html) 23* [vhost target](http://www.spdk.io/doc/vhost.html) 24* [Virtio-SCSI driver](http://www.spdk.io/doc/virtio.html) 25 26## In this readme 27 28* [Documentation](#documentation) 29* [Prerequisites](#prerequisites) 30* [Source Code](#source) 31* [Build](#libraries) 32* [Unit Tests](#tests) 33* [Vagrant](#vagrant) 34* [AWS](#aws) 35* [Advanced Build Options](#advanced) 36* [Shared libraries](#shared) 37* [Hugepages and Device Binding](#huge) 38* [Example Code](#examples) 39* [Contributing](#contributing) 40 41<a id="documentation"></a> 42## Documentation 43 44[Doxygen API documentation](http://www.spdk.io/doc/) is available, as 45well as a [Porting Guide](http://www.spdk.io/doc/porting.html) for porting SPDK to different frameworks 46and operating systems. 47 48<a id="source"></a> 49## Source Code 50 51~~~{.sh} 52git clone https://github.com/spdk/spdk 53cd spdk 54git submodule update --init 55~~~ 56 57<a id="prerequisites"></a> 58## Prerequisites 59 60The dependencies can be installed automatically by `scripts/pkgdep.sh`. 61The `scripts/pkgdep.sh` script will automatically install the bare minimum 62dependencies required to build SPDK. 63Use `--help` to see information on installing dependencies for optional components 64 65~~~{.sh} 66./scripts/pkgdep.sh 67~~~ 68 69<a id="libraries"></a> 70## Build 71 72Linux: 73 74~~~{.sh} 75./configure 76make 77~~~ 78 79FreeBSD: 80Note: Make sure you have the matching kernel source in /usr/src/ and 81also note that CONFIG_COVERAGE option is not available right now 82for FreeBSD builds. 83 84~~~{.sh} 85./configure 86gmake 87~~~ 88 89<a id="tests"></a> 90## Unit Tests 91 92~~~{.sh} 93./test/unit/unittest.sh 94~~~ 95 96You will see several error messages when running the unit tests, but they are 97part of the test suite. The final message at the end of the script indicates 98success or failure. 99 100<a id="vagrant"></a> 101## Vagrant 102 103A [Vagrant](https://www.vagrantup.com/downloads.html) setup is also provided 104to create a Linux VM with a virtual NVMe controller to get up and running 105quickly. Currently this has been tested on MacOS, Ubuntu 16.04.2 LTS and 106Ubuntu 18.04.3 LTS with the VirtualBox and Libvirt provider. 107The [VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads) 108or [Vagrant Libvirt] (https://github.com/vagrant-libvirt/vagrant-libvirt) must 109also be installed in order to get the required NVMe support. 110 111Details on the Vagrant setup can be found in the 112[SPDK Vagrant documentation](http://spdk.io/doc/vagrant.html). 113 114<a id="aws"></a> 115## AWS 116 117The following setup is known to work on AWS: 118Image: Ubuntu 18.04 119Before running `setup.sh`, run `modprobe vfio-pci` 120then: `DRIVER_OVERRIDE=vfio-pci ./setup.sh` 121 122<a id="advanced"></a> 123## Advanced Build Options 124 125Optional components and other build-time configuration are controlled by 126settings in the Makefile configuration file in the root of the repository. `CONFIG` 127contains the base settings for the `configure` script. This script generates a new 128file, `mk/config.mk`, that contains final build settings. For advanced configuration, 129there are a number of additional options to `configure` that may be used, or 130`mk/config.mk` can simply be created and edited by hand. A description of all 131possible options is located in `CONFIG`. 132 133Boolean (on/off) options are configured with a 'y' (yes) or 'n' (no). For 134example, this line of `CONFIG` controls whether the optional RDMA (libibverbs) 135support is enabled: 136 137~~~{.sh} 138CONFIG_RDMA?=n 139~~~ 140 141To enable RDMA, this line may be added to `mk/config.mk` with a 'y' instead of 142'n'. For the majority of options this can be done using the `configure` script. 143For example: 144 145~~~{.sh} 146./configure --with-rdma 147~~~ 148 149Additionally, `CONFIG` options may also be overridden on the `make` command 150line: 151 152~~~{.sh} 153make CONFIG_RDMA=y 154~~~ 155 156Users may wish to use a version of DPDK different from the submodule included 157in the SPDK repository. Note, this includes the ability to build not only 158from DPDK sources, but also just with the includes and libraries 159installed via the dpdk and dpdk-devel packages. To specify an alternate DPDK 160installation, run configure with the --with-dpdk option. For example: 161 162Linux: 163 164~~~{.sh} 165./configure --with-dpdk=/path/to/dpdk/x86_64-native-linuxapp-gcc 166make 167~~~ 168 169FreeBSD: 170 171~~~{.sh} 172./configure --with-dpdk=/path/to/dpdk/x86_64-native-bsdapp-clang 173gmake 174~~~ 175 176The options specified on the `make` command line take precedence over the 177values in `mk/config.mk`. This can be useful if you, for example, generate 178a `mk/config.mk` using the `configure` script and then have one or two 179options (i.e. debug builds) that you wish to turn on and off frequently. 180 181<a id="shared"></a> 182## Shared libraries 183 184By default, the build of the SPDK yields static libraries against which 185the SPDK applications and examples are linked. 186Configure option `--with-shared` provides the ability to produce SPDK shared 187libraries, in addition to the default static ones. Use of this flag also 188results in the SPDK executables linked to the shared versions of libraries. 189SPDK shared libraries by default, are located in `./build/lib`. This includes 190the single SPDK shared lib encompassing all of the SPDK static libs 191(`libspdk.so`) as well as individual SPDK shared libs corresponding to each 192of the SPDK static ones. 193 194In order to start a SPDK app linked with SPDK shared libraries, make sure 195to do the following steps: 196 197- run ldconfig specifying the directory containing SPDK shared libraries 198- provide proper `LD_LIBRARY_PATH` 199 200If DPDK shared libraries are used, you may also need to add DPDK shared 201libraries to `LD_LIBRARY_PATH` 202 203Linux: 204 205~~~{.sh} 206./configure --with-shared 207make 208ldconfig -v -n ./build/lib 209LD_LIBRARY_PATH=./build/lib/:./dpdk/build/lib/ ./build/bin/spdk_tgt 210~~~ 211 212<a id="huge"></a> 213## Hugepages and Device Binding 214 215Before running an SPDK application, some hugepages must be allocated and 216any NVMe and I/OAT devices must be unbound from the native kernel drivers. 217SPDK includes a script to automate this process on both Linux and FreeBSD. 218This script should be run as root. 219 220~~~{.sh} 221sudo scripts/setup.sh 222~~~ 223 224Users may wish to configure a specific memory size. Below is an example of 225configuring 8192MB memory. 226 227~~~{.sh} 228sudo HUGEMEM=8192 scripts/setup.sh 229~~~ 230 231There are a lot of other environment variables that can be set to configure 232setup.sh for advanced users. To see the full list, run: 233 234~~~{.sh} 235scripts/setup.sh --help 236~~~ 237 238<a id="examples"></a> 239## Example Code 240 241Example code is located in the examples directory. The examples are compiled 242automatically as part of the build process. Simply call any of the examples 243with no arguments to see the help output. You'll likely need to run the examples 244as a privileged user (root) unless you've done additional configuration 245to grant your user permission to allocate huge pages and map devices through 246vfio. 247 248<a id="contributing"></a> 249## Contributing 250 251For additional details on how to get more involved in the community, including 252[contributing code](http://www.spdk.io/development) and participating in discussions and other activities, please 253refer to [spdk.io](http://www.spdk.io/community) 254