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