1870ce250SPaul Luse# Storage Performance Development Kit 27c77021cSDaniel Verkamp 3*a8eacc29SBoris Glimcher[](https://github.com/spdk/spdk/blob/master/LICENSE) 4f04508a3SDaniel Verkamp[](https://travis-ci.org/spdk/spdk) 5d51fa2c7SBoris Glimcher[](http://godoc.org/github.com/spdk/spdk/go/rpc) 6*a8eacc29SBoris Glimcher[](https://goreportcard.com/report/github.com/spdk/spdk/go/rpc) 7f04508a3SDaniel Verkamp 8bf253bf6SJim HarrisNOTE: The SPDK mailing list has moved to a new location. Please visit 9bf253bf6SJim Harris[this URL](https://lists.linuxfoundation.org/mailman/listinfo/spdk) to subscribe 10bf253bf6SJim Harrisat the new location. Subscribers from the old location will not be automatically 11bf253bf6SJim Harrismigrated to the new location. 12bf253bf6SJim Harris 13870ce250SPaul LuseThe Storage Performance Development Kit ([SPDK](http://www.spdk.io)) provides a set of tools 147c77021cSDaniel Verkampand libraries for writing high performance, scalable, user-mode storage 15add1515cSBen Walkerapplications. It achieves high performance by moving all of the necessary 16add1515cSBen Walkerdrivers into userspace and operating in a polled mode instead of relying on 17add1515cSBen Walkerinterrupts, which avoids kernel context switches and eliminates interrupt 18add1515cSBen Walkerhandling overhead. 19add1515cSBen Walker 20add1515cSBen WalkerThe development kit currently includes: 213d8a0b19SKarol Latecki 22a3658ab0SDaniel Verkamp* [NVMe driver](http://www.spdk.io/doc/nvme.html) 23a3658ab0SDaniel Verkamp* [I/OAT (DMA engine) driver](http://www.spdk.io/doc/ioat.html) 24a3658ab0SDaniel Verkamp* [NVMe over Fabrics target](http://www.spdk.io/doc/nvmf.html) 25a3658ab0SDaniel Verkamp* [iSCSI target](http://www.spdk.io/doc/iscsi.html) 26509fedf0SDaniel Verkamp* [vhost target](http://www.spdk.io/doc/vhost.html) 2771ea8265SDariusz Stojaczyk* [Virtio-SCSI driver](http://www.spdk.io/doc/virtio.html) 287c77021cSDaniel Verkamp 291e1fd9acSwawryk## In this readme 30870ce250SPaul Luse 31870ce250SPaul Luse* [Documentation](#documentation) 32870ce250SPaul Luse* [Prerequisites](#prerequisites) 33870ce250SPaul Luse* [Source Code](#source) 34870ce250SPaul Luse* [Build](#libraries) 35870ce250SPaul Luse* [Unit Tests](#tests) 36870ce250SPaul Luse* [Vagrant](#vagrant) 37e6bffc3eSJesse Grodman* [AWS](#aws) 38870ce250SPaul Luse* [Advanced Build Options](#advanced) 399f9cfdc5SPiotr Pelplinski* [Shared libraries](#shared) 40870ce250SPaul Luse* [Hugepages and Device Binding](#huge) 41870ce250SPaul Luse* [Example Code](#examples) 42870ce250SPaul Luse* [Contributing](#contributing) 43870ce250SPaul Luse 44870ce250SPaul Luse<a id="documentation"></a> 45870ce250SPaul Luse## Documentation 464d7b500aSDaniel Verkamp 47a3658ab0SDaniel Verkamp[Doxygen API documentation](http://www.spdk.io/doc/) is available, as 4893ab7c31SDaniel Verkampwell as a [Porting Guide](http://www.spdk.io/doc/porting.html) for porting SPDK to different frameworks 49add1515cSBen Walkerand operating systems. 504d7b500aSDaniel Verkamp 51870ce250SPaul Luse<a id="source"></a> 52870ce250SPaul Luse## Source Code 535e95ec6fSJim Harris 54870ce250SPaul Luse~~~{.sh} 55870ce250SPaul Lusegit clone https://github.com/spdk/spdk 56870ce250SPaul Lusecd spdk 57b499ae64SPaul Lusegit submodule update --init 58870ce250SPaul Luse~~~ 594ac57251SJim Harris 6093533c20SHailiang Wang<a id="prerequisites"></a> 6193533c20SHailiang Wang## Prerequisites 6293533c20SHailiang Wang 6393533c20SHailiang WangThe dependencies can be installed automatically by `scripts/pkgdep.sh`. 649ebbf3acSMaciej WawrykThe `scripts/pkgdep.sh` script will automatically install the bare minimum 659ebbf3acSMaciej Wawrykdependencies required to build SPDK. 669ebbf3acSMaciej WawrykUse `--help` to see information on installing dependencies for optional components 6793533c20SHailiang Wang 6893533c20SHailiang Wang~~~{.sh} 6993533c20SHailiang Wang./scripts/pkgdep.sh 7093533c20SHailiang Wang~~~ 7193533c20SHailiang Wang 72870ce250SPaul Luse<a id="libraries"></a> 73870ce250SPaul Luse## Build 745e95ec6fSJim Harris 754ac57251SJim HarrisLinux: 764ac57251SJim Harris 77870ce250SPaul Luse~~~{.sh} 78b499ae64SPaul Luse./configure 799dd998cdSBen Walkermake 80870ce250SPaul Luse~~~ 814ac57251SJim Harris 824ac57251SJim HarrisFreeBSD: 83870ce250SPaul LuseNote: Make sure you have the matching kernel source in /usr/src/ and 84870ce250SPaul Lusealso note that CONFIG_COVERAGE option is not available right now 85870ce250SPaul Lusefor FreeBSD builds. 864ac57251SJim Harris 87870ce250SPaul Luse~~~{.sh} 88b499ae64SPaul Luse./configure 899dd998cdSBen Walkergmake 90870ce250SPaul Luse~~~ 919dd998cdSBen Walker 92870ce250SPaul Luse<a id="tests"></a> 93870ce250SPaul Luse## Unit Tests 94870ce250SPaul Luse 95870ce250SPaul Luse~~~{.sh} 9612e840b9SSeth Howell./test/unit/unittest.sh 97870ce250SPaul Luse~~~ 98870ce250SPaul Luse 99870ce250SPaul LuseYou will see several error messages when running the unit tests, but they are 100870ce250SPaul Lusepart of the test suite. The final message at the end of the script indicates 101870ce250SPaul Lusesuccess or failure. 102870ce250SPaul Luse 103870ce250SPaul Luse<a id="vagrant"></a> 104870ce250SPaul Luse## Vagrant 10511fa5403SJim Harris 10611fa5403SJim HarrisA [Vagrant](https://www.vagrantup.com/downloads.html) setup is also provided 10711fa5403SJim Harristo create a Linux VM with a virtual NVMe controller to get up and running 10809cd5f32SMaciej Wawrykquickly. Currently this has been tested on MacOS, Ubuntu 16.04.2 LTS and 10909cd5f32SMaciej WawrykUbuntu 18.04.3 LTS with the VirtualBox and Libvirt provider. 11009cd5f32SMaciej WawrykThe [VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads) 11109cd5f32SMaciej Wawrykor [Vagrant Libvirt] (https://github.com/vagrant-libvirt/vagrant-libvirt) must 112fadfd849SPaul Lusealso be installed in order to get the required NVMe support. 11311fa5403SJim Harris 114de191b8fSBen WalkerDetails on the Vagrant setup can be found in the 115de191b8fSBen Walker[SPDK Vagrant documentation](http://spdk.io/doc/vagrant.html). 11611fa5403SJim Harris 117e6bffc3eSJesse Grodman<a id="aws"></a> 118e6bffc3eSJesse Grodman## AWS 119e6bffc3eSJesse Grodman 120e6bffc3eSJesse GrodmanThe following setup is known to work on AWS: 121e6bffc3eSJesse GrodmanImage: Ubuntu 18.04 122e6bffc3eSJesse GrodmanBefore running `setup.sh`, run `modprobe vfio-pci` 123e6bffc3eSJesse Grodmanthen: `DRIVER_OVERRIDE=vfio-pci ./setup.sh` 124e6bffc3eSJesse Grodman 125870ce250SPaul Luse<a id="advanced"></a> 126870ce250SPaul Luse## Advanced Build Options 1279dd998cdSBen Walker 1289dd998cdSBen WalkerOptional components and other build-time configuration are controlled by 12985bc2bbeSPawel Wodkowskisettings in the Makefile configuration file in the root of the repository. `CONFIG` 13085bc2bbeSPawel Wodkowskicontains the base settings for the `configure` script. This script generates a new 13185bc2bbeSPawel Wodkowskifile, `mk/config.mk`, that contains final build settings. For advanced configuration, 13285bc2bbeSPawel Wodkowskithere are a number of additional options to `configure` that may be used, or 13385bc2bbeSPawel Wodkowski`mk/config.mk` can simply be created and edited by hand. A description of all 13485bc2bbeSPawel Wodkowskipossible options is located in `CONFIG`. 1359dd998cdSBen Walker 1369dd998cdSBen WalkerBoolean (on/off) options are configured with a 'y' (yes) or 'n' (no). For 1379dd998cdSBen Walkerexample, this line of `CONFIG` controls whether the optional RDMA (libibverbs) 1389dd998cdSBen Walkersupport is enabled: 1399dd998cdSBen Walker 14063ee471bSMaciej Wawryk~~~{.sh} 1419dd998cdSBen WalkerCONFIG_RDMA?=n 14263ee471bSMaciej Wawryk~~~ 1439dd998cdSBen Walker 14485bc2bbeSPawel WodkowskiTo enable RDMA, this line may be added to `mk/config.mk` with a 'y' instead of 1459dd998cdSBen Walker'n'. For the majority of options this can be done using the `configure` script. 1469dd998cdSBen WalkerFor example: 1479dd998cdSBen Walker 148870ce250SPaul Luse~~~{.sh} 149870ce250SPaul Luse./configure --with-rdma 150870ce250SPaul Luse~~~ 1519dd998cdSBen Walker 1521f813ec3SChen WangAdditionally, `CONFIG` options may also be overridden on the `make` command 1539dd998cdSBen Walkerline: 1549dd998cdSBen Walker 155870ce250SPaul Luse~~~{.sh} 1569dd998cdSBen Walkermake CONFIG_RDMA=y 157870ce250SPaul Luse~~~ 1589dd998cdSBen Walker 159737b1b57SJim HarrisUsers may wish to use a version of DPDK different from the submodule included 160b6938efdSLance Hartmannin the SPDK repository. Note, this includes the ability to build not only 161b6938efdSLance Hartmannfrom DPDK sources, but also just with the includes and libraries 162b6938efdSLance Hartmanninstalled via the dpdk and dpdk-devel packages. To specify an alternate DPDK 163b6938efdSLance Hartmanninstallation, run configure with the --with-dpdk option. For example: 164737b1b57SJim Harris 165737b1b57SJim HarrisLinux: 166737b1b57SJim Harris 167870ce250SPaul Luse~~~{.sh} 168737b1b57SJim Harris./configure --with-dpdk=/path/to/dpdk/x86_64-native-linuxapp-gcc 169737b1b57SJim Harrismake 170870ce250SPaul Luse~~~ 171737b1b57SJim Harris 172737b1b57SJim HarrisFreeBSD: 173737b1b57SJim Harris 174870ce250SPaul Luse~~~{.sh} 175737b1b57SJim Harris./configure --with-dpdk=/path/to/dpdk/x86_64-native-bsdapp-clang 176737b1b57SJim Harrisgmake 177870ce250SPaul Luse~~~ 178737b1b57SJim Harris 1799dd998cdSBen WalkerThe options specified on the `make` command line take precedence over the 18085bc2bbeSPawel Wodkowskivalues in `mk/config.mk`. This can be useful if you, for example, generate 18185bc2bbeSPawel Wodkowskia `mk/config.mk` using the `configure` script and then have one or two 18285bc2bbeSPawel Wodkowskioptions (i.e. debug builds) that you wish to turn on and off frequently. 1834ac57251SJim Harris 1849f9cfdc5SPiotr Pelplinski<a id="shared"></a> 1859f9cfdc5SPiotr Pelplinski## Shared libraries 1869f9cfdc5SPiotr Pelplinski 1879f9cfdc5SPiotr PelplinskiBy default, the build of the SPDK yields static libraries against which 1889f9cfdc5SPiotr Pelplinskithe SPDK applications and examples are linked. 1899f9cfdc5SPiotr PelplinskiConfigure option `--with-shared` provides the ability to produce SPDK shared 1909f9cfdc5SPiotr Pelplinskilibraries, in addition to the default static ones. Use of this flag also 1919f9cfdc5SPiotr Pelplinskiresults in the SPDK executables linked to the shared versions of libraries. 1929f9cfdc5SPiotr PelplinskiSPDK shared libraries by default, are located in `./build/lib`. This includes 1939f9cfdc5SPiotr Pelplinskithe single SPDK shared lib encompassing all of the SPDK static libs 1949f9cfdc5SPiotr Pelplinski(`libspdk.so`) as well as individual SPDK shared libs corresponding to each 1959f9cfdc5SPiotr Pelplinskiof the SPDK static ones. 1969f9cfdc5SPiotr Pelplinski 1979f9cfdc5SPiotr PelplinskiIn order to start a SPDK app linked with SPDK shared libraries, make sure 1989f9cfdc5SPiotr Pelplinskito do the following steps: 1993d8a0b19SKarol Latecki 2009f9cfdc5SPiotr Pelplinski- run ldconfig specifying the directory containing SPDK shared libraries 2019f9cfdc5SPiotr Pelplinski- provide proper `LD_LIBRARY_PATH` 2029f9cfdc5SPiotr Pelplinski 203c1a6a7f2SChangpeng LiuIf DPDK shared libraries are used, you may also need to add DPDK shared 204c1a6a7f2SChangpeng Liulibraries to `LD_LIBRARY_PATH` 205c1a6a7f2SChangpeng Liu 2069f9cfdc5SPiotr PelplinskiLinux: 2079f9cfdc5SPiotr Pelplinski 2089f9cfdc5SPiotr Pelplinski~~~{.sh} 2099f9cfdc5SPiotr Pelplinski./configure --with-shared 2109f9cfdc5SPiotr Pelplinskimake 2119f9cfdc5SPiotr Pelplinskildconfig -v -n ./build/lib 212c1a6a7f2SChangpeng LiuLD_LIBRARY_PATH=./build/lib/:./dpdk/build/lib/ ./build/bin/spdk_tgt 2139f9cfdc5SPiotr Pelplinski~~~ 2149f9cfdc5SPiotr Pelplinski 215870ce250SPaul Luse<a id="huge"></a> 216870ce250SPaul Luse## Hugepages and Device Binding 2174ac57251SJim Harris 2184ac57251SJim HarrisBefore running an SPDK application, some hugepages must be allocated and 219d4ab30baSDaniel Verkampany NVMe and I/OAT devices must be unbound from the native kernel drivers. 220c83f9378SDaniel VerkampSPDK includes a script to automate this process on both Linux and FreeBSD. 221c83f9378SDaniel VerkampThis script should be run as root. 2224ac57251SJim Harris 223870ce250SPaul Luse~~~{.sh} 224c83f9378SDaniel Verkampsudo scripts/setup.sh 225870ce250SPaul Luse~~~ 226badade1eSBen Walker 227b41a99f2SGangCaoUsers may wish to configure a specific memory size. Below is an example of 228b41a99f2SGangCaoconfiguring 8192MB memory. 229b41a99f2SGangCao 230b41a99f2SGangCao~~~{.sh} 231b41a99f2SGangCaosudo HUGEMEM=8192 scripts/setup.sh 232b41a99f2SGangCao~~~ 233b41a99f2SGangCao 234b8d2b705SJim HarrisThere are a lot of other environment variables that can be set to configure 235b8d2b705SJim Harrissetup.sh for advanced users. To see the full list, run: 236b8d2b705SJim Harris 237b8d2b705SJim Harris~~~{.sh} 238b8d2b705SJim Harrisscripts/setup.sh --help 239b8d2b705SJim Harris~~~ 240b8d2b705SJim Harris 241522abe47SKrzysztof Karas<a id="targets"></a> 242522abe47SKrzysztof Karas## Target applications 243522abe47SKrzysztof Karas 244522abe47SKrzysztof KarasAfter completing the build process, SPDK target applications can be found in 245522abe47SKrzysztof Karas`spdk/build/bin` directory: 246522abe47SKrzysztof Karas 247522abe47SKrzysztof Karas* [nvmf_tgt](https://spdk.io/doc/nvmf.html) - SPDK NVMe over Fabrics target 248522abe47SKrzysztof Karas presents block devices over a fabrics, 249522abe47SKrzysztof Karas* [iscsi_tgt](https://spdk.io/doc/iscsi.html) - SPDK iSCSI target runs I/O 250522abe47SKrzysztof Karas operations remotely with TCP/IP protocol, 251522abe47SKrzysztof Karas* [vhost](https://spdk.io/doc/vhost.html) - A vhost target provides a local 252522abe47SKrzysztof Karas storage service as a process running on a local machine, 253522abe47SKrzysztof Karas* spdk_tgt - combines capabilities of all three applications. 254522abe47SKrzysztof Karas 255522abe47SKrzysztof KarasSPDK runs in a polled mode, which means it continuously checks for operation completions. 256522abe47SKrzysztof KarasThis approach assures faster response than interrupt mode, but also lessens usefulness 257522abe47SKrzysztof Karasof tools like `top`, which only shows 100% CPU usage for SPDK assigned cores. 258522abe47SKrzysztof Karas[spdk_top](https://spdk.io/doc/spdk_top.html) is a program which simulates `top` application 259522abe47SKrzysztof Karasand uses SPDK's [JSON RPC](https://spdk.io/doc/jsonrpc.html) interface to present statistics 260522abe47SKrzysztof Karasabout SPDK threads, pollers and CPU cores as an interactive list. 261522abe47SKrzysztof Karas 262870ce250SPaul Luse<a id="examples"></a> 263870ce250SPaul Luse## Example Code 264badade1eSBen Walker 265badade1eSBen WalkerExample code is located in the examples directory. The examples are compiled 266badade1eSBen Walkerautomatically as part of the build process. Simply call any of the examples 267badade1eSBen Walkerwith no arguments to see the help output. You'll likely need to run the examples 268badade1eSBen Walkeras a privileged user (root) unless you've done additional configuration 269badade1eSBen Walkerto grant your user permission to allocate huge pages and map devices through 270badade1eSBen Walkervfio. 271870ce250SPaul Luse 272870ce250SPaul Luse<a id="contributing"></a> 273870ce250SPaul Luse## Contributing 274870ce250SPaul Luse 275870ce250SPaul LuseFor additional details on how to get more involved in the community, including 2761f813ec3SChen Wang[contributing code](http://www.spdk.io/development) and participating in discussions and other activities, please 277870ce250SPaul Luserefer to [spdk.io](http://www.spdk.io/community) 278