xref: /spdk/doc/bdev.md (revision 6e2c32c34eb9f49cb5301d8017e57da512f1fef7)
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 compression bdev module leverages the [Acceleration Framework](https://spdk.io/doc/accel_fw.html) to
108carry out the actual compression and decompression. The acceleration framework can be configured to use
109ISA-L software optimized compression or the DPDK Compressdev module for hardware acceleration. To configure
110the Compressdev module please see the `compressdev_scan_accel_module` documentation [here](https://spdk.io/doc/jsonrpc.html)
111
112Persistent memory is used to store metadata associated with the layout of the data on the
113backing device. SPDK relies on [PMDK](http://pmem.io/pmdk/) to interface persistent memory so any hardware
114supported by PMDK should work. If the directory for PMEM supplied upon vbdev creation does
115not point to persistent memory (i.e. a regular filesystem) performance will be severely
116impacted.  The vbdev module and reduce libraries were designed to use persistent memory for
117any production use.
118
119Example command
120
121`rpc.py bdev_compress_create -p /pmem_files -b myLvol`
122
123In this example, a compression vbdev is created using persistent memory that is mapped to
124the directory `pmem_files` on top of the existing thinly provisioned logical volume `myLvol`.
125The resulting compression bdev will be named `COMP_LVS/myLvol` where LVS is the name of the
126logical volume store that `myLvol` resides on.
127
128The logical volume is referred to as the backing device and once the compression vbdev is
129created it cannot be separated from the persistent memory file that will be created in
130the specified directory.  If the persistent memory file is not available, the compression
131vbdev will also not be available.
132
133To remove a compression vbdev, use the following command which will also delete the PMEM
134file.  If the logical volume is deleted the PMEM file will not be removed and the
135compression vbdev will not be available.
136
137`rpc.py bdev_compress_delete COMP_LVS/myLvol`
138
139To list compression volumes that are only available for deletion because their PMEM file
140was missing use the following. The name parameter is optional and if not included will list
141all volumes, if used it will return the name or an error that the device does not exist.
142
143`rpc.py bdev_compress_get_orphans --name COMP_Nvme0n1`
144
145## Crypto Virtual Bdev Module {#bdev_config_crypto}
146
147The crypto virtual bdev module can be configured to provide at rest data encryption
148for any underlying bdev. The module relies on the SPDK Accel Framework to provide
149all cryptographic functionality.
150One of the accel modules, dpdk_cryptodev is implemented with the DPDK CryptoDev API,
151it provides support for many different software only cryptographic modules as well hardware
152assisted support for the Intel QAT board and NVIDIA crypto enabled NICs.
153
154For reads, the buffer provided to the crypto block device will be used as the destination buffer
155for unencrypted data.  For writes, however, a temporary scratch buffer is used as the
156destination buffer for encryption which is then passed on to the underlying bdev as the
157write buffer.  This is done to avoid encrypting the data in the original source buffer which
158may cause problems in some use cases.
159
160Below is information about accel modules which support crypto operations:
161
162### dpdk_cryptodev accel module
163
164Supports the following ciphers:
165
166- AESN-NI Multi Buffer Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES128_CBC
167- Intel(R) QuickAssist (QAT) Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES128_CBC,
168  RTE_CRYPTO_CIPHER_AES128_XTS
169  (Note: QAT is functional however is marked as experimental until the hardware has
170  been fully integrated with the SPDK CI system.)
171- MLX5 Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES256_XTS, RTE_CRYPTO_CIPHER_AES512_XTS
172
173In order to support using the bdev block offset (LBA) as the initialization vector (IV),
174the crypto module break up all I/O into crypto operations of a size equal to the block
175size of the underlying bdev.  For example, a 4K I/O to a bdev with a 512B block size,
176would result in 8 cryptographic operations.
177
178### SW accel module
179
180Supports the following ciphers:
181
182- AES_XTS cipher with 128 or 256 bit keys implemented with ISA-L_crypto
183
184### General workflow
185
186- Set desired accel module to perform crypto operations, that can be done with `accel_assign_opc` RPC command
187- Create a named crypto key using `accel_crypto_key_create` RPC command. The key will use the assigned accel
188  module. Set of parameters and supported ciphers may be different in each accel module.
189- Create virtual crypto block device providing the base block device name and the crypto key name
190  using `bdev_crypto_create` RPC command
191
192#### Example
193
194Example command which uses dpdk_cryptodev accel module
195```
196# start SPDK application with `--wait-for-rpc` parameter
197rpc.py dpdk_cryptodev_scan_accel_module
198rpc.py dpdk_cryptodev_set_driver crypto_aesni_mb
199rpc.py accel_assign_opc -o encrypt -m dpdk_cryptodev
200rpc.py accel_assign_opc -o decrypt -m dpdk_cryptodev
201rpc.py framework_start_init
202rpc.py accel_crypto_key_create -c AES_CBC -k 01234567891234560123456789123456 -n key_aesni_cbc_1
203rpc.py bdev_crypto_create NVMe1n1 CryNvmeA -n key_aesni_cbc_1
204```
205
206These commands will create a crypto vbdev called 'CryNvmeA' on top of the NVMe bdev
207'NVMe1n1' and will use a key named `key_aesni_cbc_1`. The key will work with the accel module which
208has been assigned for encrypt operations, in this example it will be the dpdk_cryptodev.
209
210### Crypto key format
211
212Please make sure the keys are provided in hexlified format. This means string passed to
213rpc.py must be twice as long than the key length in binary form.
214
215#### Example command
216
217`rpc.py accel_crypto_key_create -c AES_XTS -e 7859243a027411e581e0c40a35c8228f -k 10fee72b3d47553e065affdb48c54a81 -n sample_key`
218
219This command will create a key called `sample_key`, the AES key
220'10fee72b3d47553e065affdb48c54a81' and the XTS key
221'7859243a027411e581e0c40a35c8228f'. In other words, the compound AES_XTS key to be used is
222'10fee72b3d47553e065affdb48c54a817859243a027411e581e0c40a35c8228f'
223
224### Delete the virtual crypto block device
225
226To remove the vbdev use the bdev_crypto_delete command.
227
228`rpc.py bdev_crypto_delete CryNvmeA`
229
230### dpdk_cryptodev mlx5_pci driver configuration
231
232The mlx5_pci driver works with crypto enabled Nvidia NICs and requires special configuration of
233DPDK environment to enable crypto function. It can be done via SPDK event library by configuring
234`env_context` member of `spdk_app_opts` structure or by passing corresponding CLI arguments in
235the following form: `--allow=BDF,class=crypto,wcs_file=/full/path/to/wrapped/credentials`, e.g.
236`--allow=0000:01:00.0,class=crypto,wcs_file=/path/credentials.txt`.
237
238## Delay Bdev Module {#bdev_config_delay}
239
240The delay vbdev module is intended to apply a predetermined additional latency on top of a lower
241level bdev. This enables the simulation of the latency characteristics of a device during the functional
242or scalability testing of an SPDK application. For example, to simulate the effect of drive latency when
243processing I/Os, one could configure a NULL bdev with a delay bdev on top of it.
244
245The delay bdev module is not intended to provide a high fidelity replication of a specific NVMe drive's latency,
246instead it's main purpose is to provide a "big picture" understanding of how a generic latency affects a given
247application.
248
249A delay bdev is created using the `bdev_delay_create` RPC. This rpc takes 6 arguments, one for the name
250of the delay bdev and one for the name of the base bdev. The remaining four arguments represent the following
251latency values: average read latency, average write latency, p99 read latency, and p99 write latency.
252Within the context of the delay bdev p99 latency means that one percent of the I/O will be delayed by at
253least by the value of the p99 latency before being completed to the upper level protocol. All of the latency values
254are measured in microseconds.
255
256Example command:
257
258`rpc.py bdev_delay_create -b Null0 -d delay0 -r 10 --nine-nine-read-latency 50 -w 30 --nine-nine-write-latency 90`
259
260This command will create a delay bdev with average read and write latencies of 10 and 30 microseconds and p99 read
261and write latencies of 50 and 90 microseconds respectively.
262
263A delay bdev can be deleted using the `bdev_delay_delete` RPC
264
265Example command:
266
267`rpc.py bdev_delay_delete delay0`
268
269## GPT (GUID Partition Table) {#bdev_config_gpt}
270
271The GPT virtual bdev driver is enabled by default and does not require any configuration.
272It will automatically detect @ref bdev_ug_gpt on any attached bdev and will create
273possibly multiple virtual bdevs.
274
275### SPDK GPT partition table {#bdev_ug_gpt}
276
277The SPDK partition type GUID is `6527994e-2c5a-4eec-9613-8f5944074e8b`. Existing SPDK bdevs
278can be exposed as Linux block devices via NBD and then can be partitioned with
279standard partitioning tools. After partitioning, the bdevs will need to be deleted and
280attached again for the GPT bdev module to see any changes. NBD kernel module must be
281loaded first. To create NBD bdev user should use `nbd_start_disk` RPC command.
282
283Example command
284
285`rpc.py nbd_start_disk Malloc0 /dev/nbd0`
286
287This will expose an SPDK bdev `Malloc0` under the `/dev/nbd0` block device.
288
289To remove NBD device user should use `nbd_stop_disk` RPC command.
290
291Example command
292
293`rpc.py nbd_stop_disk /dev/nbd0`
294
295To display full or specified nbd device list user should use `nbd_get_disks` RPC command.
296
297Example command
298
299`rpc.py nbd_stop_disk -n /dev/nbd0`
300
301### Creating a GPT partition table using NBD {#bdev_ug_gpt_create_part}
302
303~~~bash
304# Expose bdev Nvme0n1 as kernel block device /dev/nbd0 by JSON-RPC
305rpc.py nbd_start_disk Nvme0n1 /dev/nbd0
306
307# Create GPT partition table.
308parted -s /dev/nbd0 mklabel gpt
309
310# Add a partition consuming 50% of the available space.
311parted -s /dev/nbd0 mkpart MyPartition '0%' '50%'
312
313# Change the partition type to the SPDK GUID.
314# sgdisk is part of the gdisk package.
315sgdisk -t 1:6527994e-2c5a-4eec-9613-8f5944074e8b /dev/nbd0
316
317# Stop the NBD device (stop exporting /dev/nbd0).
318rpc.py nbd_stop_disk /dev/nbd0
319
320# Now Nvme0n1 is configured with a GPT partition table, and
321# the first partition will be automatically exposed as
322# Nvme0n1p1 in SPDK applications.
323~~~
324
325## iSCSI bdev {#bdev_config_iscsi}
326
327The SPDK iSCSI bdev driver depends on libiscsi and hence is not enabled by default.
328In order to use it, build SPDK with an extra `--with-iscsi-initiator` configure option.
329
330The following command creates an `iSCSI0` bdev from a single LUN exposed at given iSCSI URL
331with `iqn.2016-06.io.spdk:init` as the reported initiator IQN.
332
333`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`
334
335The URL is in the following format:
336`iscsi://[<username>[%<password>]@]<host>[:<port>]/<target-iqn>/<lun>`
337
338## Linux AIO bdev {#bdev_config_aio}
339
340The SPDK AIO bdev driver provides SPDK block layer access to Linux kernel block
341devices or a file on a Linux filesystem via Linux AIO. Note that O_DIRECT is
342used and thus bypasses the Linux page cache. This mode is probably as close to
343a typical kernel based target as a user space target can get without using a
344user-space driver. To create AIO bdev RPC command `bdev_aio_create` should be
345used.
346
347Example commands
348
349`rpc.py bdev_aio_create /dev/sda aio0`
350
351This command will create `aio0` device from /dev/sda.
352
353`rpc.py bdev_aio_create /tmp/file file 4096`
354
355This command will create `file` device with block size 4096 from /tmp/file.
356
357To delete an aio bdev use the bdev_aio_delete command.
358
359`rpc.py bdev_aio_delete aio0`
360
361## OCF Virtual bdev {#bdev_config_cas}
362
363OCF virtual bdev module is based on [Open CAS Framework](https://github.com/Open-CAS/ocf) - a
364high performance block storage caching meta-library.
365To enable the module, configure SPDK using `--with-ocf` flag.
366OCF bdev can be used to enable caching for any underlying bdev.
367
368Below is an example command for creating OCF bdev:
369
370`rpc.py bdev_ocf_create Cache1 wt Malloc0 Nvme0n1`
371
372This command will create new OCF bdev `Cache1` having bdev `Malloc0` as caching-device
373and `Nvme0n1` as core-device and initial cache mode `Write-Through`.
374`Malloc0` will be used as cache for `Nvme0n1`, so  data written to `Cache1` will be present
375on `Nvme0n1` eventually.
376By default, OCF will be configured with cache line size equal 4KiB
377and non-volatile metadata will be disabled.
378
379To remove `Cache1`:
380
381`rpc.py bdev_ocf_delete Cache1`
382
383During removal OCF-cache will be stopped and all cached data will be written to the core device.
384
385Note that OCF has a per-device RAM requirement. More details can be found in the
386[OCF documentation](https://open-cas.github.io/guide_system_requirements.html).
387
388## Malloc bdev {#bdev_config_malloc}
389
390Malloc bdevs are ramdisks. Because of its nature they are volatile. They are created from hugepage memory given to SPDK
391application.
392
393Example command for creating malloc bdev:
394
395`rpc.py bdev_malloc_create -b Malloc0 64 512`
396
397Example command for removing malloc bdev:
398
399`rpc.py bdev_malloc_delete Malloc0`
400
401## Null {#bdev_config_null}
402
403The SPDK null bdev driver is a dummy block I/O target that discards all writes and returns undefined
404data for reads.  It is useful for benchmarking the rest of the bdev I/O stack with minimal block
405device overhead and for testing configurations that can't easily be created with the Malloc bdev.
406To create Null bdev RPC command `bdev_null_create` should be used.
407
408Example command
409
410`rpc.py bdev_null_create Null0 8589934592 4096`
411
412This command will create an 8 petabyte `Null0` device with block size 4096.
413
414To delete a null bdev use the bdev_null_delete command.
415
416`rpc.py bdev_null_delete Null0`
417
418## NVMe bdev {#bdev_config_nvme}
419
420There are two ways to create block device based on NVMe device in SPDK. First
421way is to connect local PCIe drive and second one is to connect NVMe-oF device.
422In both cases user should use `bdev_nvme_attach_controller` RPC command to achieve that.
423
424Example commands
425
426`rpc.py bdev_nvme_attach_controller -b NVMe1 -t PCIe -a 0000:01:00.0`
427
428This command will create NVMe bdev of physical device in the system.
429
430`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`
431
432This command will create NVMe bdev of NVMe-oF resource.
433
434To remove an NVMe controller use the bdev_nvme_detach_controller command.
435
436`rpc.py bdev_nvme_detach_controller Nvme0`
437
438This command will remove NVMe bdev named Nvme0.
439
440The SPDK NVMe bdev driver provides the multipath feature. Please refer to
441@ref nvme_multipath for details.
442
443### NVMe bdev character device {#bdev_config_nvme_cuse}
444
445Example commands
446
447`rpc.py bdev_nvme_cuse_register -n Nvme3`
448
449This command will register a character device under /dev/spdk associated with Nvme3
450controller. If there are namespaces created on Nvme3 controller, a namespace
451character device is also created for each namespace.
452
453For example, the first controller registered will have a character device path of
454/dev/spdk/nvmeX, where X is replaced with a unique integer to differentiate it from
455other controllers.  Note that this 'nvmeX' name here has no correlation to the name
456associated with the controller in SPDK.  Namespace character devices will have a path
457of /dev/spdk/nvmeXnY, where Y is the namespace ID.
458
459Cuse devices are removed from system, when NVMe controller is detached or unregistered
460with command:
461
462`rpc.py bdev_nvme_cuse_unregister -n Nvme0`
463
464## Logical volumes {#bdev_ug_logical_volumes}
465
466The Logical Volumes library is a flexible storage space management system. It allows
467creating and managing virtual block devices with variable size on top of other bdevs.
468The SPDK Logical Volume library is built on top of @ref blob. For detailed description
469please refer to @ref lvol.
470
471### Logical volume store {#bdev_ug_lvol_store}
472
473Before creating any logical volumes (lvols), an lvol store has to be created first on
474selected block device. Lvol store is lvols vessel responsible for managing underlying
475bdev space assignment to lvol bdevs and storing metadata. To create lvol store user
476should use using `bdev_lvol_create_lvstore` RPC command.
477
478Example command
479
480`rpc.py bdev_lvol_create_lvstore Malloc2 lvs -c 4096`
481
482This will create lvol store named `lvs` with cluster size 4096, build on top of
483`Malloc2` bdev. In response user will be provided with uuid which is unique lvol store
484identifier.
485
486User can get list of available lvol stores using `bdev_lvol_get_lvstores` RPC command (no
487parameters available).
488
489Example response
490~~~
491{
492  "uuid": "330a6ab2-f468-11e7-983e-001e67edf35d",
493  "base_bdev": "Malloc2",
494  "free_clusters": 8190,
495  "cluster_size": 8192,
496  "total_data_clusters": 8190,
497  "block_size": 4096,
498  "name": "lvs"
499}
500~~~
501
502To delete lvol store user should use `bdev_lvol_delete_lvstore` RPC command.
503
504Example commands
505
506`rpc.py bdev_lvol_delete_lvstore -u 330a6ab2-f468-11e7-983e-001e67edf35d`
507
508`rpc.py bdev_lvol_delete_lvstore -l lvs`
509
510### Lvols {#bdev_ug_lvols}
511
512To create lvols on existing lvol store user should use `bdev_lvol_create` RPC command.
513Each created lvol will be represented by new bdev.
514
515Example commands
516
517`rpc.py bdev_lvol_create lvol1 25 -l lvs`
518
519`rpc.py bdev_lvol_create lvol2 25 -u 330a6ab2-f468-11e7-983e-001e67edf35d`
520
521## Passthru {#bdev_config_passthru}
522
523The SPDK Passthru virtual block device module serves as an example of how to write a
524virtual block device module. It implements the required functionality of a vbdev module
525and demonstrates some other basic features such as the use of per I/O context.
526
527Example commands
528
529`rpc.py bdev_passthru_create -b aio -p pt`
530
531`rpc.py bdev_passthru_delete pt`
532
533## RAID {#bdev_ug_raid}
534
535RAID virtual bdev module provides functionality to combine any SPDK bdevs into one
536RAID bdev. Currently SPDK supports RAID0, Concat, RAID1 and RAID5F levels. To enable
537RAID5F, configure SPDK using the `--with-raid5f` option. For RAID levels with redundancy
538(1 and 5F) degraded operation and rebuild are supported. RAID metadata may be stored
539on member disks if enabled when creating the RAID bdev, so user does not have to
540recreate the RAID volume when restarting application. It is not enabled by
541default for backward compatibility. User may specify member disks to create
542RAID volume even if they do not exist yet - as the member disks are registered at
543a later time, the RAID module will claim them and will surface the RAID volume
544after all of the member disks are available. It is allowed to use disks of
545different sizes - the smallest disk size will be the amount of space used on
546each member disk.
547
548Example commands
549
550`rpc.py bdev_raid_create -n Raid0 -z 64 -r 0 -b "lvol0 lvol1 lvol2 lvol3"`
551
552`rpc.py bdev_raid_get_bdevs`
553
554`rpc.py bdev_raid_delete Raid0`
555
556## Split {#bdev_ug_split}
557
558The split block device module takes an underlying block device and splits it into
559several smaller equal-sized virtual block devices. This serves as an example to create
560more vbdevs on a given base bdev for user testing.
561
562Example commands
563
564To create four split bdevs with base bdev_b0 use the `bdev_split_create` command.
565Each split bdev will be one fourth the size of the base bdev.
566
567`rpc.py bdev_split_create bdev_b0 4`
568
569The `split_size_mb`(-s) parameter restricts the size of each split bdev.
570The total size of all split bdevs must not exceed the base bdev size.
571
572`rpc.py bdev_split_create bdev_b0 4 -s 128`
573
574To remove the split bdevs, use the `bdev_split_delete` command with the base bdev name.
575
576`rpc.py bdev_split_delete bdev_b0`
577
578## Uring {#bdev_ug_uring}
579
580The uring bdev module issues I/O to kernel block devices using the io_uring Linux kernel API. This module requires liburing.
581For more information on io_uring refer to kernel [IO_uring] (https://kernel.dk/io_uring.pdf)
582
583The user needs to configure SPDK to include io_uring support:
584
585`configure --with-uring`
586
587Support for zoned devices is enabled by default in uring bdev. It can be explicitly disabled as follows:
588
589`configure --with-uring --without-uring-zns`
590
591To create a uring bdev with given filename, bdev name and block size use the `bdev_uring_create` RPC.
592
593`rpc.py  bdev_uring_create /path/to/device bdev_u0 512`
594
595To remove a uring bdev use the `bdev_uring_delete` RPC.
596
597`rpc.py bdev_uring_delete bdev_u0`
598
599## xNVMe {#bdev_ug_xnvme}
600
601The xNVMe bdev module issues I/O to the underlying NVMe devices through various I/O mechanisms
602such as libaio, io_uring, Asynchronous IOCTL using io_uring passthrough, POSIX aio, emulated aio etc.
603
604This module requires the xNVMe library.
605For more information on xNVMe refer to [xNVMe] (https://xnvme.io)
606
607The user needs to configure SPDK to include xNVMe support:
608
609`configure --with-xnvme`
610
611To create a xNVMe bdev with given filename, bdev name and I/O mechanism use the `bdev_xnvme_create` RPC.
612
613`rpc.py  bdev_xnvme_create /dev/ng0n1 bdev_ng0n1 io_uring_cmd`
614
615The most important I/O mechanisms are:
616
617- "libaio"
618- "io_uring"
619- "io_uring_cmd" (requires linux kernel v5.19 or newer)
620
621To remove a xnvme bdev use the `bdev_xnvme_delete` RPC.
622
623`rpc.py bdev_xnvme_delete bdev_ng0n1`
624
625## Virtio Block {#bdev_config_virtio_blk}
626
627The Virtio-Block driver allows creating SPDK bdevs from Virtio-Block devices.
628
629The following command creates a Virtio-Block device named `VirtioBlk0` from a vhost-user
630socket `/tmp/vhost.0` exposed directly by SPDK @ref vhost. Optional `vq-count` and
631`vq-size` params specify number of request queues and queue depth to be used.
632
633`rpc.py bdev_virtio_attach_controller --dev-type blk --trtype user --traddr /tmp/vhost.0 --vq-count 2 --vq-size 512 VirtioBlk0`
634
635The driver can be also used inside QEMU-based VMs. The following command creates a Virtio
636Block device named `VirtioBlk0` from a Virtio PCI device at address `0000:00:01.0`.
637The entire configuration will be read automatically from PCI Configuration Space. It will
638reflect all parameters passed to QEMU's vhost-user-scsi-pci device.
639
640`rpc.py bdev_virtio_attach_controller --dev-type blk --trtype pci --traddr 0000:01:00.0 VirtioBlk1`
641
642Virtio-Block devices can be removed with the following command
643
644`rpc.py bdev_virtio_detach_controller VirtioBlk0`
645
646## Virtio SCSI {#bdev_config_virtio_scsi}
647
648The Virtio-SCSI driver allows creating SPDK block devices from Virtio-SCSI LUNs.
649
650Virtio-SCSI bdevs are created the same way as Virtio-Block ones.
651
652`rpc.py bdev_virtio_attach_controller --dev-type scsi --trtype user --traddr /tmp/vhost.0 --vq-count 2 --vq-size 512 VirtioScsi0`
653
654`rpc.py bdev_virtio_attach_controller --dev-type scsi --trtype pci --traddr 0000:01:00.0 VirtioScsi0`
655
656Each Virtio-SCSI device may export up to 64 block devices named VirtioScsi0t0 ~ VirtioScsi0t63,
657one LUN (LUN0) per SCSI device. The above 2 commands will output names of all exposed bdevs.
658
659Virtio-SCSI devices can be removed with the following command
660
661`rpc.py bdev_virtio_detach_controller VirtioScsi0`
662
663Removing a Virtio-SCSI device will destroy all its bdevs.
664
665## DAOS bdev {#bdev_config_daos}
666
667DAOS bdev creates SPDK block device on top of DAOS DFS, the name of the bdev defines the file name in DFS namespace.
668Note that DAOS container has to be POSIX type, e.g.: ` daos cont create --pool=test-pool --label=test-cont --type=POSIX`
669
670To build SPDK with daos support, daos-devel package has to be installed, please see the setup [guide](https://docs.daos.io/v2.0/).
671To enable the module, configure SPDK using `--with-daos` flag.
672
673Running `daos_agent` service on the target machine is required for the SPDK DAOS bdev communication with a DAOS cluster.
674
675The implementation uses the independent pool and container connections per device's channel for the best IO throughput, therefore,
676running a target application with multiple cores (`-m [0-7], for example) is highly advisable.
677
678Example command for creating daos bdev:
679
680`rpc.py bdev_daos_create daosdev0 test-pool test-cont 64 4096`
681
682Example command for removing daos bdev:
683
684`rpc.py bdev_daos_delete daosdev0`
685
686To resize a bdev use the bdev_daos_resize command.
687
688`rpc.py bdev_daos_resize daosdev0 8192`
689
690This command will resize the daosdev0 bdev to 8192 MiB.
691