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