xref: /spdk/doc/bdev.md (revision a6dbe3721eb3b5990707fc3e378c95e505dd8ab5)
1# Block Device User Guide {#bdev}
2
3## Target Audience {#bdev_ug_targetaudience}
4
5This user guide is intended for software developers who have knowledge of block storage, storage drivers, issuing JSON-RPC
6commands and storage services such as RAID, compression, crypto, and others.
7
8## Introduction {#bdev_ug_introduction}
9
10The SPDK block device layer, often simply called *bdev*, is a C library
11intended to be equivalent to the operating system block storage layer that
12often sits immediately above the device drivers in a traditional kernel
13storage stack. Specifically, this library provides the following
14functionality:
15
16* A pluggable module API for implementing block devices that interface with different types of block storage devices.
17* Driver modules for NVMe, malloc (ramdisk), Linux AIO, virtio-scsi, Ceph RBD, Pmem and Vhost-SCSI Initiator and more.
18* An application API for enumerating and claiming SPDK block devices and then performing operations (read, write, unmap, etc.) on those devices.
19* Facilities to stack block devices to create complex I/O pipelines, including logical volume management (lvol) and partition support (GPT).
20* Configuration of block devices via JSON-RPC.
21* Request queueing, timeout, and reset handling.
22* Multiple, lockless queues for sending I/O to block devices.
23
24Bdev module creates abstraction layer that provides common API for all devices.
25User can use available bdev modules or create own module with any type of
26device underneath (please refer to @ref bdev_module for details). SPDK
27provides also vbdev modules which creates block devices on existing bdev. For
28example @ref bdev_ug_logical_volumes or @ref bdev_ug_gpt
29
30## Prerequisites {#bdev_ug_prerequisites}
31
32This guide assumes that you can already build the standard SPDK distribution
33on your platform. The block device layer is a C library with a single public
34header file named bdev.h. All SPDK configuration described in following
35chapters is done by using JSON-RPC commands. SPDK provides a python-based
36command line tool for sending RPC commands located at `scripts/rpc.py`. User
37can list available commands by running this script with `-h` or `--help` flag.
38Additionally user can retrieve currently supported set of RPC commands
39directly from SPDK application by running `scripts/rpc.py rpc_get_methods`.
40Detailed help for each command can be displayed by adding `-h` flag as a
41command parameter.
42
43## Configuring Block Device Modules {#bdev_ug_general_rpcs}
44
45Block devices can be configured using JSON RPCs. A complete list of available RPC commands
46with detailed information can be found on the @ref jsonrpc_components_bdev page.
47
48## Common Block Device Configuration Examples
49
50## Ceph RBD {#bdev_config_rbd}
51
52The SPDK RBD bdev driver provides SPDK block layer access to Ceph RADOS block
53devices (RBD). Ceph RBD devices are accessed via librbd and librados libraries
54to access the RADOS block device exported by Ceph. To create Ceph bdev RPC
55command `bdev_rbd_register_cluster` and `bdev_rbd_create` should be used.
56
57SPDK provides two ways of creating a RBD bdev. One is to create a new Rados cluster object
58for each RBD bdev. Another is to share the same Rados cluster object for multiple RBD bdevs.
59Each Rados cluster object creates a small number of io_context_pool and messenger threads.
60Ceph commands `ceph config help librados_thread_count` and `ceph config help ms_async_op_threads`
61could help to check these threads information. Besides, you can specify the number of threads by
62updating ceph.conf file or using Ceph config commands. For more information, please refer to
63[Ceph configuration](https://docs.ceph.com/en/latest/rados/configuration/ceph-conf/)
64One set of threads may not be enough to maximize performance with a large number of RBD bdevs,
65but one set of threads per RBD bdev may add too much context switching. Therefore, performance
66tuning on the number of RBD bdevs per cluster object and thread may be required.
67
68Example command
69
70`rpc.py bdev_rbd_register_cluster rbd_cluster`
71
72This command will register a cluster named rbd_cluster. Optional `--config-file` and
73`--key-file` params are specified for the cluster.
74
75To remove a registered cluster use the bdev_rbd_unregister_cluster command.
76
77`rpc.py bdev_rbd_unregister_cluster rbd_cluster`
78
79To create RBD bdev with a registered cluster.
80
81`rpc.py bdev_rbd_create rbd foo 512 -c rbd_cluster`
82
83This command will create a bdev that represents the 'foo' image from a pool called 'rbd'.
84When specifying -c for `bdev_rbd_create`, RBD bdevs will share the same rados cluster with
85one connection of Ceph in librbd module. Instead it will create a new rados cluster with one
86cluster connection for every bdev without specifying -c.
87
88To remove a block device representation use the bdev_rbd_delete command.
89
90`rpc.py bdev_rbd_delete Rbd0`
91
92To resize a bdev use the bdev_rbd_resize command.
93
94`rpc.py bdev_rbd_resize Rbd0 4096`
95
96This command will resize the Rbd0 bdev to 4096 MiB.
97
98## Compression Virtual Bdev Module {#bdev_config_compress}
99
100The compression bdev module can be configured to provide compression/decompression
101services for an underlying thinly provisioned logical volume. Although the underlying
102module can be anything (i.e. NVME bdev) the overall compression benefits will not be realized
103unless the data stored on disk is placed appropriately. The compression vbdev module
104relies on an internal SPDK library called `reduce` to accomplish this, see @ref reduce
105for detailed information.
106
107The vbdev module relies on the DPDK CompressDev Framework to provide all compression
108functionality. The framework provides support for many different software only
109compression modules as well as hardware assisted support for Intel QAT. At this
110time the vbdev module supports the DPDK drivers for ISAL, QAT and mlx5_pci.
111
112mlx5_pci driver works with BlueField 2 SmartNIC and requires additional configuration of DPDK
113environment to enable compression function. It can be done via SPDK event library by configuring
114`env_context` member of `spdk_app_opts` structure or by passing corresponding CLI arguments in the
115following form: `--allow=BDF,class=compress`, e.g. `--allow=0000:01:00.0,class=compress`.
116
117Persistent memory is used to store metadata associated with the layout of the data on the
118backing device. SPDK relies on [PMDK](http://pmem.io/pmdk/) to interface persistent memory so any hardware
119supported by PMDK should work. If the directory for PMEM supplied upon vbdev creation does
120not point to persistent memory (i.e. a regular filesystem) performance will be severely
121impacted.  The vbdev module and reduce libraries were designed to use persistent memory for
122any production use.
123
124Example command
125
126`rpc.py bdev_compress_create -p /pmem_files -b myLvol`
127
128In this example, a compression vbdev is created using persistent memory that is mapped to
129the directory `pmem_files` on top of the existing thinly provisioned logical volume `myLvol`.
130The resulting compression bdev will be named `COMP_LVS/myLvol` where LVS is the name of the
131logical volume store that `myLvol` resides on.
132
133The logical volume is referred to as the backing device and once the compression vbdev is
134created it cannot be separated from the persistent memory file that will be created in
135the specified directory.  If the persistent memory file is not available, the compression
136vbdev will also not be available.
137
138By default the vbdev module will choose the QAT driver if the hardware and drivers are
139available and loaded.  If not, it will revert to the software-only ISAL driver. By using
140the following command, the driver may be specified however this is not persistent so it
141must be done either upon creation or before the underlying logical volume is loaded to
142be honored. In the example below, `0` is telling the vbdev module to use QAT if available
143otherwise use ISAL, this is the default and if sufficient the command is not required. Passing
144a value of 1 tells the driver to use QAT and if not available then the creation or loading
145the vbdev should fail to create or load.  A value of '2' as shown below tells the module
146to use ISAL and if for some reason it is not available, the vbdev should fail to create or load.
147
148`rpc.py bdev_compress_set_pmd -p 2`
149
150To remove a compression vbdev, use the following command which will also delete the PMEM
151file.  If the logical volume is deleted the PMEM file will not be removed and the
152compression vbdev will not be available.
153
154`rpc.py bdev_compress_delete COMP_LVS/myLvol`
155
156To list compression volumes that are only available for deletion because their PMEM file
157was missing use the following. The name parameter is optional and if not included will list
158all volumes, if used it will return the name or an error that the device does not exist.
159
160`rpc.py bdev_compress_get_orphans --name COMP_Nvme0n1`
161
162## Crypto Virtual Bdev Module {#bdev_config_crypto}
163
164The crypto virtual bdev module can be configured to provide at rest data encryption
165for any underlying bdev. The module relies on the DPDK CryptoDev Framework to provide
166all cryptographic functionality. The framework provides support for many different software
167only cryptographic modules as well hardware assisted support for the Intel QAT board and
168NVIDIA crypto enabled NICs.
169The framework also provides support for cipher, hash, authentication and AEAD functions.
170At this time the SPDK virtual bdev module supports cipher only as follows:
171
172- AESN-NI Multi Buffer Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES128_CBC
173- Intel(R) QuickAssist (QAT) Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES128_CBC,
174  RTE_CRYPTO_CIPHER_AES128_XTS
175  (Note: QAT is functional however is marked as experimental until the hardware has
176  been fully integrated with the SPDK CI system.)
177- MLX5 Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES256_XTS, RTE_CRYPTO_CIPHER_AES512_XTS
178
179In order to support using the bdev block offset (LBA) as the initialization vector (IV),
180the crypto module break up all I/O into crypto operations of a size equal to the block
181size of the underlying bdev.  For example, a 4K I/O to a bdev with a 512B block size,
182would result in 8 cryptographic operations.
183
184For reads, the buffer provided to the crypto module will be used as the destination buffer
185for unencrypted data.  For writes, however, a temporary scratch buffer is used as the
186destination buffer for encryption which is then passed on to the underlying bdev as the
187write buffer.  This is done to avoid encrypting the data in the original source buffer which
188may cause problems in some use cases.
189
190Example command
191
192`rpc.py bdev_crypto_create NVMe1n1 CryNvmeA crypto_aesni_mb 01234567891234560123456789123456`
193
194This command will create a crypto vbdev called 'CryNvmeA' on top of the NVMe bdev
195'NVMe1n1' and will use the DPDK software driver 'crypto_aesni_mb' and the key
196'01234567891234560123456789123456'.
197
198Please make sure the keys are provided in hexlified format. This means string passed to
199rpc.py must be twice as long than the key length in binary form.
200
201Example command
202
203rpc.py bdev_crypto_create -c AES_XTS -k2 7859243a027411e581e0c40a35c8228f NVMe1n1 CryNvmeA \
204mlx5_pci d16a2f3a9e9f5b32daefacd7f5984f4578add84425be4a0baa489b9de8884b09
205
206This command will create a crypto vbdev called 'CryNvmeA' on top of the NVMe bdev
207'NVMe1n1' and will use the DPDK software driver 'mlx5_pci', the AES key
208'd16a2f3a9e9f5b32daefacd7f5984f4578add84425be4a0baa489b9de8884b09' and the XTS key
209'7859243a027411e581e0c40a35c8228f'. In other words, the compound AES_XTS key to be used is
210'd16a2f3a9e9f5b32daefacd7f5984f4578add84425be4a0baa489b9de8884b097859243a027411e581e0c40a35c8228f'
211
212To remove the vbdev use the bdev_crypto_delete command.
213
214`rpc.py bdev_crypto_delete CryNvmeA`
215
216The MLX5 driver works with crypto enabled Nvidia NICs and requires special configuration of
217DPDK environment to enable crypto function. It can be done via SPDK event library by configuring
218`env_context` member of `spdk_app_opts` structure or by passing corresponding CLI arguments in
219the following form: `--allow=BDF,class=crypto,wcs_file=/full/path/to/wrapped/credentials`, e.g.
220`--allow=0000:01:00.0,class=crypto,wcs_file=/path/credentials.txt`.
221
222## Delay Bdev Module {#bdev_config_delay}
223
224The delay vbdev module is intended to apply a predetermined additional latency on top of a lower
225level bdev. This enables the simulation of the latency characteristics of a device during the functional
226or scalability testing of an SPDK application. For example, to simulate the effect of drive latency when
227processing I/Os, one could configure a NULL bdev with a delay bdev on top of it.
228
229The delay bdev module is not intended to provide a high fidelity replication of a specific NVMe drive's latency,
230instead it's main purpose is to provide a "big picture" understanding of how a generic latency affects a given
231application.
232
233A delay bdev is created using the `bdev_delay_create` RPC. This rpc takes 6 arguments, one for the name
234of the delay bdev and one for the name of the base bdev. The remaining four arguments represent the following
235latency values: average read latency, average write latency, p99 read latency, and p99 write latency.
236Within the context of the delay bdev p99 latency means that one percent of the I/O will be delayed by at
237least by the value of the p99 latency before being completed to the upper level protocol. All of the latency values
238are measured in microseconds.
239
240Example command:
241
242`rpc.py bdev_delay_create -b Null0 -d delay0 -r 10 --nine-nine-read-latency 50 -w 30 --nine-nine-write-latency 90`
243
244This command will create a delay bdev with average read and write latencies of 10 and 30 microseconds and p99 read
245and write latencies of 50 and 90 microseconds respectively.
246
247A delay bdev can be deleted using the `bdev_delay_delete` RPC
248
249Example command:
250
251`rpc.py bdev_delay_delete delay0`
252
253## GPT (GUID Partition Table) {#bdev_config_gpt}
254
255The GPT virtual bdev driver is enabled by default and does not require any configuration.
256It will automatically detect @ref bdev_ug_gpt on any attached bdev and will create
257possibly multiple virtual bdevs.
258
259### SPDK GPT partition table {#bdev_ug_gpt}
260
261The SPDK partition type GUID is `7c5222bd-8f5d-4087-9c00-bf9843c7b58c`. Existing SPDK bdevs
262can be exposed as Linux block devices via NBD and then can be partitioned with
263standard partitioning tools. After partitioning, the bdevs will need to be deleted and
264attached again for the GPT bdev module to see any changes. NBD kernel module must be
265loaded first. To create NBD bdev user should use `nbd_start_disk` RPC command.
266
267Example command
268
269`rpc.py nbd_start_disk Malloc0 /dev/nbd0`
270
271This will expose an SPDK bdev `Malloc0` under the `/dev/nbd0` block device.
272
273To remove NBD device user should use `nbd_stop_disk` RPC command.
274
275Example command
276
277`rpc.py nbd_stop_disk /dev/nbd0`
278
279To display full or specified nbd device list user should use `nbd_get_disks` RPC command.
280
281Example command
282
283`rpc.py nbd_stop_disk -n /dev/nbd0`
284
285### Creating a GPT partition table using NBD {#bdev_ug_gpt_create_part}
286
287~~~bash
288# Expose bdev Nvme0n1 as kernel block device /dev/nbd0 by JSON-RPC
289rpc.py nbd_start_disk Nvme0n1 /dev/nbd0
290
291# Create GPT partition table.
292parted -s /dev/nbd0 mklabel gpt
293
294# Add a partition consuming 50% of the available space.
295parted -s /dev/nbd0 mkpart MyPartition '0%' '50%'
296
297# Change the partition type to the SPDK GUID.
298# sgdisk is part of the gdisk package.
299sgdisk -t 1:7c5222bd-8f5d-4087-9c00-bf9843c7b58c /dev/nbd0
300
301# Stop the NBD device (stop exporting /dev/nbd0).
302rpc.py nbd_stop_disk /dev/nbd0
303
304# Now Nvme0n1 is configured with a GPT partition table, and
305# the first partition will be automatically exposed as
306# Nvme0n1p1 in SPDK applications.
307~~~
308
309## iSCSI bdev {#bdev_config_iscsi}
310
311The SPDK iSCSI bdev driver depends on libiscsi and hence is not enabled by default.
312In order to use it, build SPDK with an extra `--with-iscsi-initiator` configure option.
313
314The following command creates an `iSCSI0` bdev from a single LUN exposed at given iSCSI URL
315with `iqn.2016-06.io.spdk:init` as the reported initiator IQN.
316
317`rpc.py bdev_iscsi_create -b iSCSI0 -i iqn.2016-06.io.spdk:init --url iscsi://127.0.0.1/iqn.2016-06.io.spdk:disk1/0`
318
319The URL is in the following format:
320`iscsi://[<username>[%<password>]@]<host>[:<port>]/<target-iqn>/<lun>`
321
322## Linux AIO bdev {#bdev_config_aio}
323
324The SPDK AIO bdev driver provides SPDK block layer access to Linux kernel block
325devices or a file on a Linux filesystem via Linux AIO. Note that O_DIRECT is
326used and thus bypasses the Linux page cache. This mode is probably as close to
327a typical kernel based target as a user space target can get without using a
328user-space driver. To create AIO bdev RPC command `bdev_aio_create` should be
329used.
330
331Example commands
332
333`rpc.py bdev_aio_create /dev/sda aio0`
334
335This command will create `aio0` device from /dev/sda.
336
337`rpc.py bdev_aio_create /tmp/file file 4096`
338
339This command will create `file` device with block size 4096 from /tmp/file.
340
341To delete an aio bdev use the bdev_aio_delete command.
342
343`rpc.py bdev_aio_delete aio0`
344
345## OCF Virtual bdev {#bdev_config_cas}
346
347OCF virtual bdev module is based on [Open CAS Framework](https://github.com/Open-CAS/ocf) - a
348high performance block storage caching meta-library.
349To enable the module, configure SPDK using `--with-ocf` flag.
350OCF bdev can be used to enable caching for any underlying bdev.
351
352Below is an example command for creating OCF bdev:
353
354`rpc.py bdev_ocf_create Cache1 wt Malloc0 Nvme0n1`
355
356This command will create new OCF bdev `Cache1` having bdev `Malloc0` as caching-device
357and `Nvme0n1` as core-device and initial cache mode `Write-Through`.
358`Malloc0` will be used as cache for `Nvme0n1`, so  data written to `Cache1` will be present
359on `Nvme0n1` eventually.
360By default, OCF will be configured with cache line size equal 4KiB
361and non-volatile metadata will be disabled.
362
363To remove `Cache1`:
364
365`rpc.py bdev_ocf_delete Cache1`
366
367During removal OCF-cache will be stopped and all cached data will be written to the core device.
368
369Note that OCF has a per-device RAM requirement. More details can be found in the
370[OCF documentation](https://open-cas.github.io/guide_system_requirements.html).
371
372## Malloc bdev {#bdev_config_malloc}
373
374Malloc bdevs are ramdisks. Because of its nature they are volatile. They are created from hugepage memory given to SPDK
375application.
376
377Example command for creating malloc bdev:
378
379`rpc.py bdev_malloc_create -b Malloc0 64 512`
380
381Example command for removing malloc bdev:
382
383`rpc.py bdev_malloc_delete Malloc0`
384
385## Null {#bdev_config_null}
386
387The SPDK null bdev driver is a dummy block I/O target that discards all writes and returns undefined
388data for reads.  It is useful for benchmarking the rest of the bdev I/O stack with minimal block
389device overhead and for testing configurations that can't easily be created with the Malloc bdev.
390To create Null bdev RPC command `bdev_null_create` should be used.
391
392Example command
393
394`rpc.py bdev_null_create Null0 8589934592 4096`
395
396This command will create an 8 petabyte `Null0` device with block size 4096.
397
398To delete a null bdev use the bdev_null_delete command.
399
400`rpc.py bdev_null_delete Null0`
401
402## NVMe bdev {#bdev_config_nvme}
403
404There are two ways to create block device based on NVMe device in SPDK. First
405way is to connect local PCIe drive and second one is to connect NVMe-oF device.
406In both cases user should use `bdev_nvme_attach_controller` RPC command to achieve that.
407
408Example commands
409
410`rpc.py bdev_nvme_attach_controller -b NVMe1 -t PCIe -a 0000:01:00.0`
411
412This command will create NVMe bdev of physical device in the system.
413
414`rpc.py bdev_nvme_attach_controller -b Nvme0 -t RDMA -a 192.168.100.1 -f IPv4 -s 4420 -n nqn.2016-06.io.spdk:cnode1`
415
416This command will create NVMe bdev of NVMe-oF resource.
417
418To remove an NVMe controller use the bdev_nvme_detach_controller command.
419
420`rpc.py bdev_nvme_detach_controller Nvme0`
421
422This command will remove NVMe bdev named Nvme0.
423
424The SPDK NVMe bdev driver provides the multipath feature. Please refer to
425@ref nvme_multipath for details.
426
427### NVMe bdev character device {#bdev_config_nvme_cuse}
428
429This feature is considered as experimental. You must configure with --with-nvme-cuse
430option to enable this RPC.
431
432Example commands
433
434`rpc.py bdev_nvme_cuse_register -n Nvme3
435
436This command will register a character device under /dev/spdk associated with Nvme3
437controller. If there are namespaces created on Nvme3 controller, a namespace
438character device is also created for each namespace.
439
440For example, the first controller registered will have a character device path of
441/dev/spdk/nvmeX, where X is replaced with a unique integer to differentiate it from
442other controllers.  Note that this 'nvmeX' name here has no correlation to the name
443associated with the controller in SPDK.  Namespace character devices will have a path
444of /dev/spdk/nvmeXnY, where Y is the namespace ID.
445
446Cuse devices are removed from system, when NVMe controller is detached or unregistered
447with command:
448
449`rpc.py bdev_nvme_cuse_unregister -n Nvme0`
450
451## Logical volumes {#bdev_ug_logical_volumes}
452
453The Logical Volumes library is a flexible storage space management system. It allows
454creating and managing virtual block devices with variable size on top of other bdevs.
455The SPDK Logical Volume library is built on top of @ref blob. For detailed description
456please refer to @ref lvol.
457
458### Logical volume store {#bdev_ug_lvol_store}
459
460Before creating any logical volumes (lvols), an lvol store has to be created first on
461selected block device. Lvol store is lvols vessel responsible for managing underlying
462bdev space assignment to lvol bdevs and storing metadata. To create lvol store user
463should use using `bdev_lvol_create_lvstore` RPC command.
464
465Example command
466
467`rpc.py bdev_lvol_create_lvstore Malloc2 lvs -c 4096`
468
469This will create lvol store named `lvs` with cluster size 4096, build on top of
470`Malloc2` bdev. In response user will be provided with uuid which is unique lvol store
471identifier.
472
473User can get list of available lvol stores using `bdev_lvol_get_lvstores` RPC command (no
474parameters available).
475
476Example response
477~~~
478{
479  "uuid": "330a6ab2-f468-11e7-983e-001e67edf35d",
480  "base_bdev": "Malloc2",
481  "free_clusters": 8190,
482  "cluster_size": 8192,
483  "total_data_clusters": 8190,
484  "block_size": 4096,
485  "name": "lvs"
486}
487~~~
488
489To delete lvol store user should use `bdev_lvol_delete_lvstore` RPC command.
490
491Example commands
492
493`rpc.py bdev_lvol_delete_lvstore -u 330a6ab2-f468-11e7-983e-001e67edf35d`
494
495`rpc.py bdev_lvol_delete_lvstore -l lvs`
496
497### Lvols {#bdev_ug_lvols}
498
499To create lvols on existing lvol store user should use `bdev_lvol_create` RPC command.
500Each created lvol will be represented by new bdev.
501
502Example commands
503
504`rpc.py bdev_lvol_create lvol1 25 -l lvs`
505
506`rpc.py bdev_lvol_create lvol2 25 -u 330a6ab2-f468-11e7-983e-001e67edf35d`
507
508## Passthru {#bdev_config_passthru}
509
510The SPDK Passthru virtual block device module serves as an example of how to write a
511virtual block device module. It implements the required functionality of a vbdev module
512and demonstrates some other basic features such as the use of per I/O context.
513
514Example commands
515
516`rpc.py bdev_passthru_create -b aio -p pt`
517
518`rpc.py bdev_passthru_delete pt`
519
520## Pmem {#bdev_config_pmem}
521
522The SPDK pmem bdev driver uses pmemblk pool as the target for block I/O operations. For
523details on Pmem memory please refer to PMDK documentation on http://pmem.io website.
524First, user needs to configure SPDK to include PMDK support:
525
526`configure --with-pmdk`
527
528To create pmemblk pool for use with SPDK user should use `bdev_pmem_create_pool` RPC command.
529
530Example command
531
532`rpc.py bdev_pmem_create_pool /path/to/pmem_pool 25 4096`
533
534To get information on created pmem pool file user can use `bdev_pmem_get_pool_info` RPC command.
535
536Example command
537
538`rpc.py bdev_pmem_get_pool_info /path/to/pmem_pool`
539
540To remove pmem pool file user can use `bdev_pmem_delete_pool` RPC command.
541
542Example command
543
544`rpc.py bdev_pmem_delete_pool /path/to/pmem_pool`
545
546To create bdev based on pmemblk pool file user should use `bdev_pmem_create` RPC
547command.
548
549Example command
550
551`rpc.py bdev_pmem_create /path/to/pmem_pool -n pmem`
552
553To remove a block device representation use the bdev_pmem_delete command.
554
555`rpc.py bdev_pmem_delete pmem`
556
557## RAID {#bdev_ug_raid}
558
559RAID virtual bdev module provides functionality to combine any SPDK bdevs into
560one RAID bdev. Currently SPDK supports only RAID 0. RAID functionality does not
561store on-disk metadata on the member disks, so user must recreate the RAID
562volume when restarting application. User may specify member disks to create RAID
563volume event if they do not exists yet - as the member disks are registered at
564a later time, the RAID module will claim them and will surface the RAID volume
565after all of the member disks are available. It is allowed to use disks of
566different sizes - the smallest disk size will be the amount of space used on
567each member disk.
568
569Example commands
570
571`rpc.py bdev_raid_create -n Raid0 -z 64 -r 0 -b "lvol0 lvol1 lvol2 lvol3"`
572
573`rpc.py bdev_raid_get_bdevs`
574
575`rpc.py bdev_raid_delete Raid0`
576
577## Split {#bdev_ug_split}
578
579The split block device module takes an underlying block device and splits it into
580several smaller equal-sized virtual block devices. This serves as an example to create
581more vbdevs on a given base bdev for user testing.
582
583Example commands
584
585To create four split bdevs with base bdev_b0 use the `bdev_split_create` command.
586Each split bdev will be one fourth the size of the base bdev.
587
588`rpc.py bdev_split_create bdev_b0 4`
589
590The `split_size_mb`(-s) parameter restricts the size of each split bdev.
591The total size of all split bdevs must not exceed the base bdev size.
592
593`rpc.py bdev_split_create bdev_b0 4 -s 128`
594
595To remove the split bdevs, use the `bdev_split_delete` command with the base bdev name.
596
597`rpc.py bdev_split_delete bdev_b0`
598
599## Uring {#bdev_ug_uring}
600
601The uring bdev module issues I/O to kernel block devices using the io_uring Linux kernel API. This module requires liburing.
602For more information on io_uring refer to kernel [IO_uring] (https://kernel.dk/io_uring.pdf)
603
604The user needs to configure SPDK to include io_uring support:
605
606`configure --with-uring`
607
608Support for zoned devices is enabled by default in uring bdev. It can be explicitly disabled as follows:
609
610`configure --with-uring --without-uring-zns`
611
612To create a uring bdev with given filename, bdev name and block size use the `bdev_uring_create` RPC.
613
614`rpc.py  bdev_uring_create /path/to/device bdev_u0 512`
615
616To remove a uring bdev use the `bdev_uring_delete` RPC.
617
618`rpc.py bdev_uring_delete bdev_u0`
619
620## xnvme {#bdev_ug_xnvme}
621
622The xnvme bdev module issues I/O to the underlying NVMe devices through various I/O mechanisms
623such as libaio, io_uring, Asynchronous IOCTL using io_uring passthrough, POSIX aio, emulated aio etc.
624
625This module requires xNVMe library.
626For more information on xNVMe refer to [xNVMe] (https://xnvme.io/docs/latest)
627
628The user needs to configure SPDK to include xNVMe support:
629
630`configure --with-xnvme`
631
632To create a xnvme bdev with given filename, bdev name and I/O mechanism use the `bdev_xnvme_create` RPC.
633
634`rpc.py  bdev_xnvme_create /dev/ng0n1 bdev_ng0n1 io_uring_cmd`
635
636To remove a xnvme bdev use the `bdev_xnvme_delete` RPC.
637
638`rpc.py bdev_xnvme_delete bdev_ng0n1`
639
640## Virtio Block {#bdev_config_virtio_blk}
641
642The Virtio-Block driver allows creating SPDK bdevs from Virtio-Block devices.
643
644The following command creates a Virtio-Block device named `VirtioBlk0` from a vhost-user
645socket `/tmp/vhost.0` exposed directly by SPDK @ref vhost. Optional `vq-count` and
646`vq-size` params specify number of request queues and queue depth to be used.
647
648`rpc.py bdev_virtio_attach_controller --dev-type blk --trtype user --traddr /tmp/vhost.0 --vq-count 2 --vq-size 512 VirtioBlk0`
649
650The driver can be also used inside QEMU-based VMs. The following command creates a Virtio
651Block device named `VirtioBlk0` from a Virtio PCI device at address `0000:00:01.0`.
652The entire configuration will be read automatically from PCI Configuration Space. It will
653reflect all parameters passed to QEMU's vhost-user-scsi-pci device.
654
655`rpc.py bdev_virtio_attach_controller --dev-type blk --trtype pci --traddr 0000:01:00.0 VirtioBlk1`
656
657Virtio-Block devices can be removed with the following command
658
659`rpc.py bdev_virtio_detach_controller VirtioBlk0`
660
661## Virtio SCSI {#bdev_config_virtio_scsi}
662
663The Virtio-SCSI driver allows creating SPDK block devices from Virtio-SCSI LUNs.
664
665Virtio-SCSI bdevs are created the same way as Virtio-Block ones.
666
667`rpc.py bdev_virtio_attach_controller --dev-type scsi --trtype user --traddr /tmp/vhost.0 --vq-count 2 --vq-size 512 VirtioScsi0`
668
669`rpc.py bdev_virtio_attach_controller --dev-type scsi --trtype pci --traddr 0000:01:00.0 VirtioScsi0`
670
671Each Virtio-SCSI device may export up to 64 block devices named VirtioScsi0t0 ~ VirtioScsi0t63,
672one LUN (LUN0) per SCSI device. The above 2 commands will output names of all exposed bdevs.
673
674Virtio-SCSI devices can be removed with the following command
675
676`rpc.py bdev_virtio_detach_controller VirtioScsi0`
677
678Removing a Virtio-SCSI device will destroy all its bdevs.
679
680## DAOS bdev {#bdev_config_daos}
681
682DAOS bdev creates SPDK block device on top of DAOS DFS, the name of the bdev defines the file name in DFS namespace.
683Note that DAOS container has to be POSIX type, e.g.: ` daos cont create --pool=test-pool --label=test-cont --type=POSIX`
684
685To build SPDK with daos support, daos-devel package has to be installed, please see the setup [guide](https://docs.daos.io/v2.0/).
686To enable the module, configure SPDK using `--with-daos` flag.
687
688Running `daos_agent` service on the target machine is required for the SPDK DAOS bdev communication with a DAOS cluster.
689
690The implementation uses the independent pool and container connections per device's channel for the best IO throughput, therefore,
691running a target application with multiple cores (`-m [0-7], for example) is highly advisable.
692
693Example command for creating daos bdev:
694
695`rpc.py bdev_daos_create daosdev0 test-pool test-cont 64 4096`
696
697Example command for removing daos bdev:
698
699`rpc.py bdev_daos_delete daosdev0`
700
701To resize a bdev use the bdev_daos_resize command.
702
703`rpc.py bdev_daos_resize daosdev0 8192`
704
705This command will resize the daosdev0 bdev to 8192 MiB.
706