xref: /spdk/doc/bdev.md (revision 6e2c32c34eb9f49cb5301d8017e57da512f1fef7)
10124a07dSMaciej Szwed# Block Device User Guide {#bdev}
21a787169SDaniel Verkamp
31e1fd9acSwawryk## Target Audience {#bdev_ug_targetaudience}
4802fd5bfSMonica Kenguva
512fcbc9bSwawrykThis user guide is intended for software developers who have knowledge of block storage, storage drivers, issuing JSON-RPC
612fcbc9bSwawrykcommands and storage services such as RAID, compression, crypto, and others.
7802fd5bfSMonica Kenguva
81e1fd9acSwawryk## Introduction {#bdev_ug_introduction}
91a787169SDaniel Verkamp
104163a275SBen WalkerThe SPDK block device layer, often simply called *bdev*, is a C library
114163a275SBen Walkerintended to be equivalent to the operating system block storage layer that
124163a275SBen Walkeroften sits immediately above the device drivers in a traditional kernel
134163a275SBen Walkerstorage stack. Specifically, this library provides the following
144163a275SBen Walkerfunctionality:
151a787169SDaniel Verkamp
164163a275SBen Walker* A pluggable module API for implementing block devices that interface with different types of block storage devices.
170124a07dSMaciej Szwed* Driver modules for NVMe, malloc (ramdisk), Linux AIO, virtio-scsi, Ceph RBD, Pmem and Vhost-SCSI Initiator and more.
184163a275SBen Walker* An application API for enumerating and claiming SPDK block devices and then performing operations (read, write, unmap, etc.) on those devices.
194163a275SBen Walker* Facilities to stack block devices to create complex I/O pipelines, including logical volume management (lvol) and partition support (GPT).
200124a07dSMaciej Szwed* Configuration of block devices via JSON-RPC.
214163a275SBen Walker* Request queueing, timeout, and reset handling.
224163a275SBen Walker* Multiple, lockless queues for sending I/O to block devices.
231a787169SDaniel Verkamp
240124a07dSMaciej SzwedBdev module creates abstraction layer that provides common API for all devices.
250124a07dSMaciej SzwedUser can use available bdev modules or create own module with any type of
260124a07dSMaciej Szweddevice underneath (please refer to @ref bdev_module for details). SPDK
270124a07dSMaciej Szwedprovides also vbdev modules which creates block devices on existing bdev. For
280124a07dSMaciej Szwedexample @ref bdev_ug_logical_volumes or @ref bdev_ug_gpt
291a787169SDaniel Verkamp
301e1fd9acSwawryk## Prerequisites {#bdev_ug_prerequisites}
310fb41bb1SPaul Luse
320124a07dSMaciej SzwedThis guide assumes that you can already build the standard SPDK distribution
330124a07dSMaciej Szwedon your platform. The block device layer is a C library with a single public
340124a07dSMaciej Szwedheader file named bdev.h. All SPDK configuration described in following
350124a07dSMaciej Szwedchapters is done by using JSON-RPC commands. SPDK provides a python-based
360124a07dSMaciej Szwedcommand line tool for sending RPC commands located at `scripts/rpc.py`. User
370124a07dSMaciej Szwedcan list available commands by running this script with `-h` or `--help` flag.
380124a07dSMaciej SzwedAdditionally user can retrieve currently supported set of RPC commands
396ee44c69SJim Harrisdirectly from SPDK application by running `scripts/rpc.py rpc_get_methods`.
400124a07dSMaciej SzwedDetailed help for each command can be displayed by adding `-h` flag as a
410124a07dSMaciej Szwedcommand parameter.
421a787169SDaniel Verkamp
431e1fd9acSwawryk## Configuring Block Device Modules {#bdev_ug_general_rpcs}
440124a07dSMaciej Szwed
45802fd5bfSMonica KenguvaBlock devices can be configured using JSON RPCs. A complete list of available RPC commands
46802fd5bfSMonica Kenguvawith detailed information can be found on the @ref jsonrpc_components_bdev page.
470124a07dSMaciej Szwed
481e1fd9acSwawryk## Common Block Device Configuration Examples
49891bf99aSPiotr Pelplinski
501e1fd9acSwawryk## Ceph RBD {#bdev_config_rbd}
510124a07dSMaciej Szwed
520124a07dSMaciej SzwedThe SPDK RBD bdev driver provides SPDK block layer access to Ceph RADOS block
530124a07dSMaciej Szweddevices (RBD). Ceph RBD devices are accessed via librbd and librados libraries
540124a07dSMaciej Szwedto access the RADOS block device exported by Ceph. To create Ceph bdev RPC
55bde5d09bSYifan Biancommand `bdev_rbd_register_cluster` and `bdev_rbd_create` should be used.
56bde5d09bSYifan Bian
57bde5d09bSYifan BianSPDK provides two ways of creating a RBD bdev. One is to create a new Rados cluster object
58bde5d09bSYifan Bianfor each RBD bdev. Another is to share the same Rados cluster object for multiple RBD bdevs.
59bde5d09bSYifan BianEach Rados cluster object creates a small number of io_context_pool and messenger threads.
60bde5d09bSYifan BianCeph commands `ceph config help librados_thread_count` and `ceph config help ms_async_op_threads`
61bde5d09bSYifan Biancould help to check these threads information. Besides, you can specify the number of threads by
62bde5d09bSYifan Bianupdating ceph.conf file or using Ceph config commands. For more information, please refer to
63bde5d09bSYifan Bian[Ceph configuration](https://docs.ceph.com/en/latest/rados/configuration/ceph-conf/)
64bde5d09bSYifan BianOne set of threads may not be enough to maximize performance with a large number of RBD bdevs,
65bde5d09bSYifan Bianbut one set of threads per RBD bdev may add too much context switching. Therefore, performance
66bde5d09bSYifan Biantuning on the number of RBD bdevs per cluster object and thread may be required.
670124a07dSMaciej Szwed
680124a07dSMaciej SzwedExample command
690124a07dSMaciej Szwed
70bde5d09bSYifan Bian`rpc.py bdev_rbd_register_cluster rbd_cluster`
71bde5d09bSYifan Bian
72bde5d09bSYifan BianThis command will register a cluster named rbd_cluster. Optional `--config-file` and
73bde5d09bSYifan Bian`--key-file` params are specified for the cluster.
74bde5d09bSYifan Bian
75bde5d09bSYifan BianTo remove a registered cluster use the bdev_rbd_unregister_cluster command.
76bde5d09bSYifan Bian
77bde5d09bSYifan Bian`rpc.py bdev_rbd_unregister_cluster rbd_cluster`
78bde5d09bSYifan Bian
79bde5d09bSYifan BianTo create RBD bdev with a registered cluster.
80bde5d09bSYifan Bian
81bde5d09bSYifan Bian`rpc.py bdev_rbd_create rbd foo 512 -c rbd_cluster`
820124a07dSMaciej Szwed
830124a07dSMaciej SzwedThis command will create a bdev that represents the 'foo' image from a pool called 'rbd'.
84bde5d09bSYifan BianWhen specifying -c for `bdev_rbd_create`, RBD bdevs will share the same rados cluster with
85bde5d09bSYifan Bianone connection of Ceph in librbd module. Instead it will create a new rados cluster with one
86bde5d09bSYifan Biancluster connection for every bdev without specifying -c.
870124a07dSMaciej Szwed
88164939aaSMaciej WawrykTo remove a block device representation use the bdev_rbd_delete command.
8906192d28SMaciej Szwed
90164939aaSMaciej Wawryk`rpc.py bdev_rbd_delete Rbd0`
9106192d28SMaciej Szwed
926a29c6a9SLiang YanTo resize a bdev use the bdev_rbd_resize command.
936a29c6a9SLiang Yan
946a29c6a9SLiang Yan`rpc.py bdev_rbd_resize Rbd0 4096`
956a29c6a9SLiang Yan
966a29c6a9SLiang YanThis command will resize the Rbd0 bdev to 4096 MiB.
976a29c6a9SLiang Yan
981e1fd9acSwawryk## Compression Virtual Bdev Module {#bdev_config_compress}
99d8d2635dSpaul luse
100d8d2635dSpaul luseThe compression bdev module can be configured to provide compression/decompression
101d8d2635dSpaul luseservices for an underlying thinly provisioned logical volume. Although the underlying
102d8d2635dSpaul lusemodule can be anything (i.e. NVME bdev) the overall compression benefits will not be realized
103d8d2635dSpaul luseunless the data stored on disk is placed appropriately. The compression vbdev module
104d8d2635dSpaul luserelies on an internal SPDK library called `reduce` to accomplish this, see @ref reduce
105d8d2635dSpaul lusefor detailed information.
106d8d2635dSpaul luse
107bb5083a8Spaul luseThe compression bdev module leverages the [Acceleration Framework](https://spdk.io/doc/accel_fw.html) to
108bb5083a8Spaul lusecarry out the actual compression and decompression. The acceleration framework can be configured to use
109bb5083a8Spaul luseISA-L software optimized compression or the DPDK Compressdev module for hardware acceleration. To configure
110bb5083a8Spaul lusethe Compressdev module please see the `compressdev_scan_accel_module` documentation [here](https://spdk.io/doc/jsonrpc.html)
111d8d2635dSpaul luse
112d8d2635dSpaul lusePersistent memory is used to store metadata associated with the layout of the data on the
113d8d2635dSpaul lusebacking device. SPDK relies on [PMDK](http://pmem.io/pmdk/) to interface persistent memory so any hardware
114d8d2635dSpaul lusesupported by PMDK should work. If the directory for PMEM supplied upon vbdev creation does
115d8d2635dSpaul lusenot point to persistent memory (i.e. a regular filesystem) performance will be severely
116d8d2635dSpaul luseimpacted.  The vbdev module and reduce libraries were designed to use persistent memory for
117d8d2635dSpaul luseany production use.
118d8d2635dSpaul luse
119d8d2635dSpaul luseExample command
120d8d2635dSpaul luse
1219a91a45cSMaciej Wawryk`rpc.py bdev_compress_create -p /pmem_files -b myLvol`
122d8d2635dSpaul luse
123d8d2635dSpaul luseIn this example, a compression vbdev is created using persistent memory that is mapped to
124d8d2635dSpaul lusethe directory `pmem_files` on top of the existing thinly provisioned logical volume `myLvol`.
125d8d2635dSpaul luseThe resulting compression bdev will be named `COMP_LVS/myLvol` where LVS is the name of the
126d8d2635dSpaul luselogical volume store that `myLvol` resides on.
127d8d2635dSpaul luse
128d8d2635dSpaul luseThe logical volume is referred to as the backing device and once the compression vbdev is
129d8d2635dSpaul lusecreated it cannot be separated from the persistent memory file that will be created in
130d8d2635dSpaul lusethe specified directory.  If the persistent memory file is not available, the compression
131d8d2635dSpaul lusevbdev will also not be available.
132d8d2635dSpaul luse
133d8d2635dSpaul luseTo remove a compression vbdev, use the following command which will also delete the PMEM
134d8d2635dSpaul lusefile.  If the logical volume is deleted the PMEM file will not be removed and the
135d8d2635dSpaul lusecompression vbdev will not be available.
136d8d2635dSpaul luse
1379a91a45cSMaciej Wawryk`rpc.py bdev_compress_delete COMP_LVS/myLvol`
138d8d2635dSpaul luse
13968e7da44Spaul luseTo list compression volumes that are only available for deletion because their PMEM file
14068e7da44Spaul lusewas missing use the following. The name parameter is optional and if not included will list
14168e7da44Spaul luseall volumes, if used it will return the name or an error that the device does not exist.
14268e7da44Spaul luse
14368e7da44Spaul luse`rpc.py bdev_compress_get_orphans --name COMP_Nvme0n1`
14468e7da44Spaul luse
1451e1fd9acSwawryk## Crypto Virtual Bdev Module {#bdev_config_crypto}
14651606ed4SPaul Luse
14751606ed4SPaul LuseThe crypto virtual bdev module can be configured to provide at rest data encryption
14813f97e67SAlexey Marchukfor any underlying bdev. The module relies on the SPDK Accel Framework to provide
14913f97e67SAlexey Marchukall cryptographic functionality.
15013f97e67SAlexey MarchukOne of the accel modules, dpdk_cryptodev is implemented with the DPDK CryptoDev API,
15113f97e67SAlexey Marchukit provides support for many different software only cryptographic modules as well hardware
15213f97e67SAlexey Marchukassisted support for the Intel QAT board and NVIDIA crypto enabled NICs.
15313f97e67SAlexey Marchuk
15413f97e67SAlexey MarchukFor reads, the buffer provided to the crypto block device will be used as the destination buffer
15513f97e67SAlexey Marchukfor unencrypted data.  For writes, however, a temporary scratch buffer is used as the
15613f97e67SAlexey Marchukdestination buffer for encryption which is then passed on to the underlying bdev as the
15713f97e67SAlexey Marchukwrite buffer.  This is done to avoid encrypting the data in the original source buffer which
15813f97e67SAlexey Marchukmay cause problems in some use cases.
15913f97e67SAlexey Marchuk
16013f97e67SAlexey MarchukBelow is information about accel modules which support crypto operations:
16113f97e67SAlexey Marchuk
16213f97e67SAlexey Marchuk### dpdk_cryptodev accel module
16313f97e67SAlexey Marchuk
16413f97e67SAlexey MarchukSupports the following ciphers:
16551606ed4SPaul Luse
16651606ed4SPaul Luse- AESN-NI Multi Buffer Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES128_CBC
16745f24aebSYuriy Umanets- Intel(R) QuickAssist (QAT) Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES128_CBC,
16845f24aebSYuriy Umanets  RTE_CRYPTO_CIPHER_AES128_XTS
16951606ed4SPaul Luse  (Note: QAT is functional however is marked as experimental until the hardware has
17051606ed4SPaul Luse  been fully integrated with the SPDK CI system.)
17145f24aebSYuriy Umanets- MLX5 Crypto Poll Mode Driver: RTE_CRYPTO_CIPHER_AES256_XTS, RTE_CRYPTO_CIPHER_AES512_XTS
17251606ed4SPaul Luse
17351606ed4SPaul LuseIn order to support using the bdev block offset (LBA) as the initialization vector (IV),
17451606ed4SPaul Lusethe crypto module break up all I/O into crypto operations of a size equal to the block
17551606ed4SPaul Lusesize of the underlying bdev.  For example, a 4K I/O to a bdev with a 512B block size,
17651606ed4SPaul Lusewould result in 8 cryptographic operations.
17751606ed4SPaul Luse
17813f97e67SAlexey Marchuk### SW accel module
17951606ed4SPaul Luse
18013f97e67SAlexey MarchukSupports the following ciphers:
1815968bd62Spaul luse
18213f97e67SAlexey Marchuk- AES_XTS cipher with 128 or 256 bit keys implemented with ISA-L_crypto
1835968bd62Spaul luse
18413f97e67SAlexey Marchuk### General workflow
18513f97e67SAlexey Marchuk
18613f97e67SAlexey Marchuk- Set desired accel module to perform crypto operations, that can be done with `accel_assign_opc` RPC command
18713f97e67SAlexey Marchuk- Create a named crypto key using `accel_crypto_key_create` RPC command. The key will use the assigned accel
18813f97e67SAlexey Marchuk  module. Set of parameters and supported ciphers may be different in each accel module.
18913f97e67SAlexey Marchuk- Create virtual crypto block device providing the base block device name and the crypto key name
19013f97e67SAlexey Marchuk  using `bdev_crypto_create` RPC command
19113f97e67SAlexey Marchuk
19213f97e67SAlexey Marchuk#### Example
19313f97e67SAlexey Marchuk
19413f97e67SAlexey MarchukExample command which uses dpdk_cryptodev accel module
19513f97e67SAlexey Marchuk```
19613f97e67SAlexey Marchuk# start SPDK application with `--wait-for-rpc` parameter
19713f97e67SAlexey Marchukrpc.py dpdk_cryptodev_scan_accel_module
19813f97e67SAlexey Marchukrpc.py dpdk_cryptodev_set_driver crypto_aesni_mb
19913f97e67SAlexey Marchukrpc.py accel_assign_opc -o encrypt -m dpdk_cryptodev
20013f97e67SAlexey Marchukrpc.py accel_assign_opc -o decrypt -m dpdk_cryptodev
20113f97e67SAlexey Marchukrpc.py framework_start_init
20213f97e67SAlexey Marchukrpc.py accel_crypto_key_create -c AES_CBC -k 01234567891234560123456789123456 -n key_aesni_cbc_1
20313f97e67SAlexey Marchukrpc.py bdev_crypto_create NVMe1n1 CryNvmeA -n key_aesni_cbc_1
20413f97e67SAlexey Marchuk```
20513f97e67SAlexey Marchuk
20613f97e67SAlexey MarchukThese commands will create a crypto vbdev called 'CryNvmeA' on top of the NVMe bdev
20713f97e67SAlexey Marchuk'NVMe1n1' and will use a key named `key_aesni_cbc_1`. The key will work with the accel module which
20813f97e67SAlexey Marchukhas been assigned for encrypt operations, in this example it will be the dpdk_cryptodev.
20913f97e67SAlexey Marchuk
21013f97e67SAlexey Marchuk### Crypto key format
2111434e255SYuriy Umanets
2121434e255SYuriy UmanetsPlease make sure the keys are provided in hexlified format. This means string passed to
2131434e255SYuriy Umanetsrpc.py must be twice as long than the key length in binary form.
2141434e255SYuriy Umanets
21513f97e67SAlexey Marchuk#### Example command
2161434e255SYuriy Umanets
217*6e2c32c3SHadi Moshayedi`rpc.py accel_crypto_key_create -c AES_XTS -e 7859243a027411e581e0c40a35c8228f -k 10fee72b3d47553e065affdb48c54a81 -n sample_key`
2181434e255SYuriy Umanets
21913f97e67SAlexey MarchukThis command will create a key called `sample_key`, the AES key
220*6e2c32c3SHadi Moshayedi'10fee72b3d47553e065affdb48c54a81' and the XTS key
2211434e255SYuriy Umanets'7859243a027411e581e0c40a35c8228f'. In other words, the compound AES_XTS key to be used is
222*6e2c32c3SHadi Moshayedi'10fee72b3d47553e065affdb48c54a817859243a027411e581e0c40a35c8228f'
2235968bd62Spaul luse
22413f97e67SAlexey Marchuk### Delete the virtual crypto block device
22513f97e67SAlexey Marchuk
22640c959cbSMaciej WawrykTo remove the vbdev use the bdev_crypto_delete command.
2275968bd62Spaul luse
22840c959cbSMaciej Wawryk`rpc.py bdev_crypto_delete CryNvmeA`
2295968bd62Spaul luse
23013f97e67SAlexey Marchuk### dpdk_cryptodev mlx5_pci driver configuration
23113f97e67SAlexey Marchuk
23213f97e67SAlexey MarchukThe mlx5_pci driver works with crypto enabled Nvidia NICs and requires special configuration of
23345f24aebSYuriy UmanetsDPDK environment to enable crypto function. It can be done via SPDK event library by configuring
23445f24aebSYuriy Umanets`env_context` member of `spdk_app_opts` structure or by passing corresponding CLI arguments in
23545f24aebSYuriy Umanetsthe following form: `--allow=BDF,class=crypto,wcs_file=/full/path/to/wrapped/credentials`, e.g.
23645f24aebSYuriy Umanets`--allow=0000:01:00.0,class=crypto,wcs_file=/path/credentials.txt`.
23745f24aebSYuriy Umanets
2381e1fd9acSwawryk## Delay Bdev Module {#bdev_config_delay}
239faf726cdSSeth Howell
240faf726cdSSeth HowellThe delay vbdev module is intended to apply a predetermined additional latency on top of a lower
241faf726cdSSeth Howelllevel bdev. This enables the simulation of the latency characteristics of a device during the functional
242faf726cdSSeth Howellor scalability testing of an SPDK application. For example, to simulate the effect of drive latency when
243faf726cdSSeth Howellprocessing I/Os, one could configure a NULL bdev with a delay bdev on top of it.
244faf726cdSSeth Howell
245faf726cdSSeth HowellThe delay bdev module is not intended to provide a high fidelity replication of a specific NVMe drive's latency,
246faf726cdSSeth Howellinstead it's main purpose is to provide a "big picture" understanding of how a generic latency affects a given
247faf726cdSSeth Howellapplication.
248faf726cdSSeth Howell
249faf726cdSSeth HowellA delay bdev is created using the `bdev_delay_create` RPC. This rpc takes 6 arguments, one for the name
250faf726cdSSeth Howellof the delay bdev and one for the name of the base bdev. The remaining four arguments represent the following
251faf726cdSSeth Howelllatency values: average read latency, average write latency, p99 read latency, and p99 write latency.
252faf726cdSSeth HowellWithin the context of the delay bdev p99 latency means that one percent of the I/O will be delayed by at
253faf726cdSSeth Howellleast by the value of the p99 latency before being completed to the upper level protocol. All of the latency values
254faf726cdSSeth Howellare measured in microseconds.
255faf726cdSSeth Howell
256faf726cdSSeth HowellExample command:
257faf726cdSSeth Howell
258faf726cdSSeth Howell`rpc.py bdev_delay_create -b Null0 -d delay0 -r 10 --nine-nine-read-latency 50 -w 30 --nine-nine-write-latency 90`
259faf726cdSSeth Howell
260faf726cdSSeth HowellThis command will create a delay bdev with average read and write latencies of 10 and 30 microseconds and p99 read
261faf726cdSSeth Howelland write latencies of 50 and 90 microseconds respectively.
262faf726cdSSeth Howell
263faf726cdSSeth HowellA delay bdev can be deleted using the `bdev_delay_delete` RPC
264faf726cdSSeth Howell
265faf726cdSSeth HowellExample command:
266faf726cdSSeth Howell
267faf726cdSSeth Howell`rpc.py bdev_delay_delete delay0`
268faf726cdSSeth Howell
2691e1fd9acSwawryk## GPT (GUID Partition Table) {#bdev_config_gpt}
2700124a07dSMaciej Szwed
2710124a07dSMaciej SzwedThe GPT virtual bdev driver is enabled by default and does not require any configuration.
272f2d4c777SJim HarrisIt will automatically detect @ref bdev_ug_gpt on any attached bdev and will create
2730124a07dSMaciej Szwedpossibly multiple virtual bdevs.
2740124a07dSMaciej Szwed
2751e1fd9acSwawryk### SPDK GPT partition table {#bdev_ug_gpt}
276d9208c88SDarek Stojaczyk
2773a39d90bSJim HarrisThe SPDK partition type GUID is `6527994e-2c5a-4eec-9613-8f5944074e8b`. Existing SPDK bdevs
2785cdab5e2SDayu Liucan be exposed as Linux block devices via NBD and then can be partitioned with
2790124a07dSMaciej Szwedstandard partitioning tools. After partitioning, the bdevs will need to be deleted and
2801f813ec3SChen Wangattached again for the GPT bdev module to see any changes. NBD kernel module must be
2810a993323SPawel Kaminskiloaded first. To create NBD bdev user should use `nbd_start_disk` RPC command.
2820124a07dSMaciej Szwed
2830124a07dSMaciej SzwedExample command
2840124a07dSMaciej Szwed
2850a993323SPawel Kaminski`rpc.py nbd_start_disk Malloc0 /dev/nbd0`
2860124a07dSMaciej Szwed
2870124a07dSMaciej SzwedThis will expose an SPDK bdev `Malloc0` under the `/dev/nbd0` block device.
2880124a07dSMaciej Szwed
289d242f5a0SPawel KaminskiTo remove NBD device user should use `nbd_stop_disk` RPC command.
2900124a07dSMaciej Szwed
2910124a07dSMaciej SzwedExample command
2920124a07dSMaciej Szwed
293d242f5a0SPawel Kaminski`rpc.py nbd_stop_disk /dev/nbd0`
2940124a07dSMaciej Szwed
2955456a430SPawel KaminskiTo display full or specified nbd device list user should use `nbd_get_disks` RPC command.
2960124a07dSMaciej Szwed
2970124a07dSMaciej SzwedExample command
2980124a07dSMaciej Szwed
299d242f5a0SPawel Kaminski`rpc.py nbd_stop_disk -n /dev/nbd0`
3000124a07dSMaciej Szwed
3011e1fd9acSwawryk### Creating a GPT partition table using NBD {#bdev_ug_gpt_create_part}
3021a787169SDaniel Verkamp
30363ee471bSMaciej Wawryk~~~bash
304450ffbc6SXiaodong Liu# Expose bdev Nvme0n1 as kernel block device /dev/nbd0 by JSON-RPC
3050a993323SPawel Kaminskirpc.py nbd_start_disk Nvme0n1 /dev/nbd0
306450ffbc6SXiaodong Liu
30792a9961fSDaniel Verkamp# Create GPT partition table.
30892a9961fSDaniel Verkampparted -s /dev/nbd0 mklabel gpt
30992a9961fSDaniel Verkamp
31092a9961fSDaniel Verkamp# Add a partition consuming 50% of the available space.
31192a9961fSDaniel Verkampparted -s /dev/nbd0 mkpart MyPartition '0%' '50%'
31292a9961fSDaniel Verkamp
31392a9961fSDaniel Verkamp# Change the partition type to the SPDK GUID.
31492a9961fSDaniel Verkamp# sgdisk is part of the gdisk package.
3153a39d90bSJim Harrissgdisk -t 1:6527994e-2c5a-4eec-9613-8f5944074e8b /dev/nbd0
31692a9961fSDaniel Verkamp
3170124a07dSMaciej Szwed# Stop the NBD device (stop exporting /dev/nbd0).
318d242f5a0SPawel Kaminskirpc.py nbd_stop_disk /dev/nbd0
31992a9961fSDaniel Verkamp
32092a9961fSDaniel Verkamp# Now Nvme0n1 is configured with a GPT partition table, and
32192a9961fSDaniel Verkamp# the first partition will be automatically exposed as
32292a9961fSDaniel Verkamp# Nvme0n1p1 in SPDK applications.
32392a9961fSDaniel Verkamp~~~
3245226e908SPiotr Pelplinski
3251e1fd9acSwawryk## iSCSI bdev {#bdev_config_iscsi}
326c6eb4da6SDarek Stojaczyk
327c6eb4da6SDarek StojaczykThe SPDK iSCSI bdev driver depends on libiscsi and hence is not enabled by default.
328c6eb4da6SDarek StojaczykIn order to use it, build SPDK with an extra `--with-iscsi-initiator` configure option.
329c6eb4da6SDarek Stojaczyk
330c6eb4da6SDarek StojaczykThe following command creates an `iSCSI0` bdev from a single LUN exposed at given iSCSI URL
331c6eb4da6SDarek Stojaczykwith `iqn.2016-06.io.spdk:init` as the reported initiator IQN.
332c6eb4da6SDarek Stojaczyk
3339f5cbf4cSMaciej Wawryk`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`
334c6eb4da6SDarek Stojaczyk
335c6eb4da6SDarek StojaczykThe URL is in the following format:
336c6eb4da6SDarek Stojaczyk`iscsi://[<username>[%<password>]@]<host>[:<port>]/<target-iqn>/<lun>`
337c6eb4da6SDarek Stojaczyk
3381e1fd9acSwawryk## Linux AIO bdev {#bdev_config_aio}
339cd270e54Spaul luse
340cd270e54Spaul luseThe SPDK AIO bdev driver provides SPDK block layer access to Linux kernel block
341cd270e54Spaul lusedevices or a file on a Linux filesystem via Linux AIO. Note that O_DIRECT is
342cd270e54Spaul luseused and thus bypasses the Linux page cache. This mode is probably as close to
343cd270e54Spaul lusea typical kernel based target as a user space target can get without using a
344acaa079bSMaciej Wawrykuser-space driver. To create AIO bdev RPC command `bdev_aio_create` should be
345cd270e54Spaul luseused.
346cd270e54Spaul luse
347cd270e54Spaul luseExample commands
348cd270e54Spaul luse
349acaa079bSMaciej Wawryk`rpc.py bdev_aio_create /dev/sda aio0`
350cd270e54Spaul luse
351cd270e54Spaul luseThis command will create `aio0` device from /dev/sda.
352cd270e54Spaul luse
353ac498b14SDayu Liu`rpc.py bdev_aio_create /tmp/file file 4096`
354cd270e54Spaul luse
355ac498b14SDayu LiuThis command will create `file` device with block size 4096 from /tmp/file.
356cd270e54Spaul luse
357acaa079bSMaciej WawrykTo delete an aio bdev use the bdev_aio_delete command.
358cd270e54Spaul luse
359acaa079bSMaciej Wawryk`rpc.py bdev_aio_delete aio0`
360cd270e54Spaul luse
3611e1fd9acSwawryk## OCF Virtual bdev {#bdev_config_cas}
3629d893251SVitaliy Mysak
3634a6f4552STomasz ZawadzkiOCF virtual bdev module is based on [Open CAS Framework](https://github.com/Open-CAS/ocf) - a
3649d893251SVitaliy Mysakhigh performance block storage caching meta-library.
36569380320SVitaliy MysakTo enable the module, configure SPDK using `--with-ocf` flag.
3669d893251SVitaliy MysakOCF bdev can be used to enable caching for any underlying bdev.
3679d893251SVitaliy Mysak
3689d893251SVitaliy MysakBelow is an example command for creating OCF bdev:
3699d893251SVitaliy Mysak
370557f8ff9SPawel Kaminski`rpc.py bdev_ocf_create Cache1 wt Malloc0 Nvme0n1`
3719d893251SVitaliy Mysak
3729d893251SVitaliy MysakThis command will create new OCF bdev `Cache1` having bdev `Malloc0` as caching-device
3739d893251SVitaliy Mysakand `Nvme0n1` as core-device and initial cache mode `Write-Through`.
3749d893251SVitaliy Mysak`Malloc0` will be used as cache for `Nvme0n1`, so  data written to `Cache1` will be present
3759d893251SVitaliy Mysakon `Nvme0n1` eventually.
3769d893251SVitaliy MysakBy default, OCF will be configured with cache line size equal 4KiB
3779d893251SVitaliy Mysakand non-volatile metadata will be disabled.
3789d893251SVitaliy Mysak
3799d893251SVitaliy MysakTo remove `Cache1`:
3809d893251SVitaliy Mysak
381557f8ff9SPawel Kaminski`rpc.py bdev_ocf_delete Cache1`
3829d893251SVitaliy Mysak
3839d893251SVitaliy MysakDuring removal OCF-cache will be stopped and all cached data will be written to the core device.
3849d893251SVitaliy Mysak
38534584d25SRafal StefanowskiNote that OCF has a per-device RAM requirement. More details can be found in the
38634584d25SRafal Stefanowski[OCF documentation](https://open-cas.github.io/guide_system_requirements.html).
3879d893251SVitaliy Mysak
3881e1fd9acSwawryk## Malloc bdev {#bdev_config_malloc}
389cd270e54Spaul luse
390cd270e54Spaul luseMalloc bdevs are ramdisks. Because of its nature they are volatile. They are created from hugepage memory given to SPDK
391cd270e54Spaul luseapplication.
392cd270e54Spaul luse
393802fd5bfSMonica KenguvaExample command for creating malloc bdev:
394802fd5bfSMonica Kenguva
395802fd5bfSMonica Kenguva`rpc.py bdev_malloc_create -b Malloc0 64 512`
396802fd5bfSMonica Kenguva
397802fd5bfSMonica KenguvaExample command for removing malloc bdev:
398802fd5bfSMonica Kenguva
399802fd5bfSMonica Kenguva`rpc.py bdev_malloc_delete Malloc0`
400802fd5bfSMonica Kenguva
4011e1fd9acSwawryk## Null {#bdev_config_null}
402cd270e54Spaul luse
403cd270e54Spaul luseThe SPDK null bdev driver is a dummy block I/O target that discards all writes and returns undefined
404cd270e54Spaul lusedata for reads.  It is useful for benchmarking the rest of the bdev I/O stack with minimal block
405cd270e54Spaul lusedevice overhead and for testing configurations that can't easily be created with the Malloc bdev.
40660563dfeSPawel KaminskiTo create Null bdev RPC command `bdev_null_create` should be used.
407cd270e54Spaul luse
408cd270e54Spaul luseExample command
409cd270e54Spaul luse
41060563dfeSPawel Kaminski`rpc.py bdev_null_create Null0 8589934592 4096`
411cd270e54Spaul luse
412cd270e54Spaul luseThis command will create an 8 petabyte `Null0` device with block size 4096.
413cd270e54Spaul luse
41460563dfeSPawel KaminskiTo delete a null bdev use the bdev_null_delete command.
415cd270e54Spaul luse
41660563dfeSPawel Kaminski`rpc.py bdev_null_delete Null0`
417cd270e54Spaul luse
4181e1fd9acSwawryk## NVMe bdev {#bdev_config_nvme}
419cd270e54Spaul luse
420cd270e54Spaul luseThere are two ways to create block device based on NVMe device in SPDK. First
421cd270e54Spaul luseway is to connect local PCIe drive and second one is to connect NVMe-oF device.
422f54df840SPawel KaminskiIn both cases user should use `bdev_nvme_attach_controller` RPC command to achieve that.
423cd270e54Spaul luse
424cd270e54Spaul luseExample commands
425cd270e54Spaul luse
426f54df840SPawel Kaminski`rpc.py bdev_nvme_attach_controller -b NVMe1 -t PCIe -a 0000:01:00.0`
427cd270e54Spaul luse
428cd270e54Spaul luseThis command will create NVMe bdev of physical device in the system.
429cd270e54Spaul luse
430f54df840SPawel Kaminski`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`
431cd270e54Spaul luse
432cd270e54Spaul luseThis command will create NVMe bdev of NVMe-oF resource.
433cd270e54Spaul luse
43431e77a73SPawel KaminskiTo remove an NVMe controller use the bdev_nvme_detach_controller command.
435cd270e54Spaul luse
43631e77a73SPawel Kaminski`rpc.py bdev_nvme_detach_controller Nvme0`
437cd270e54Spaul luse
43831e77a73SPawel KaminskiThis command will remove NVMe bdev named Nvme0.
439cd270e54Spaul luse
440b0ab5524SShuhei MatsumotoThe SPDK NVMe bdev driver provides the multipath feature. Please refer to
441b0ab5524SShuhei Matsumoto@ref nvme_multipath for details.
442b0ab5524SShuhei Matsumoto
4431e1fd9acSwawryk### NVMe bdev character device {#bdev_config_nvme_cuse}
444e9b5bef8STomasz Zawadzki
445e9b5bef8STomasz ZawadzkiExample commands
446e9b5bef8STomasz Zawadzki
4473bdb0019Swanghailiangx`rpc.py bdev_nvme_cuse_register -n Nvme3`
448e9b5bef8STomasz Zawadzki
4498617ddc9SJim HarrisThis command will register a character device under /dev/spdk associated with Nvme3
4508617ddc9SJim Harriscontroller. If there are namespaces created on Nvme3 controller, a namespace
4518617ddc9SJim Harrischaracter device is also created for each namespace.
4528617ddc9SJim Harris
4538617ddc9SJim HarrisFor example, the first controller registered will have a character device path of
4548617ddc9SJim Harris/dev/spdk/nvmeX, where X is replaced with a unique integer to differentiate it from
4558617ddc9SJim Harrisother controllers.  Note that this 'nvmeX' name here has no correlation to the name
4568617ddc9SJim Harrisassociated with the controller in SPDK.  Namespace character devices will have a path
4578617ddc9SJim Harrisof /dev/spdk/nvmeXnY, where Y is the namespace ID.
458e9b5bef8STomasz Zawadzki
459e9b5bef8STomasz ZawadzkiCuse devices are removed from system, when NVMe controller is detached or unregistered
460e9b5bef8STomasz Zawadzkiwith command:
461e9b5bef8STomasz Zawadzki
462e9b5bef8STomasz Zawadzki`rpc.py bdev_nvme_cuse_unregister -n Nvme0`
463e9b5bef8STomasz Zawadzki
4641e1fd9acSwawryk## Logical volumes {#bdev_ug_logical_volumes}
4655226e908SPiotr Pelplinski
4660124a07dSMaciej SzwedThe Logical Volumes library is a flexible storage space management system. It allows
4670124a07dSMaciej Szwedcreating and managing virtual block devices with variable size on top of other bdevs.
4680124a07dSMaciej SzwedThe SPDK Logical Volume library is built on top of @ref blob. For detailed description
4690124a07dSMaciej Szwedplease refer to @ref lvol.
4700124a07dSMaciej Szwed
4711e1fd9acSwawryk### Logical volume store {#bdev_ug_lvol_store}
4720124a07dSMaciej Szwed
4730124a07dSMaciej SzwedBefore creating any logical volumes (lvols), an lvol store has to be created first on
4740124a07dSMaciej Szwedselected block device. Lvol store is lvols vessel responsible for managing underlying
4751f813ec3SChen Wangbdev space assignment to lvol bdevs and storing metadata. To create lvol store user
476de756853SMaciej Wawrykshould use using `bdev_lvol_create_lvstore` RPC command.
4770124a07dSMaciej Szwed
4780124a07dSMaciej SzwedExample command
4790124a07dSMaciej Szwed
480de756853SMaciej Wawryk`rpc.py bdev_lvol_create_lvstore Malloc2 lvs -c 4096`
4810124a07dSMaciej Szwed
4820124a07dSMaciej SzwedThis will create lvol store named `lvs` with cluster size 4096, build on top of
4830124a07dSMaciej Szwed`Malloc2` bdev. In response user will be provided with uuid which is unique lvol store
4840124a07dSMaciej Szwedidentifier.
4850124a07dSMaciej Szwed
4860b3f378fSMaciej WawrykUser can get list of available lvol stores using `bdev_lvol_get_lvstores` RPC command (no
4870124a07dSMaciej Szwedparameters available).
4880124a07dSMaciej Szwed
4890124a07dSMaciej SzwedExample response
4900124a07dSMaciej Szwed~~~
4910124a07dSMaciej Szwed{
4920124a07dSMaciej Szwed  "uuid": "330a6ab2-f468-11e7-983e-001e67edf35d",
4930124a07dSMaciej Szwed  "base_bdev": "Malloc2",
4940124a07dSMaciej Szwed  "free_clusters": 8190,
4950124a07dSMaciej Szwed  "cluster_size": 8192,
4960124a07dSMaciej Szwed  "total_data_clusters": 8190,
4970124a07dSMaciej Szwed  "block_size": 4096,
4980124a07dSMaciej Szwed  "name": "lvs"
4990124a07dSMaciej Szwed}
5000124a07dSMaciej Szwed~~~
5010124a07dSMaciej Szwed
5024c049618SMaciej WawrykTo delete lvol store user should use `bdev_lvol_delete_lvstore` RPC command.
5030124a07dSMaciej Szwed
5040124a07dSMaciej SzwedExample commands
5050124a07dSMaciej Szwed
5064c049618SMaciej Wawryk`rpc.py bdev_lvol_delete_lvstore -u 330a6ab2-f468-11e7-983e-001e67edf35d`
5070124a07dSMaciej Szwed
5084c049618SMaciej Wawryk`rpc.py bdev_lvol_delete_lvstore -l lvs`
5090124a07dSMaciej Szwed
5101e1fd9acSwawryk### Lvols {#bdev_ug_lvols}
5110124a07dSMaciej Szwed
512c57cd922SMaciej WawrykTo create lvols on existing lvol store user should use `bdev_lvol_create` RPC command.
5130124a07dSMaciej SzwedEach created lvol will be represented by new bdev.
5140124a07dSMaciej Szwed
5150124a07dSMaciej SzwedExample commands
5160124a07dSMaciej Szwed
517c57cd922SMaciej Wawryk`rpc.py bdev_lvol_create lvol1 25 -l lvs`
5180124a07dSMaciej Szwed
519c57cd922SMaciej Wawryk`rpc.py bdev_lvol_create lvol2 25 -u 330a6ab2-f468-11e7-983e-001e67edf35d`
5200124a07dSMaciej Szwed
5211e1fd9acSwawryk## Passthru {#bdev_config_passthru}
522cd270e54Spaul luse
523cd270e54Spaul luseThe SPDK Passthru virtual block device module serves as an example of how to write a
5241f813ec3SChen Wangvirtual block device module. It implements the required functionality of a vbdev module
525cd270e54Spaul luseand demonstrates some other basic features such as the use of per I/O context.
526cd270e54Spaul luse
527cd270e54Spaul luseExample commands
528cd270e54Spaul luse
5297e875f37SPawel Kaminski`rpc.py bdev_passthru_create -b aio -p pt`
530cd270e54Spaul luse
5317e875f37SPawel Kaminski`rpc.py bdev_passthru_delete pt`
532cd270e54Spaul luse
5331e1fd9acSwawryk## RAID {#bdev_ug_raid}
5347a71ae51SMonica Kenguva
5358aab02a7SArtur PaszkiewiczRAID virtual bdev module provides functionality to combine any SPDK bdevs into one
5368aab02a7SArtur PaszkiewiczRAID bdev. Currently SPDK supports RAID0, Concat, RAID1 and RAID5F levels. To enable
5378aab02a7SArtur PaszkiewiczRAID5F, configure SPDK using the `--with-raid5f` option. For RAID levels with redundancy
5388aab02a7SArtur Paszkiewicz(1 and 5F) degraded operation and rebuild are supported. RAID metadata may be stored
53977b8f7b6SArtur Paszkiewiczon member disks if enabled when creating the RAID bdev, so user does not have to
54077b8f7b6SArtur Paszkiewiczrecreate the RAID volume when restarting application. It is not enabled by
54177b8f7b6SArtur Paszkiewiczdefault for backward compatibility. User may specify member disks to create
54277b8f7b6SArtur PaszkiewiczRAID volume even if they do not exist yet - as the member disks are registered at
5437a71ae51SMonica Kenguvaa later time, the RAID module will claim them and will surface the RAID volume
5447a71ae51SMonica Kenguvaafter all of the member disks are available. It is allowed to use disks of
5457a71ae51SMonica Kenguvadifferent sizes - the smallest disk size will be the amount of space used on
5467a71ae51SMonica Kenguvaeach member disk.
5477a71ae51SMonica Kenguva
5487a71ae51SMonica KenguvaExample commands
5497a71ae51SMonica Kenguva
5507a71ae51SMonica Kenguva`rpc.py bdev_raid_create -n Raid0 -z 64 -r 0 -b "lvol0 lvol1 lvol2 lvol3"`
5517a71ae51SMonica Kenguva
5527a71ae51SMonica Kenguva`rpc.py bdev_raid_get_bdevs`
5537a71ae51SMonica Kenguva
5547a71ae51SMonica Kenguva`rpc.py bdev_raid_delete Raid0`
5557a71ae51SMonica Kenguva
5561e1fd9acSwawryk## Split {#bdev_ug_split}
557e25747e5SMonica Kenguva
558e25747e5SMonica KenguvaThe split block device module takes an underlying block device and splits it into
559e25747e5SMonica Kenguvaseveral smaller equal-sized virtual block devices. This serves as an example to create
560e25747e5SMonica Kenguvamore vbdevs on a given base bdev for user testing.
561e25747e5SMonica Kenguva
562e25747e5SMonica KenguvaExample commands
563e25747e5SMonica Kenguva
564e25747e5SMonica KenguvaTo create four split bdevs with base bdev_b0 use the `bdev_split_create` command.
565e25747e5SMonica KenguvaEach split bdev will be one fourth the size of the base bdev.
566e25747e5SMonica Kenguva
567e25747e5SMonica Kenguva`rpc.py bdev_split_create bdev_b0 4`
568e25747e5SMonica Kenguva
569e25747e5SMonica KenguvaThe `split_size_mb`(-s) parameter restricts the size of each split bdev.
570e25747e5SMonica KenguvaThe total size of all split bdevs must not exceed the base bdev size.
571e25747e5SMonica Kenguva
572e25747e5SMonica Kenguva`rpc.py bdev_split_create bdev_b0 4 -s 128`
573e25747e5SMonica Kenguva
574e25747e5SMonica KenguvaTo remove the split bdevs, use the `bdev_split_delete` command with the base bdev name.
575e25747e5SMonica Kenguva
576e25747e5SMonica Kenguva`rpc.py bdev_split_delete bdev_b0`
577e25747e5SMonica Kenguva
5781e1fd9acSwawryk## Uring {#bdev_ug_uring}
579685f31d6SMonica Kenguva
580685f31d6SMonica KenguvaThe uring bdev module issues I/O to kernel block devices using the io_uring Linux kernel API. This module requires liburing.
581685f31d6SMonica KenguvaFor more information on io_uring refer to kernel [IO_uring] (https://kernel.dk/io_uring.pdf)
582685f31d6SMonica Kenguva
583685f31d6SMonica KenguvaThe user needs to configure SPDK to include io_uring support:
584685f31d6SMonica Kenguva
585685f31d6SMonica Kenguva`configure --with-uring`
586685f31d6SMonica Kenguva
587958d196cSIndraneel MSupport for zoned devices is enabled by default in uring bdev. It can be explicitly disabled as follows:
5888b840195SIndraneel M
589958d196cSIndraneel M`configure --with-uring --without-uring-zns`
5908b840195SIndraneel M
591685f31d6SMonica KenguvaTo create a uring bdev with given filename, bdev name and block size use the `bdev_uring_create` RPC.
592685f31d6SMonica Kenguva
593685f31d6SMonica Kenguva`rpc.py  bdev_uring_create /path/to/device bdev_u0 512`
594685f31d6SMonica Kenguva
595685f31d6SMonica KenguvaTo remove a uring bdev use the `bdev_uring_delete` RPC.
596685f31d6SMonica Kenguva
597685f31d6SMonica Kenguva`rpc.py bdev_uring_delete bdev_u0`
598685f31d6SMonica Kenguva
599076ae917SKarl Bonde Torp## xNVMe {#bdev_ug_xnvme}
6006f338d4bSKrishna Kanth Reddy
601076ae917SKarl Bonde TorpThe xNVMe bdev module issues I/O to the underlying NVMe devices through various I/O mechanisms
6026f338d4bSKrishna Kanth Reddysuch as libaio, io_uring, Asynchronous IOCTL using io_uring passthrough, POSIX aio, emulated aio etc.
6036f338d4bSKrishna Kanth Reddy
604076ae917SKarl Bonde TorpThis module requires the xNVMe library.
605076ae917SKarl Bonde TorpFor more information on xNVMe refer to [xNVMe] (https://xnvme.io)
6066f338d4bSKrishna Kanth Reddy
6076f338d4bSKrishna Kanth ReddyThe user needs to configure SPDK to include xNVMe support:
6086f338d4bSKrishna Kanth Reddy
6096f338d4bSKrishna Kanth Reddy`configure --with-xnvme`
6106f338d4bSKrishna Kanth Reddy
611076ae917SKarl Bonde TorpTo create a xNVMe bdev with given filename, bdev name and I/O mechanism use the `bdev_xnvme_create` RPC.
6126f338d4bSKrishna Kanth Reddy
6136f338d4bSKrishna Kanth Reddy`rpc.py  bdev_xnvme_create /dev/ng0n1 bdev_ng0n1 io_uring_cmd`
6146f338d4bSKrishna Kanth Reddy
615076ae917SKarl Bonde TorpThe most important I/O mechanisms are:
616076ae917SKarl Bonde Torp
617076ae917SKarl Bonde Torp- "libaio"
618076ae917SKarl Bonde Torp- "io_uring"
619076ae917SKarl Bonde Torp- "io_uring_cmd" (requires linux kernel v5.19 or newer)
620076ae917SKarl Bonde Torp
6216f338d4bSKrishna Kanth ReddyTo remove a xnvme bdev use the `bdev_xnvme_delete` RPC.
6226f338d4bSKrishna Kanth Reddy
6236f338d4bSKrishna Kanth Reddy`rpc.py bdev_xnvme_delete bdev_ng0n1`
6246f338d4bSKrishna Kanth Reddy
6251e1fd9acSwawryk## Virtio Block {#bdev_config_virtio_blk}
626cd270e54Spaul luse
627f3096dacSDarek StojaczykThe Virtio-Block driver allows creating SPDK bdevs from Virtio-Block devices.
628cd270e54Spaul luse
629f3096dacSDarek StojaczykThe following command creates a Virtio-Block device named `VirtioBlk0` from a vhost-user
630f3096dacSDarek Stojaczyksocket `/tmp/vhost.0` exposed directly by SPDK @ref vhost. Optional `vq-count` and
631f3096dacSDarek Stojaczyk`vq-size` params specify number of request queues and queue depth to be used.
632cd270e54Spaul luse
6332aed03f0SMaciej Wawryk`rpc.py bdev_virtio_attach_controller --dev-type blk --trtype user --traddr /tmp/vhost.0 --vq-count 2 --vq-size 512 VirtioBlk0`
634cd270e54Spaul luse
635f3096dacSDarek StojaczykThe driver can be also used inside QEMU-based VMs. The following command creates a Virtio
636f3096dacSDarek StojaczykBlock device named `VirtioBlk0` from a Virtio PCI device at address `0000:00:01.0`.
637f3096dacSDarek StojaczykThe entire configuration will be read automatically from PCI Configuration Space. It will
638f3096dacSDarek Stojaczykreflect all parameters passed to QEMU's vhost-user-scsi-pci device.
639cd270e54Spaul luse
6402aed03f0SMaciej Wawryk`rpc.py bdev_virtio_attach_controller --dev-type blk --trtype pci --traddr 0000:01:00.0 VirtioBlk1`
641f3096dacSDarek Stojaczyk
642f3096dacSDarek StojaczykVirtio-Block devices can be removed with the following command
643cd270e54Spaul luse
644c1b87b3dSMaciej Wawryk`rpc.py bdev_virtio_detach_controller VirtioBlk0`
645cd270e54Spaul luse
6461e1fd9acSwawryk## Virtio SCSI {#bdev_config_virtio_scsi}
6470124a07dSMaciej Szwed
648c769e03fSDariusz StojaczykThe Virtio-SCSI driver allows creating SPDK block devices from Virtio-SCSI LUNs.
6490124a07dSMaciej Szwed
6502aed03f0SMaciej WawrykVirtio-SCSI bdevs are created the same way as Virtio-Block ones.
6510124a07dSMaciej Szwed
6522aed03f0SMaciej Wawryk`rpc.py bdev_virtio_attach_controller --dev-type scsi --trtype user --traddr /tmp/vhost.0 --vq-count 2 --vq-size 512 VirtioScsi0`
6530124a07dSMaciej Szwed
6542aed03f0SMaciej Wawryk`rpc.py bdev_virtio_attach_controller --dev-type scsi --trtype pci --traddr 0000:01:00.0 VirtioScsi0`
6550124a07dSMaciej Szwed
656c769e03fSDariusz StojaczykEach Virtio-SCSI device may export up to 64 block devices named VirtioScsi0t0 ~ VirtioScsi0t63,
657c769e03fSDariusz Stojaczykone LUN (LUN0) per SCSI device. The above 2 commands will output names of all exposed bdevs.
6580124a07dSMaciej Szwed
6590124a07dSMaciej SzwedVirtio-SCSI devices can be removed with the following command
6600124a07dSMaciej Szwed
661c1b87b3dSMaciej Wawryk`rpc.py bdev_virtio_detach_controller VirtioScsi0`
6620124a07dSMaciej Szwed
6630124a07dSMaciej SzwedRemoving a Virtio-SCSI device will destroy all its bdevs.
6642e283fcbS0xe0f
6652e283fcbS0xe0f## DAOS bdev {#bdev_config_daos}
6662e283fcbS0xe0f
6672e283fcbS0xe0fDAOS bdev creates SPDK block device on top of DAOS DFS, the name of the bdev defines the file name in DFS namespace.
6682e283fcbS0xe0fNote that DAOS container has to be POSIX type, e.g.: ` daos cont create --pool=test-pool --label=test-cont --type=POSIX`
6692e283fcbS0xe0f
6702e283fcbS0xe0fTo build SPDK with daos support, daos-devel package has to be installed, please see the setup [guide](https://docs.daos.io/v2.0/).
6712e283fcbS0xe0fTo enable the module, configure SPDK using `--with-daos` flag.
6722e283fcbS0xe0f
6732e283fcbS0xe0fRunning `daos_agent` service on the target machine is required for the SPDK DAOS bdev communication with a DAOS cluster.
6742e283fcbS0xe0f
6752e283fcbS0xe0fThe implementation uses the independent pool and container connections per device's channel for the best IO throughput, therefore,
6762e283fcbS0xe0frunning a target application with multiple cores (`-m [0-7], for example) is highly advisable.
6772e283fcbS0xe0f
6782e283fcbS0xe0fExample command for creating daos bdev:
6792e283fcbS0xe0f
6802e283fcbS0xe0f`rpc.py bdev_daos_create daosdev0 test-pool test-cont 64 4096`
6812e283fcbS0xe0f
6822e283fcbS0xe0fExample command for removing daos bdev:
6832e283fcbS0xe0f
6842e283fcbS0xe0f`rpc.py bdev_daos_delete daosdev0`
685bdc683aaSDenis Barakhtanov
686bdc683aaSDenis BarakhtanovTo resize a bdev use the bdev_daos_resize command.
687bdc683aaSDenis Barakhtanov
688bdc683aaSDenis Barakhtanov`rpc.py bdev_daos_resize daosdev0 8192`
689bdc683aaSDenis Barakhtanov
690bdc683aaSDenis BarakhtanovThis command will resize the daosdev0 bdev to 8192 MiB.
691