xref: /spdk/python/spdk/rpc/bdev.py (revision 25a9ccb9892e398116f4168fc7eb2ae321650b11)
1#  SPDX-License-Identifier: BSD-3-Clause
2#  Copyright (C) 2017 Intel Corporation.
3#  All rights reserved.
4#  Copyright (c) 2022 Dell Inc, or its subsidiaries.
5#  Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
6
7
8def bdev_set_options(client, bdev_io_pool_size=None, bdev_io_cache_size=None,
9                     bdev_auto_examine=None, iobuf_small_cache_size=None,
10                     iobuf_large_cache_size=None):
11    """Set parameters for the bdev subsystem.
12    Args:
13        bdev_io_pool_size: number of bdev_io structures in shared buffer pool (optional)
14        bdev_io_cache_size: maximum number of bdev_io structures cached per thread (optional)
15        bdev_auto_examine: if set to false, the bdev layer will not examine every disks automatically (optional)
16        iobuf_small_cache_size: size of the small iobuf per thread cache
17        iobuf_large_cache_size: size of the large iobuf per thread cache
18    """
19    params = dict()
20    if bdev_io_pool_size is not None:
21        params['bdev_io_pool_size'] = bdev_io_pool_size
22    if bdev_io_cache_size is not None:
23        params['bdev_io_cache_size'] = bdev_io_cache_size
24    if bdev_auto_examine is not None:
25        params['bdev_auto_examine'] = bdev_auto_examine
26    if iobuf_small_cache_size is not None:
27        params['iobuf_small_cache_size'] = iobuf_small_cache_size
28    if iobuf_large_cache_size is not None:
29        params['iobuf_large_cache_size'] = iobuf_large_cache_size
30    return client.call('bdev_set_options', params)
31
32
33def bdev_examine(client, name):
34    """Examine a bdev manually. If the bdev does not exist yet when this RPC is called,
35    it will be examined when it is created
36    Args:
37        name: name of the bdev
38    """
39    params = dict()
40    params['name'] = name
41    return client.call('bdev_examine', params)
42
43
44def bdev_wait_for_examine(client):
45    """Report when all bdevs have been examined
46    """
47    return client.call('bdev_wait_for_examine')
48
49
50def bdev_compress_create(client, base_bdev_name, pm_path, lb_size=None):
51    """Construct a compress virtual block device.
52    Args:
53        base_bdev_name: name of the underlying base bdev
54        pm_path: path to persistent memory
55        lb_size: logical block size for the compressed vol in bytes.  Must be 4K or 512.
56    Returns:
57        Name of created virtual block device.
58    """
59    params = dict()
60    params['base_bdev_name'] = base_bdev_name
61    params['pm_path'] = pm_path
62    if lb_size is not None:
63        params['lb_size'] = lb_size
64    return client.call('bdev_compress_create', params)
65
66
67def bdev_compress_delete(client, name):
68    """Delete compress virtual block device.
69    Args:
70        name: name of compress vbdev to delete
71    """
72    params = dict()
73    params['name'] = name
74    return client.call('bdev_compress_delete', params)
75
76
77def bdev_compress_get_orphans(client, name=None):
78    """Get a list of comp bdevs that do not have a pmem file (aka orphaned).
79    Args:
80        name: comp bdev name to query (optional; if omitted, query all comp bdevs)
81    Returns:
82        List of comp bdev names.
83    """
84    params = dict()
85    if name is not None:
86        params['name'] = name
87    return client.call('bdev_compress_get_orphans', params)
88
89
90def bdev_crypto_create(client, base_bdev_name, name, crypto_pmd=None, key=None, cipher=None, key2=None, key_name=None):
91    """Construct a crypto virtual block device.
92    Args:
93        base_bdev_name: name of the underlying base bdev
94        name: name for the crypto vbdev
95        crypto_pmd: name of the DPDK crypto driver to use
96        key: key
97        cipher: crypto algorithm to use
98        key2: Optional second part of the key
99        key_name: The key name to use in crypto operations
100    Returns:
101        Name of created virtual block device.
102    """
103    params = dict()
104    params['base_bdev_name'] = base_bdev_name
105    params['name'] = name
106    if crypto_pmd is not None:
107        params['crypto_pmd'] = crypto_pmd
108    if key is not None:
109        params['key'] = key
110    if cipher is not None:
111        params['cipher'] = cipher
112    if key2 is not None:
113        params['key2'] = key2
114    if key_name is not None:
115        params['key_name'] = key_name
116    return client.call('bdev_crypto_create', params)
117
118
119def bdev_crypto_delete(client, name):
120    """Delete crypto virtual block device.
121    Args:
122        name: name of crypto vbdev to delete
123    """
124    params = dict()
125    params['name'] = name
126    return client.call('bdev_crypto_delete', params)
127
128
129def bdev_ocf_create(client, name, mode, cache_bdev_name, core_bdev_name, cache_line_size=None):
130    """Add an OCF block device
131    Args:
132        name: name of constructed OCF bdev
133        mode: OCF cache mode: {'wb', 'wt', 'pt', 'wa', 'wi', 'wo'}
134        cache_bdev_name: name of underlying cache bdev
135        core_bdev_name: name of underlying core bdev
136        cache_line_size: OCF cache line size. The unit is KiB: {4, 8, 16, 32, 64}
137    Returns:
138        Name of created block device
139    """
140    params = dict()
141    params['name'] = name
142    params['mode'] = mode
143    params['cache_bdev_name'] = cache_bdev_name
144    params['core_bdev_name'] = core_bdev_name
145    if cache_line_size is not None:
146        params['cache_line_size'] = cache_line_size
147    return client.call('bdev_ocf_create', params)
148
149
150def bdev_ocf_delete(client, name):
151    """Delete an OCF device
152    Args:
153        name: name of OCF bdev
154    """
155    params = dict()
156    params['name'] = name
157    return client.call('bdev_ocf_delete', params)
158
159
160def bdev_ocf_get_stats(client, name):
161    """Get statistics of chosen OCF block device
162    Args:
163        name: name of OCF bdev
164    Returns:
165        Statistics as json object
166    """
167    params = dict()
168    params['name'] = name
169    return client.call('bdev_ocf_get_stats', params)
170
171
172def bdev_ocf_reset_stats(client, name):
173    """Reset statistics of chosen OCF block device
174    Args:
175        name: name of OCF bdev
176    Returns:
177        None
178    """
179    params = dict()
180    params['name'] = name
181    return client.call('bdev_ocf_reset_stats', params)
182
183
184def bdev_ocf_get_bdevs(client, name=None):
185    """Get list of OCF devices including unregistered ones
186    Args:
187        name: name of OCF vbdev or name of cache device or name of core device (optional)
188    Returns:
189        Array of OCF devices with their current status
190    """
191    params = dict()
192    if name is not None:
193        params['name'] = name
194    return client.call('bdev_ocf_get_bdevs', params)
195
196
197def bdev_ocf_set_cache_mode(client, name, mode):
198    """Set cache mode of OCF block device
199    Args:
200        name: name of OCF bdev
201        mode: OCF cache mode: {'wb', 'wt', 'pt', 'wa', 'wi', 'wo'}
202    Returns:
203        New cache mode name
204    """
205    params = dict()
206    params['name'] = name
207    params['mode'] = mode
208    return client.call('bdev_ocf_set_cache_mode', params)
209
210
211def bdev_ocf_set_seqcutoff(client, name, policy, threshold=None, promotion_count=None):
212    """Set sequential cutoff parameters on all cores for the given OCF cache device
213    Args:
214        name: Name of OCF cache bdev
215        policy: Sequential cutoff policy
216        threshold: Activation threshold [KiB] (optional)
217        promotion_count: Promotion request count (optional)
218    """
219    params = dict()
220    params['name'] = name
221    params['policy'] = policy
222    if threshold is not None:
223        params['threshold'] = threshold
224    if promotion_count is not None:
225        params['promotion_count'] = promotion_count
226    return client.call('bdev_ocf_set_seqcutoff', params)
227
228
229def bdev_ocf_flush_start(client, name):
230    """Start flushing OCF cache device
231    Args:
232        name: name of OCF bdev
233    """
234    params = dict()
235    params['name'] = name
236    return client.call('bdev_ocf_flush_start', params)
237
238
239def bdev_ocf_flush_status(client, name):
240    """Get flush status of OCF cache device
241    Args:
242        name: name of OCF bdev
243    Returns:
244        Flush status
245    """
246    params = dict()
247    params['name'] = name
248    return client.call('bdev_ocf_flush_status', params)
249
250
251def bdev_malloc_create(client, num_blocks, block_size, physical_block_size=None, name=None, uuid=None, optimal_io_boundary=None,
252                       md_size=None, md_interleave=None, dif_type=None, dif_is_head_of_md=None, dif_pi_format=None):
253    """Construct a malloc block device.
254    Args:
255        num_blocks: size of block device in blocks
256        block_size: Data block size of device; must be a power of 2 and at least 512
257        physical_block_size: Physical block size of device; must be a power of 2 and at least 512 (optional)
258        name: name of block device (optional)
259        uuid: UUID of block device (optional)
260        optimal_io_boundary: Split on optimal IO boundary, in number of blocks, default 0 (disabled, optional)
261        md_size: metadata size of device (0, 8, 16, 32, 64, or 128), default 0 (optional)
262        md_interleave: metadata location, interleaved if set, and separated if omitted (optional)
263        dif_type: protection information type (optional)
264        dif_is_head_of_md: protection information is in the first 8 bytes of metadata (optional)
265        dif_pi_format: protection information format (optional)
266    Returns:
267        Name of created block device.
268    """
269    params = dict()
270    params['num_blocks'] = num_blocks
271    params['block_size'] = block_size
272    if physical_block_size is not None:
273        params['physical_block_size'] = physical_block_size
274    if name is not None:
275        params['name'] = name
276    if uuid is not None:
277        params['uuid'] = uuid
278    if optimal_io_boundary is not None:
279        params['optimal_io_boundary'] = optimal_io_boundary
280    if md_size is not None:
281        params['md_size'] = md_size
282    if md_interleave is not None:
283        params['md_interleave'] = md_interleave
284    if dif_type is not None:
285        params['dif_type'] = dif_type
286    if dif_is_head_of_md is not None:
287        params['dif_is_head_of_md'] = dif_is_head_of_md
288    if dif_pi_format is not None:
289        params['dif_pi_format'] = dif_pi_format
290    return client.call('bdev_malloc_create', params)
291
292
293def bdev_malloc_delete(client, name):
294    """Delete malloc block device.
295    Args:
296        bdev_name: name of malloc bdev to delete
297    """
298    params = dict()
299    params['name'] = name
300    return client.call('bdev_malloc_delete', params)
301
302
303def bdev_null_create(client, num_blocks, block_size, name, physical_block_size=None, uuid=None, md_size=None,
304                     dif_type=None, dif_is_head_of_md=None, dif_pi_format=None):
305    """Construct a null block device.
306    Args:
307        num_blocks: size of block device in blocks
308        block_size: block size of device; data part size must be a power of 2 and at least 512
309        name: name of block device
310        physical_block_size: physical block size of the device; data part size must be a power of 2 and at least 512 (optional)
311        uuid: UUID of block device (optional)
312        md_size: metadata size of device (optional)
313        dif_type: protection information type (optional)
314        dif_is_head_of_md: protection information is in the first 8 bytes of metadata (optional)
315        dif_pi_format: protection information format (optional)
316    Returns:
317        Name of created block device.
318    """
319    params = dict()
320    params['num_blocks'] = num_blocks
321    params['block_size'] = block_size
322    params['name'] = name
323    if physical_block_size is not None:
324        params['physical_block_size'] = physical_block_size
325    if uuid is not None:
326        params['uuid'] = uuid
327    if md_size is not None:
328        params['md_size'] = md_size
329    if dif_type is not None:
330        params['dif_type'] = dif_type
331    if dif_is_head_of_md is not None:
332        params['dif_is_head_of_md'] = dif_is_head_of_md
333    if dif_pi_format is not None:
334        params['dif_pi_format'] = dif_pi_format
335    return client.call('bdev_null_create', params)
336
337
338def bdev_null_delete(client, name):
339    """Remove null bdev from the system.
340    Args:
341        name: name of null bdev to delete
342    """
343    params = dict()
344    params['name'] = name
345    return client.call('bdev_null_delete', params)
346
347
348def bdev_null_resize(client, name, new_size):
349    """Resize null bdev in the system.
350    Args:
351        name: name of null bdev to resize
352        new_size: new bdev size of resize operation. The unit is MiB
353    """
354    params = dict()
355    params['name'] = name
356    params['new_size'] = new_size
357    return client.call('bdev_null_resize', params)
358
359
360def bdev_raid_set_options(client, process_window_size_kb=None, process_max_bandwidth_mb_sec=None):
361    """Set options for bdev raid.
362    Args:
363        process_window_size_kb: Background process (e.g. rebuild) window size in KiB
364        process_max_bandwidth_mb_sec: Background process (e.g. rebuild) maximum bandwidth in MiB/Sec
365    """
366    params = dict()
367    if process_window_size_kb is not None:
368        params['process_window_size_kb'] = process_window_size_kb
369
370    if process_max_bandwidth_mb_sec is not None:
371        params['process_max_bandwidth_mb_sec'] = process_max_bandwidth_mb_sec
372
373    return client.call('bdev_raid_set_options', params)
374
375
376def bdev_raid_get_bdevs(client, category):
377    """Get list of raid bdevs based on category
378    Args:
379        category: any one of all or online or configuring or offline
380    Returns:
381        List of raid bdev details
382    """
383    params = dict()
384    params['category'] = category
385    return client.call('bdev_raid_get_bdevs', params)
386
387
388def bdev_raid_create(client, name, raid_level, base_bdevs, strip_size_kb=None, uuid=None, superblock=None):
389    """Create raid bdev. Either strip size arg will work but one is required.
390    Args:
391        name: user defined raid bdev name
392        raid_level: raid level of raid bdev, supported values 0
393        base_bdevs: Space separated names of Nvme bdevs in double quotes, like "Nvme0n1 Nvme1n1 Nvme2n1"
394        strip_size_kb: strip size of raid bdev in KB, supported values like 8, 16, 32, 64, 128, 256, etc
395        uuid: UUID for this raid bdev (optional)
396        superblock: information about raid bdev will be stored in superblock on each base bdev,
397                    disabled by default due to backward compatibility
398    Returns:
399        None
400    """
401    params = dict()
402    params['name'] = name
403    params['raid_level'] = raid_level
404    params['base_bdevs'] = base_bdevs
405    if strip_size_kb is not None:
406        params['strip_size_kb'] = strip_size_kb
407    if uuid is not None:
408        params['uuid'] = uuid
409    if superblock is not None:
410        params['superblock'] = superblock
411    return client.call('bdev_raid_create', params)
412
413
414def bdev_raid_delete(client, name):
415    """Delete raid bdev
416    Args:
417        name: raid bdev name
418    Returns:
419        None
420    """
421    params = dict()
422    params['name'] = name
423    return client.call('bdev_raid_delete', params)
424
425
426def bdev_raid_add_base_bdev(client, base_bdev, raid_bdev):
427    """Add base bdev to existing raid bdev
428    Args:
429        base_bdev: base bdev name
430        raid_bdev: raid bdev name
431    Returns:
432        None
433    """
434    params = dict()
435    params['base_bdev'] = base_bdev
436    params['raid_bdev'] = raid_bdev
437    return client.call('bdev_raid_add_base_bdev', params)
438
439
440def bdev_raid_remove_base_bdev(client, name):
441    """Remove base bdev from existing raid bdev
442    Args:
443        name: base bdev name
444    Returns:
445        None
446    """
447    params = dict()
448    params['name'] = name
449    return client.call('bdev_raid_remove_base_bdev', params)
450
451
452def bdev_aio_create(client, filename, name, block_size=None, readonly=None, fallocate=None):
453    """Construct a Linux AIO block device.
454    Args:
455        filename: path to device or file (ex: /dev/sda)
456        name: name of block device
457        block_size: block size of device (optional; autodetected if omitted)
458        readonly: set aio bdev as read-only
459        fallocate: enable fallocate for UNMAP/WRITEZEROS support (note that fallocate syscall would block reactor)
460    Returns:
461        Name of created block device.
462    """
463    params = dict()
464    params['filename'] = filename
465    params['name'] = name
466    if block_size is not None:
467        params['block_size'] = block_size
468    if readonly is not None:
469        params['readonly'] = readonly
470    if fallocate is not None:
471        params['fallocate'] = fallocate
472    return client.call('bdev_aio_create', params)
473
474
475def bdev_aio_rescan(client, name):
476    """Rescan a Linux AIO block device.
477    Args:
478        name: name of aio bdev to rescan
479    """
480    params = dict()
481    params['name'] = name
482    return client.call('bdev_aio_rescan', params)
483
484
485def bdev_aio_delete(client, name):
486    """Remove aio bdev from the system.
487    Args:
488        name: name of aio bdev to delete
489    """
490    params = dict()
491    params['name'] = name
492    return client.call('bdev_aio_delete', params)
493
494
495def bdev_uring_create(client, filename, name, block_size=None, uuid=None):
496    """Create a bdev with Linux io_uring backend.
497    Args:
498        filename: path to device or file (ex: /dev/nvme0n1)
499        name: name of bdev
500        block_size: block size of device (optional; autodetected if omitted)
501        uuid: UUID of block device (optional)
502    Returns:
503        Name of created bdev.
504    """
505    params = dict()
506    params['filename'] = filename
507    params['name'] = name
508    if block_size is not None:
509        params['block_size'] = block_size
510    if uuid is not None:
511        params['uuid'] = uuid
512    return client.call('bdev_uring_create', params)
513
514
515def bdev_uring_rescan(client, name):
516    """Rescan a Linux URING block device.
517    Args:
518        name: name of uring bdev to rescan
519    """
520    params = dict()
521    params['name'] = name
522    return client.call('bdev_uring_rescan', params)
523
524
525def bdev_uring_delete(client, name):
526    """Delete a uring bdev.
527    Args:
528        name: name of uring bdev to delete
529    """
530    params = dict()
531    params['name'] = name
532    return client.call('bdev_uring_delete', params)
533
534
535def bdev_xnvme_create(client, filename, name, io_mechanism, conserve_cpu=None):
536    """Create a bdev with xNVMe backend.
537    Args:
538        filename: path to device or file (ex: /dev/nvme0n1)
539        name: name of xNVMe bdev to create
540        io_mechanism: I/O mechanism to use (ex: io_uring, io_uring_cmd, etc.)
541        conserve_cpu: Whether or not to conserve CPU when polling (default: False)
542    Returns:
543        Name of created bdev.
544    """
545    params = dict()
546    params['filename'] = filename
547    params['name'] = name
548    params['io_mechanism'] = io_mechanism
549    if conserve_cpu is not None:
550        params['conserve_cpu'] = conserve_cpu
551    return client.call('bdev_xnvme_create', params)
552
553
554def bdev_xnvme_delete(client, name):
555    """Delete a xNVMe bdev.
556    Args:
557        name: name of xNVMe bdev to delete
558    """
559    params = dict()
560    params['name'] = name
561    return client.call('bdev_xnvme_delete', params)
562
563
564def bdev_nvme_set_options(client, action_on_timeout=None, timeout_us=None, timeout_admin_us=None,
565                          keep_alive_timeout_ms=None, arbitration_burst=None,
566                          low_priority_weight=None, medium_priority_weight=None, high_priority_weight=None,
567                          nvme_adminq_poll_period_us=None, nvme_ioq_poll_period_us=None, io_queue_requests=None,
568                          delay_cmd_submit=None, transport_retry_count=None, bdev_retry_count=None,
569                          transport_ack_timeout=None, ctrlr_loss_timeout_sec=None, reconnect_delay_sec=None,
570                          fast_io_fail_timeout_sec=None, disable_auto_failback=None, generate_uuids=None,
571                          transport_tos=None, nvme_error_stat=None, rdma_srq_size=None, io_path_stat=None,
572                          allow_accel_sequence=None, rdma_max_cq_size=None, rdma_cm_event_timeout_ms=None,
573                          dhchap_digests=None, dhchap_dhgroups=None):
574    """Set options for the bdev nvme. This is startup command.
575    Args:
576        action_on_timeout:  action to take on command time out. Valid values are: none, reset, abort (optional)
577        timeout_us: Timeout for each command, in microseconds. If 0, don't track timeouts (optional)
578        timeout_admin_us: Timeout for each admin command, in microseconds. If 0, treat same as io timeouts (optional)
579        keep_alive_timeout_ms: Keep alive timeout period in millisecond, default is 10s (optional)
580        arbitration_burst: The value is expressed as a power of two (optional)
581        low_priority_weight: The number of commands that may be executed from the low priority queue at one time (optional)
582        medium_priority_weight: The number of commands that may be executed from the medium priority queue at one time (optional)
583        high_priority_weight: The number of commands that may be executed from the high priority queue at one time (optional)
584        nvme_adminq_poll_period_us: How often the admin queue is polled for asynchronous events in microseconds (optional)
585        nvme_ioq_poll_period_us: How often to poll I/O queues for completions in microseconds (optional)
586        io_queue_requests: The number of requests allocated for each NVMe I/O queue. Default: 512 (optional)
587        delay_cmd_submit: Enable delayed NVMe command submission to allow batching of multiple commands (optional)
588        transport_retry_count: The number of attempts per I/O in the transport layer when an I/O fails (optional)
589        bdev_retry_count: The number of attempts per I/O in the bdev layer when an I/O fails. -1 means infinite retries. (optional)
590        transport_ack_timeout: Time to wait ack until packet retransmission for RDMA or until closes connection for TCP.
591        Range 0-31 where 0 is driver-specific default value (optional)
592        ctrlr_loss_timeout_sec: Time to wait until ctrlr is reconnected before deleting ctrlr.
593        -1 means infinite reconnect retries. 0 means no reconnect retry.
594        If reconnect_delay_sec is zero, ctrlr_loss_timeout_sec has to be zero.
595        If reconnect_delay_sec is non-zero, ctrlr_loss_timeout_sec has to be -1 or not less than reconnect_delay_sec.
596        This can be overridden by bdev_nvme_attach_controller. (optional)
597        reconnect_delay_sec: Time to delay a reconnect retry.
598        If ctrlr_loss_timeout_sec is zero, reconnect_delay_sec has to be zero.
599        If ctrlr_loss_timeout_sec is -1, reconnect_delay_sec has to be non-zero.
600        If ctrlr_loss_timeout_sec is not -1 or zero, reconnect_sec has to be non-zero and less than ctrlr_loss_timeout_sec.
601        This can be overridden by bdev_nvme_attach_controller. (optional)
602        fast_io_fail_timeout_sec: Time to wait until ctrlr is reconnected before failing I/O to ctrlr.
603        0 means no such timeout.
604        If fast_io_fail_timeout_sec is not zero, it has to be not less than reconnect_delay_sec and less than
605        ctrlr_loss_timeout_sec if ctrlr_loss_timeout_sec is not -1.
606        This can be overridden by bdev_nvme_attach_controller. (optional)
607        disable_auto_failback: Disable automatic failback. bdev_nvme_set_preferred_path can be used to do manual failback.
608        By default, immediately failback to the preferred I/O path if it is restored. (optional)
609        generate_uuids: Enable generation of unique identifiers for NVMe bdevs only if they do not provide UUID themselves.
610        These strings are based on device serial number and namespace ID and will always be the same for that device.
611        transport_tos: IPv4 Type of Service value. Only applicable for RDMA transports.
612        The default is 0 which means no TOS is applied. (optional)
613        nvme_error_stat: Enable collecting NVMe error counts. (optional)
614        rdma_srq_size: Set the size of a shared rdma receive queue. Default: 0 (disabled) (optional)
615        io_path_stat: Enable collection I/O path stat of each io path. (optional)
616        allow_accel_sequence: Allow NVMe bdevs to advertise support for accel sequences if the
617        controller also supports them. (optional)
618        rdma_max_cq_size: The maximum size of a rdma completion queue. Default: 0 (unlimited) (optional)
619        rdma_cm_event_timeout_ms: Time to wait for RDMA CM event. Only applicable for RDMA transports.
620        dhchap_digests: List of allowed DH-HMAC-CHAP digests. (optional)
621        dhchap_dhgroups: List of allowed DH-HMAC-CHAP DH groups. (optional)
622    """
623    params = dict()
624    if action_on_timeout is not None:
625        params['action_on_timeout'] = action_on_timeout
626    if timeout_us is not None:
627        params['timeout_us'] = timeout_us
628    if timeout_admin_us is not None:
629        params['timeout_admin_us'] = timeout_admin_us
630    if keep_alive_timeout_ms is not None:
631        params['keep_alive_timeout_ms'] = keep_alive_timeout_ms
632    if arbitration_burst is not None:
633        params['arbitration_burst'] = arbitration_burst
634    if low_priority_weight is not None:
635        params['low_priority_weight'] = low_priority_weight
636    if medium_priority_weight is not None:
637        params['medium_priority_weight'] = medium_priority_weight
638    if high_priority_weight is not None:
639        params['high_priority_weight'] = high_priority_weight
640    if nvme_adminq_poll_period_us is not None:
641        params['nvme_adminq_poll_period_us'] = nvme_adminq_poll_period_us
642    if nvme_ioq_poll_period_us is not None:
643        params['nvme_ioq_poll_period_us'] = nvme_ioq_poll_period_us
644    if io_queue_requests is not None:
645        params['io_queue_requests'] = io_queue_requests
646    if delay_cmd_submit is not None:
647        params['delay_cmd_submit'] = delay_cmd_submit
648    if transport_retry_count is not None:
649        params['transport_retry_count'] = transport_retry_count
650    if bdev_retry_count is not None:
651        params['bdev_retry_count'] = bdev_retry_count
652    if transport_ack_timeout is not None:
653        params['transport_ack_timeout'] = transport_ack_timeout
654    if ctrlr_loss_timeout_sec is not None:
655        params['ctrlr_loss_timeout_sec'] = ctrlr_loss_timeout_sec
656    if reconnect_delay_sec is not None:
657        params['reconnect_delay_sec'] = reconnect_delay_sec
658    if fast_io_fail_timeout_sec is not None:
659        params['fast_io_fail_timeout_sec'] = fast_io_fail_timeout_sec
660    if disable_auto_failback is not None:
661        params['disable_auto_failback'] = disable_auto_failback
662    if generate_uuids is not None:
663        params['generate_uuids'] = generate_uuids
664    if transport_tos is not None:
665        params['transport_tos'] = transport_tos
666    if nvme_error_stat is not None:
667        params['nvme_error_stat'] = nvme_error_stat
668    if rdma_srq_size is not None:
669        params['rdma_srq_size'] = rdma_srq_size
670    if io_path_stat is not None:
671        params['io_path_stat'] = io_path_stat
672    if allow_accel_sequence is not None:
673        params['allow_accel_sequence'] = allow_accel_sequence
674    if rdma_max_cq_size is not None:
675        params['rdma_max_cq_size'] = rdma_max_cq_size
676    if rdma_cm_event_timeout_ms is not None:
677        params['rdma_cm_event_timeout_ms'] = rdma_cm_event_timeout_ms
678    if dhchap_digests is not None:
679        params['dhchap_digests'] = dhchap_digests
680    if dhchap_dhgroups is not None:
681        params['dhchap_dhgroups'] = dhchap_dhgroups
682    return client.call('bdev_nvme_set_options', params)
683
684
685def bdev_nvme_set_hotplug(client, enable, period_us=None):
686    """Set options for the bdev nvme. This is startup command.
687    Args:
688       enable: True to enable hotplug, False to disable.
689       period_us: how often the hotplug is processed for insert and remove events. Set 0 to reset to default. (optional)
690    """
691    params = dict()
692    params['enable'] = enable
693    if period_us is not None:
694        params['period_us'] = period_us
695    return client.call('bdev_nvme_set_hotplug', params)
696
697
698def bdev_nvme_attach_controller(client, name, trtype, traddr, adrfam=None, trsvcid=None,
699                                priority=None, subnqn=None, hostnqn=None, hostaddr=None,
700                                hostsvcid=None, prchk_reftag=None, prchk_guard=None,
701                                hdgst=None, ddgst=None, fabrics_connect_timeout_us=None,
702                                multipath=None, num_io_queues=None, ctrlr_loss_timeout_sec=None,
703                                reconnect_delay_sec=None, fast_io_fail_timeout_sec=None,
704                                psk=None, max_bdevs=None, dhchap_key=None, dhchap_ctrlr_key=None):
705    """Construct block device for each NVMe namespace in the attached controller.
706    Args:
707        name: bdev name prefix; "n" + namespace ID will be appended to create unique names
708        trtype: transport type ("PCIe", "RDMA", "FC", "TCP")
709        traddr: transport address (PCI BDF or IP address)
710        adrfam: address family ("IPv4", "IPv6", "IB", or "FC")
711        trsvcid: transport service ID (port number for IP-based addresses)
712        priority: transport connection priority (Sock priority for TCP-based transports; optional)
713        subnqn: subsystem NQN to connect to (optional)
714        hostnqn: NQN to connect from (optional)
715        hostaddr: host transport address (IP address for IP-based transports, NULL for PCIe or FC; optional)
716        hostsvcid: host transport service ID (port number for IP-based transports, NULL for PCIe or FC; optional)
717        prchk_reftag: Enable checking of PI reference tag for I/O processing (optional)
718        prchk_guard: Enable checking of PI guard for I/O processing (optional)
719        hdgst: Enable TCP header digest (optional)
720        ddgst: Enable TCP data digest (optional)
721        fabrics_connect_timeout_us: Fabrics connect timeout in us (optional)
722        multipath: The behavior when multiple paths are created ("disable", "failover", or "multipath"; failover if not specified)
723        num_io_queues: The number of IO queues to request during initialization. (optional)
724        ctrlr_loss_timeout_sec: Time to wait until ctrlr is reconnected before deleting ctrlr.
725        -1 means infinite reconnect retries. 0 means no reconnect retry.
726        If reconnect_delay_sec is zero, ctrlr_loss_timeout_sec has to be zero.
727        If reconnect_delay_sec is non-zero, ctrlr_loss_timeout_sec has to be -1 or not less than reconnect_delay_sec.
728        (optional)
729        reconnect_delay_sec: Time to delay a reconnect retry.
730        If ctrlr_loss_timeout_sec is zero, reconnect_delay_sec has to be zero.
731        If ctrlr_loss_timeout_sec is -1, reconnect_delay_sec has to be non-zero.
732        If ctrlr_loss_timeout_sec is not -1 or zero, reconnect_sec has to be non-zero and less than ctrlr_loss_timeout_sec.
733        (optional)
734        fast_io_fail_timeout_sec: Time to wait until ctrlr is reconnected before failing I/O to ctrlr.
735        0 means no such timeout.
736        If fast_io_fail_timeout_sec is not zero, it has to be not less than reconnect_delay_sec and less than
737        ctrlr_loss_timeout_sec if ctrlr_loss_timeout_sec is not -1. (optional)
738        psk: Set PSK file path and enable TCP SSL socket implementation (optional)
739        max_bdevs: Size of the name array for newly created bdevs. Default is 128. (optional)
740        dhchap_key: DH-HMAC-CHAP key name.
741        dhchap_ctrlr_key: DH-HMAC-CHAP controller key name.
742    Returns:
743        Names of created block devices.
744    """
745    params = dict()
746    params['name'] = name
747    params['trtype'] = trtype
748    params['traddr'] = traddr
749    if adrfam is not None:
750        params['adrfam'] = adrfam
751    if trsvcid is not None:
752        params['trsvcid'] = trsvcid
753    if priority is not None:
754        params['priority'] = priority
755    if subnqn is not None:
756        params['subnqn'] = subnqn
757    if hostnqn is not None:
758        params['hostnqn'] = hostnqn
759    if hostaddr is not None:
760        params['hostaddr'] = hostaddr
761    if hostsvcid is not None:
762        params['hostsvcid'] = hostsvcid
763    if prchk_reftag is not None:
764        params['prchk_reftag'] = prchk_reftag
765    if prchk_guard is not None:
766        params['prchk_guard'] = prchk_guard
767    if hdgst is not None:
768        params['hdgst'] = hdgst
769    if ddgst is not None:
770        params['ddgst'] = ddgst
771    if fabrics_connect_timeout_us is not None:
772        params['fabrics_connect_timeout_us'] = fabrics_connect_timeout_us
773    if multipath is not None:
774        params['multipath'] = multipath
775    if num_io_queues is not None:
776        params['num_io_queues'] = num_io_queues
777    if ctrlr_loss_timeout_sec is not None:
778        params['ctrlr_loss_timeout_sec'] = ctrlr_loss_timeout_sec
779    if reconnect_delay_sec is not None:
780        params['reconnect_delay_sec'] = reconnect_delay_sec
781    if fast_io_fail_timeout_sec is not None:
782        params['fast_io_fail_timeout_sec'] = fast_io_fail_timeout_sec
783    if psk is not None:
784        params['psk'] = psk
785    if max_bdevs is not None:
786        params['max_bdevs'] = max_bdevs
787    if dhchap_key is not None:
788        params['dhchap_key'] = dhchap_key
789    if dhchap_ctrlr_key is not None:
790        params['dhchap_ctrlr_key'] = dhchap_ctrlr_key
791    return client.call('bdev_nvme_attach_controller', params)
792
793
794def bdev_nvme_detach_controller(client, name, trtype=None, traddr=None,
795                                adrfam=None, trsvcid=None, subnqn=None,
796                                hostaddr=None, hostsvcid=None):
797    """Detach NVMe controller and delete any associated bdevs. Optionally,
798       If all of the transport ID options are specified, only remove that
799       transport path from the specified controller. If that is the only
800       available path for the controller, this will also result in the
801       controller being detached and the associated bdevs being deleted.
802    Args:
803        name: controller name
804        trtype: transport type ("PCIe", "RDMA")
805        traddr: transport address (PCI BDF or IP address)
806        adrfam: address family ("IPv4", "IPv6", "IB", or "FC")
807        trsvcid: transport service ID (port number for IP-based addresses)
808        subnqn: subsystem NQN to connect to (optional)
809        hostaddr: Host address (IP address)
810        hostsvcid: transport service ID on host side (port number)
811    """
812    params = dict()
813    params['name'] = name
814    if trtype is not None:
815        params['trtype'] = trtype
816    if traddr is not None:
817        params['traddr'] = traddr
818    if adrfam is not None:
819        params['adrfam'] = adrfam
820    if trsvcid is not None:
821        params['trsvcid'] = trsvcid
822    if subnqn is not None:
823        params['subnqn'] = subnqn
824    if hostaddr is not None:
825        params['hostaddr'] = hostaddr
826    if hostsvcid is not None:
827        params['hostsvcid'] = hostsvcid
828    return client.call('bdev_nvme_detach_controller', params)
829
830
831def bdev_nvme_reset_controller(client, name, cntlid=None):
832    """Reset an NVMe controller or all NVMe controllers in an NVMe bdev controller.
833    Args:
834        name: controller name
835        cntlid: NVMe controller ID (optional)
836    """
837    params = dict()
838    params['name'] = name
839    if cntlid is not None:
840        params['cntlid'] = cntlid
841    return client.call('bdev_nvme_reset_controller', params)
842
843
844def bdev_nvme_enable_controller(client, name, cntlid=None):
845    """Enable an NVMe controller or all NVMe controllers in an NVMe bdev controller.
846    Args:
847        name: controller name
848        cntlid: NVMe controller ID (optional)
849    """
850    params = dict()
851    params['name'] = name
852    if cntlid is not None:
853        params['cntlid'] = cntlid
854    return client.call('bdev_nvme_enable_controller', params)
855
856
857def bdev_nvme_disable_controller(client, name, cntlid=None):
858    """Disable an NVMe controller or all NVMe controllers in an NVMe bdev controller.
859    Args:
860        name: controller name
861        cntlid: NVMe controller ID (optional)
862    """
863    params = dict()
864    params['name'] = name
865    if cntlid is not None:
866        params['cntlid'] = cntlid
867    return client.call('bdev_nvme_disable_controller', params)
868
869
870def bdev_nvme_start_discovery(client, name, trtype, traddr, adrfam=None, trsvcid=None,
871                              hostnqn=None, wait_for_attach=None, ctrlr_loss_timeout_sec=None,
872                              reconnect_delay_sec=None, fast_io_fail_timeout_sec=None,
873                              attach_timeout_ms=None):
874    """Start discovery with the specified discovery subsystem
875    Args:
876        name: bdev name prefix; "n" + namespace ID will be appended to create unique names
877        trtype: transport type ("PCIe", "RDMA", "FC", "TCP")
878        traddr: transport address (PCI BDF or IP address)
879        adrfam: address family ("IPv4", "IPv6", "IB", or "FC")
880        trsvcid: transport service ID (port number for IP-based addresses)
881        hostnqn: NQN to connect from (optional)
882        wait_for_attach: Wait to complete RPC until all discovered NVM subsystems have attached (optional)
883        ctrlr_loss_timeout_sec: Time to wait until ctrlr is reconnected before deleting ctrlr.
884        -1 means infinite reconnect retries. 0 means no reconnect retry.
885        If reconnect_delay_sec is zero, ctrlr_loss_timeout_sec has to be zero.
886        If reconnect_delay_sec is non-zero, ctrlr_loss_timeout_sec has to be -1 or not less than reconnect_delay_sec.
887        (optional)
888        reconnect_delay_sec: Time to delay a reconnect retry.
889        If ctrlr_loss_timeout_sec is zero, reconnect_delay_sec has to be zero.
890        If ctrlr_loss_timeout_sec is -1, reconnect_delay_sec has to be non-zero.
891        If ctrlr_loss_timeout_sec is not -1 or zero, reconnect_sec has to be non-zero and less than ctrlr_loss_timeout_sec.
892        (optional)
893        fast_io_fail_timeout_sec: Time to wait until ctrlr is reconnected before failing I/O to ctrlr.
894        0 means no such timeout.
895        If fast_io_fail_timeout_sec is not zero, it has to be not less than reconnect_delay_sec and less than
896        ctrlr_loss_timeout_sec if ctrlr_loss_timeout_sec is not -1. (optional)
897        attach_timeout_ms: Time to wait until the discovery and all discovered NVM subsystems are attached (optional)
898    """
899    params = dict()
900    params['name'] = name
901    params['trtype'] = trtype
902    params['traddr'] = traddr
903    if adrfam is not None:
904        params['adrfam'] = adrfam
905    if trsvcid is not None:
906        params['trsvcid'] = trsvcid
907    if hostnqn is not None:
908        params['hostnqn'] = hostnqn
909    if wait_for_attach is not None:
910        params['wait_for_attach'] = wait_for_attach
911    if ctrlr_loss_timeout_sec is not None:
912        params['ctrlr_loss_timeout_sec'] = ctrlr_loss_timeout_sec
913    if reconnect_delay_sec is not None:
914        params['reconnect_delay_sec'] = reconnect_delay_sec
915    if fast_io_fail_timeout_sec is not None:
916        params['fast_io_fail_timeout_sec'] = fast_io_fail_timeout_sec
917    if attach_timeout_ms is not None:
918        params['attach_timeout_ms'] = attach_timeout_ms
919    return client.call('bdev_nvme_start_discovery', params)
920
921
922def bdev_nvme_stop_discovery(client, name):
923    """Stop a previously started discovery service
924    Args:
925        name: name of discovery service to start
926    """
927    params = dict()
928    params['name'] = name
929    return client.call('bdev_nvme_stop_discovery', params)
930
931
932def bdev_nvme_get_discovery_info(client):
933    """Get information about the automatic discovery
934    """
935    return client.call('bdev_nvme_get_discovery_info')
936
937
938def bdev_nvme_get_io_paths(client, name=None):
939    """Display all or the specified NVMe bdev's active I/O paths
940    Args:
941        name: Name of the NVMe bdev (optional)
942    Returns:
943        List of active I/O paths
944    """
945    params = dict()
946    if name is not None:
947        params['name'] = name
948    return client.call('bdev_nvme_get_io_paths', params)
949
950
951def bdev_nvme_set_preferred_path(client, name, cntlid):
952    """Set the preferred I/O path for an NVMe bdev when in multipath mode
953    Args:
954        name: NVMe bdev name
955        cntlid: NVMe-oF controller ID
956    """
957    params = dict()
958    params['name'] = name
959    params['cntlid'] = cntlid
960    return client.call('bdev_nvme_set_preferred_path', params)
961
962
963def bdev_nvme_set_multipath_policy(client, name, policy, selector=None, rr_min_io=None):
964    """Set multipath policy of the NVMe bdev
965    Args:
966        name: NVMe bdev name
967        policy: Multipath policy (active_passive or active_active)
968        selector: Multipath selector (round_robin, queue_depth)
969        rr_min_io: Number of IO to route to a path before switching to another one (optional)
970    """
971    params = dict()
972    params['name'] = name
973    params['policy'] = policy
974    if selector is not None:
975        params['selector'] = selector
976    if rr_min_io is not None:
977        params['rr_min_io'] = rr_min_io
978    return client.call('bdev_nvme_set_multipath_policy', params)
979
980
981def bdev_nvme_get_path_iostat(client, name):
982    """Get I/O statistics for IO paths of the block device.
983    Args:
984        name: bdev name to query
985    Returns:
986        I/O statistics for IO paths of the requested block device.
987    """
988    params = dict()
989    params['name'] = name
990    return client.call('bdev_nvme_get_path_iostat', params)
991
992
993def bdev_nvme_cuse_register(client, name):
994    """Register CUSE devices on NVMe controller.
995    Args:
996        name: Name of the operating NVMe controller
997    """
998    params = dict()
999    params['name'] = name
1000    return client.call('bdev_nvme_cuse_register', params)
1001
1002
1003def bdev_nvme_cuse_unregister(client, name):
1004    """Unregister CUSE devices on NVMe controller.
1005    Args:
1006        name: Name of the operating NVMe controller
1007    """
1008    params = dict()
1009    params['name'] = name
1010    return client.call('bdev_nvme_cuse_unregister', params)
1011
1012
1013def bdev_zone_block_create(client, name, base_bdev, zone_capacity, optimal_open_zones):
1014    """Creates a virtual zone device on top of existing non-zoned bdev.
1015    Args:
1016        name: Zone device name
1017        base_bdev: Base Nvme bdev name
1018        zone_capacity: Surfaced zone capacity in blocks
1019        optimal_open_zones: Number of zones required to reach optimal write speed (optional, default: 1)
1020    Returns:
1021        Name of created block device.
1022    """
1023    params = dict()
1024    params['name'] = name
1025    params['base_bdev'] = base_bdev
1026    params['zone_capacity'] = zone_capacity
1027    params['optimal_open_zones'] = optimal_open_zones
1028    return client.call('bdev_zone_block_create', params)
1029
1030
1031def bdev_zone_block_delete(client, name):
1032    """Remove block zone bdev from the system.
1033    Args:
1034        name: name of block zone bdev to delete
1035    """
1036    params = dict()
1037    params['name'] = name
1038    return client.call('bdev_zone_block_delete', params)
1039
1040
1041def bdev_rbd_register_cluster(client, name=None, user_id=None, config_param=None, config_file=None, key_file=None, core_mask=None):
1042    """Create a Rados Cluster object of the Ceph RBD backend.
1043    Args:
1044        name: name of Rados Cluster
1045        user_id: Ceph user name (optional)
1046        config_param: map of config keys to values (optional)
1047        config_file: file path of Ceph configuration file (optional)
1048        key_file: file path of Ceph key file (optional)
1049        core_mask: core mask for librbd IO context threads (optional)
1050    Returns:
1051        Name of registered Rados Cluster object.
1052    """
1053    params = dict()
1054    if name is not None:
1055        params['name'] = name
1056    if user_id is not None:
1057        params['user_id'] = user_id
1058    if config_param is not None:
1059        params['config_param'] = config_param
1060    if config_file is not None:
1061        params['config_file'] = config_file
1062    if key_file is not None:
1063        params['key_file'] = key_file
1064    if core_mask is not None:
1065        params['core_mask'] = core_mask
1066    return client.call('bdev_rbd_register_cluster', params)
1067
1068
1069def bdev_rbd_unregister_cluster(client, name):
1070    """Remove Rados cluster object from the system.
1071    Args:
1072        name: name of Rados cluster object to unregister
1073    """
1074    params = dict()
1075    params['name'] = name
1076    return client.call('bdev_rbd_unregister_cluster', params)
1077
1078
1079def bdev_rbd_get_clusters_info(client, name=None):
1080    """Get the cluster(s) info
1081    Args:
1082        name: name of Rados cluster object to query (optional; if omitted, query all clusters)
1083    Returns:
1084        List of registered Rados cluster information objects.
1085    """
1086    params = dict()
1087    if name is not None:
1088        params['name'] = name
1089    return client.call('bdev_rbd_get_clusters_info', params)
1090
1091
1092def bdev_rbd_create(client, pool_name, rbd_name, block_size, name=None, user_id=None, config=None, cluster_name=None, uuid=None):
1093    """Create a Ceph RBD block device.
1094    Args:
1095        pool_name: Ceph RBD pool name
1096        rbd_name: Ceph RBD image name
1097        block_size: block size of RBD volume
1098        name: name of block device (optional)
1099        user_id: Ceph user name (optional)
1100        config: map of config keys to values (optional)
1101        cluster_name: Name to identify Rados cluster (optional)
1102        uuid: UUID of block device (optional)
1103    Returns:
1104        Name of created block device.
1105    """
1106    params = dict()
1107    params['pool_name'] = pool_name
1108    params['rbd_name'] = rbd_name
1109    params['block_size'] = block_size
1110    if name is not None:
1111        params['name'] = name
1112    if user_id is not None:
1113        params['user_id'] = user_id
1114    if config is not None:
1115        params['config'] = config
1116    if cluster_name is not None:
1117        params['cluster_name'] = cluster_name
1118    else:
1119        print("WARNING:bdev_rbd_create should be used with specifying -c to have a cluster name after bdev_rbd_register_cluster.")
1120    if uuid is not None:
1121        params['uuid'] = uuid
1122    return client.call('bdev_rbd_create', params)
1123
1124
1125def bdev_rbd_delete(client, name):
1126    """Remove rbd bdev from the system.
1127    Args:
1128        name: name of rbd bdev to delete
1129    """
1130    params = dict()
1131    params['name'] = name
1132    return client.call('bdev_rbd_delete', params)
1133
1134
1135def bdev_rbd_resize(client, name, new_size):
1136    """Resize rbd bdev in the system.
1137    Args:
1138        name: name of rbd bdev to resize
1139        new_size: new bdev size of resize operation. The unit is MiB
1140    """
1141    params = dict()
1142    params['name'] = name
1143    params['new_size'] = new_size
1144    return client.call('bdev_rbd_resize', params)
1145
1146
1147def bdev_error_create(client, base_name, uuid=None):
1148    """Construct an error injection block device.
1149    Args:
1150        base_name: base bdev name
1151        uuid: UUID for this bdev (optional)
1152    """
1153    params = dict()
1154    params['base_name'] = base_name
1155    if uuid is not None:
1156        params['uuid'] = uuid
1157    return client.call('bdev_error_create', params)
1158
1159
1160def bdev_delay_create(client, base_bdev_name, name, avg_read_latency, p99_read_latency, avg_write_latency, p99_write_latency, uuid=None):
1161    """Construct a delay block device.
1162    Args:
1163        base_bdev_name: name of the existing bdev
1164        name: name of block device
1165        avg_read_latency: complete 99% of read ops with this delay
1166        p99_read_latency: complete 1% of read ops with this delay
1167        avg_write_latency: complete 99% of write ops with this delay
1168        p99_write_latency: complete 1% of write ops with this delay
1169        uuid: UUID of block device (optional)
1170    Returns:
1171        Name of created block device.
1172    """
1173    params = dict()
1174    params['base_bdev_name'] = base_bdev_name
1175    params['name'] = name
1176    params['avg_read_latency'] = avg_read_latency
1177    params['p99_read_latency'] = p99_read_latency
1178    params['avg_write_latency'] = avg_write_latency
1179    params['p99_write_latency'] = p99_write_latency
1180    if uuid is not None:
1181        params['uuid'] = uuid
1182    return client.call('bdev_delay_create', params)
1183
1184
1185def bdev_delay_delete(client, name):
1186    """Remove delay bdev from the system.
1187    Args:
1188        name: name of delay bdev to delete
1189    """
1190    params = dict()
1191    params['name'] = name
1192    return client.call('bdev_delay_delete', params)
1193
1194
1195def bdev_delay_update_latency(client, delay_bdev_name, latency_type, latency_us):
1196    """Update the latency value for a delay block device
1197    Args:
1198        delay_bdev_name: name of the delay bdev
1199        latency_type: 'one of: avg_read, avg_write, p99_read, p99_write. No other values accepted.'
1200        latency_us: 'new latency value.'
1201    Returns:
1202        True if successful, or a specific error otherwise.
1203    """
1204    params = dict()
1205    params['delay_bdev_name'] = delay_bdev_name
1206    params['latency_type'] = latency_type
1207    params['latency_us'] = latency_us
1208    return client.call('bdev_delay_update_latency', params)
1209
1210
1211def bdev_error_delete(client, name):
1212    """Remove error bdev from the system.
1213    Args:
1214        bdev_name: name of error bdev to delete
1215    """
1216    params = dict()
1217    params['name'] = name
1218    return client.call('bdev_error_delete', params)
1219
1220
1221def bdev_iscsi_set_options(client, timeout_sec=None):
1222    """Set options for the bdev iscsi.
1223    Args:
1224        timeout_sec: Timeout for command, in seconds, if 0, don't track timeout
1225    """
1226    params = dict()
1227    if timeout_sec is not None:
1228        params['timeout_sec'] = timeout_sec
1229    return client.call('bdev_iscsi_set_options', params)
1230
1231
1232def bdev_iscsi_create(client, name, url, initiator_iqn):
1233    """Construct an iSCSI block device.
1234    Args:
1235        name: name of block device
1236        url: iSCSI URL
1237        initiator_iqn: IQN name to be used by initiator
1238    Returns:
1239        Name of created block device.
1240    """
1241    params = dict()
1242    params['name'] = name
1243    params['url'] = url
1244    params['initiator_iqn'] = initiator_iqn
1245    return client.call('bdev_iscsi_create', params)
1246
1247
1248def bdev_iscsi_delete(client, name):
1249    """Remove iSCSI bdev from the system.
1250    Args:
1251        bdev_name: name of iSCSI bdev to delete
1252    """
1253    params = dict()
1254    params['name'] = name
1255    return client.call('bdev_iscsi_delete', params)
1256
1257
1258def bdev_passthru_create(client, base_bdev_name, name, uuid=None):
1259    """Construct a pass-through block device.
1260    Args:
1261        base_bdev_name: name of the existing bdev
1262        name: name of block device
1263        uuid: UUID of block device (optional)
1264    Returns:
1265        Name of created block device.
1266    """
1267    params = dict()
1268    params['base_bdev_name'] = base_bdev_name
1269    params['name'] = name
1270    if uuid is not None:
1271        params['uuid'] = uuid
1272    return client.call('bdev_passthru_create', params)
1273
1274
1275def bdev_passthru_delete(client, name):
1276    """Remove pass through bdev from the system.
1277    Args:
1278        name: name of pass through bdev to delete
1279    """
1280    params = dict()
1281    params['name'] = name
1282    return client.call('bdev_passthru_delete', params)
1283
1284
1285def bdev_opal_create(client, nvme_ctrlr_name, nsid, locking_range_id, range_start, range_length, password):
1286    """Create opal virtual block devices from a base nvme bdev.
1287    Args:
1288        nvme_ctrlr_name: name of the nvme ctrlr
1289        nsid: namespace ID of nvme ctrlr
1290        locking_range_id: locking range ID corresponding to this virtual bdev
1291        range_start: start address of this locking range
1292        range_length: length of this locking range
1293        password: admin password of base nvme bdev
1294    Returns:
1295        Name of the new created block devices.
1296    """
1297    params = dict()
1298    params['nvme_ctrlr_name'] = nvme_ctrlr_name
1299    params['nsid'] = nsid
1300    params['locking_range_id'] = locking_range_id
1301    params['range_start'] = range_start
1302    params['range_length'] = range_length
1303    params['password'] = password
1304    return client.call('bdev_opal_create', params)
1305
1306
1307def bdev_opal_get_info(client, bdev_name, password):
1308    """Get opal locking range info.
1309    Args:
1310        bdev_name: name of opal vbdev to get info
1311        password: admin password
1312    Returns:
1313        Locking range info.
1314    """
1315    params = dict()
1316    params['bdev_name'] = bdev_name
1317    params['password'] = password
1318    return client.call('bdev_opal_get_info', params)
1319
1320
1321def bdev_opal_delete(client, bdev_name, password):
1322    """Delete opal virtual bdev from the system.
1323    Args:
1324        bdev_name: name of opal vbdev to delete
1325        password: admin password of base nvme bdev
1326    """
1327    params = dict()
1328    params['bdev_name'] = bdev_name
1329    params['password'] = password
1330    return client.call('bdev_opal_delete', params)
1331
1332
1333def bdev_opal_new_user(client, bdev_name, admin_password, user_id, user_password):
1334    """Add a user to opal bdev who can set lock state for this bdev.
1335    Args:
1336        bdev_name: name of opal vbdev
1337        admin_password: admin password
1338        user_id: ID of the user who will be added to this opal bdev
1339        user_password: password set for this user
1340    """
1341    params = dict()
1342    params['bdev_name'] = bdev_name
1343    params['admin_password'] = admin_password
1344    params['user_id'] = user_id
1345    params['user_password'] = user_password
1346    return client.call('bdev_opal_new_user', params)
1347
1348
1349def bdev_opal_set_lock_state(client, bdev_name, user_id, password, lock_state):
1350    """set lock state for an opal bdev.
1351    Args:
1352        bdev_name: name of opal vbdev
1353        user_id: ID of the user who will set lock state
1354        password: password of the user
1355        lock_state: lock state to set
1356    """
1357    params = dict()
1358    params['bdev_name'] = bdev_name
1359    params['user_id'] = user_id
1360    params['password'] = password
1361    params['lock_state'] = lock_state
1362    return client.call('bdev_opal_set_lock_state', params)
1363
1364
1365def bdev_split_create(client, base_bdev, split_count, split_size_mb=None):
1366    """Create split block devices from a base bdev.
1367    Args:
1368        base_bdev: name of bdev to split
1369        split_count: number of split bdevs to create
1370        split_size_mb: size of each split volume in MiB (optional)
1371    Returns:
1372        List of created block devices.
1373    """
1374    params = dict()
1375    params['base_bdev'] = base_bdev
1376    params['split_count'] = split_count
1377    if split_size_mb is not None:
1378        params['split_size_mb'] = split_size_mb
1379    return client.call('bdev_split_create', params)
1380
1381
1382def bdev_split_delete(client, base_bdev):
1383    """Delete split block devices.
1384    Args:
1385        base_bdev: name of previously split bdev
1386    """
1387    params = dict()
1388    params['base_bdev'] = base_bdev
1389    return client.call('bdev_split_delete', params)
1390
1391
1392def bdev_ftl_create(client, name, base_bdev, cache, **kwargs):
1393    """Construct FTL bdev
1394    Args:
1395        name: name of the bdev
1396        base_bdev: name of the base bdev
1397        cache: name of the cache device
1398        kwargs: optional parameters
1399    """
1400    params = dict()
1401    params['name'] = name
1402    params['base_bdev'] = base_bdev
1403    params['cache'] = cache
1404    for key, value in kwargs.items():
1405        if value is not None:
1406            params[key] = value
1407    return client.call('bdev_ftl_create', params)
1408
1409
1410def bdev_ftl_load(client, name, base_bdev, cache, **kwargs):
1411    """Load FTL bdev
1412    Args:
1413        name: name of the bdev
1414        base_bdev: name of the base bdev
1415        cache: Name of the cache device
1416        kwargs: optional parameters
1417    """
1418    params = dict()
1419    params['name'] = name
1420    params['base_bdev'] = base_bdev
1421    params['cache'] = cache
1422    for key, value in kwargs.items():
1423        if value is not None:
1424            params[key] = value
1425    return client.call('bdev_ftl_load', params)
1426
1427
1428def bdev_ftl_unload(client, name, fast_shutdown=None):
1429    """Unload FTL bdev
1430    Args:
1431        name: name of the bdev
1432        fast_shutdown: When set FTL will minimize persisted data during deletion and rely on shared memory during next load
1433    """
1434    params = dict()
1435    params['name'] = name
1436    if fast_shutdown is not None:
1437        params['fast_shutdown'] = fast_shutdown
1438    return client.call('bdev_ftl_unload', params)
1439
1440
1441def bdev_ftl_delete(client, name, fast_shutdown=None):
1442    """Delete FTL bdev
1443    Args:
1444        name: name of the bdev
1445        fast_shutdown: When set FTL will minimize persisted data during deletion and rely on shared memory during next load
1446    """
1447    params = dict()
1448    params['name'] = name
1449    if fast_shutdown is not None:
1450        params['fast_shutdown'] = fast_shutdown
1451    return client.call('bdev_ftl_delete', params)
1452
1453
1454def bdev_ftl_unmap(client, name, lba, num_blocks):
1455    """FTL unmap
1456    Args:
1457        name: name of the bdev
1458        lba: starting lba to be unmapped
1459        num_blocks: number of blocks to unmap
1460    """
1461    params = dict()
1462    params['name'] = name
1463    params['lba'] = lba
1464    params['num_blocks'] = num_blocks
1465    return client.call('bdev_ftl_unmap', params)
1466
1467
1468def bdev_ftl_get_stats(client, name):
1469    """get FTL stats
1470    Args:
1471        name: name of the bdev
1472    """
1473    params = dict()
1474    params['name'] = name
1475    return client.call('bdev_ftl_get_stats', params)
1476
1477
1478def bdev_ftl_get_properties(client, name):
1479    """Get FTL properties
1480    Args:
1481        name: name of the bdev
1482    """
1483    params = dict()
1484    params['name'] = name
1485    return client.call('bdev_ftl_get_properties', params)
1486
1487
1488def bdev_ftl_set_property(client, name, ftl_property, value):
1489    """Set FTL property
1490    Args:
1491        name: name of the bdev
1492        ftl_property: name of the property to be set
1493        value: The new value of the updated property
1494    """
1495    params = dict()
1496    params['name'] = name
1497    params['ftl_property'] = ftl_property
1498    params['value'] = value
1499    return client.call('bdev_ftl_set_property', params)
1500
1501
1502def bdev_get_bdevs(client, name=None, timeout=None):
1503    """Get information about block devices.
1504    Args:
1505        name: bdev name to query (optional; if omitted, query all bdevs)
1506        timeout: time in ms to wait for the bdev with specified name to appear
1507    Returns:
1508        List of bdev information objects.
1509    """
1510    params = dict()
1511    if name is not None:
1512        params['name'] = name
1513    if timeout is not None:
1514        params['timeout'] = timeout
1515    return client.call('bdev_get_bdevs', params)
1516
1517
1518def bdev_get_iostat(client, name=None, per_channel=None):
1519    """Get I/O statistics for block devices.
1520    Args:
1521        name: bdev name to query (optional; if omitted, query all bdevs)
1522        per_channel: display per channel IO stats for specified bdev
1523    Returns:
1524        I/O statistics for the requested block devices.
1525    """
1526    params = dict()
1527    if name is not None:
1528        params['name'] = name
1529    if per_channel is not None:
1530        params['per_channel'] = per_channel
1531    return client.call('bdev_get_iostat', params)
1532
1533
1534def bdev_reset_iostat(client, name=None, mode=None):
1535    """Reset I/O statistics for block devices.
1536    Args:
1537        name: bdev name to reset (optional; if omitted, reset all bdevs)
1538        mode: mode to reset: all, maxmin (optional: if omitted, reset all fields)
1539    """
1540    params = dict()
1541    if name is not None:
1542        params['name'] = name
1543    if mode is not None:
1544        params['mode'] = mode
1545    return client.call('bdev_reset_iostat', params)
1546
1547
1548def bdev_enable_histogram(client, name, enable, opc):
1549    """Control whether histogram is enabled for specified bdev.
1550    Args:
1551        name: name of bdev
1552        enable: Enable or disable histogram on specified device
1553        opc: name of io_type (optional)
1554    """
1555    params = dict()
1556    params['name'] = name
1557    params['enable'] = enable
1558    if opc:
1559        params['opc'] = opc
1560    return client.call('bdev_enable_histogram', params)
1561
1562
1563def bdev_get_histogram(client, name):
1564    """Get histogram for specified bdev.
1565    Args:
1566        name: name of bdev
1567    """
1568    params = dict()
1569    params['name'] = name
1570    return client.call('bdev_get_histogram', params)
1571
1572
1573def bdev_error_inject_error(client, name, io_type, error_type, num=None,
1574                            queue_depth=None, corrupt_offset=None, corrupt_value=None):
1575    """Inject an error via an error bdev.
1576    Args:
1577        name: name of error bdev
1578        io_type: one of "clear", "read", "write", "unmap", "flush", or "all"
1579        error_type: one of "failure", "pending", "corrupt_data" or "nomem"
1580        num: number of commands to fail
1581        queue_depth: the queue depth at which to trigger the error
1582        corrupt_offset: offset in bytes to xor with corrupt_value
1583        corrupt_value: value for xor (1-255, 0 is invalid)
1584    """
1585    params = dict()
1586    params['name'] = name
1587    params['io_type'] = io_type
1588    params['error_type'] = error_type
1589    if num is not None:
1590        params['num'] = num
1591    if queue_depth is not None:
1592        params['queue_depth'] = queue_depth
1593    if corrupt_offset is not None:
1594        params['corrupt_offset'] = corrupt_offset
1595    if corrupt_value is not None:
1596        params['corrupt_value'] = corrupt_value
1597    return client.call('bdev_error_inject_error', params)
1598
1599
1600def bdev_set_qd_sampling_period(client, name, period):
1601    """Enable queue depth tracking on a specified bdev.
1602    Args:
1603        name: name of a bdev on which to track queue depth.
1604        period: period (in microseconds) at which to update the queue depth reading. If set to 0, polling will be disabled.
1605    """
1606    params = dict()
1607    params['name'] = name
1608    params['period'] = period
1609    return client.call('bdev_set_qd_sampling_period', params)
1610
1611
1612def bdev_set_qos_limit(
1613        client,
1614        name,
1615        rw_ios_per_sec=None,
1616        rw_mbytes_per_sec=None,
1617        r_mbytes_per_sec=None,
1618        w_mbytes_per_sec=None):
1619    """Set QoS rate limit on a block device.
1620    Args:
1621        name: name of block device
1622        rw_ios_per_sec: R/W IOs per second limit (>=1000, example: 20000). 0 means unlimited.
1623        rw_mbytes_per_sec: R/W megabytes per second limit (>=10, example: 100). 0 means unlimited.
1624        r_mbytes_per_sec: Read megabytes per second limit (>=10, example: 100). 0 means unlimited.
1625        w_mbytes_per_sec: Write megabytes per second limit (>=10, example: 100). 0 means unlimited.
1626    """
1627    params = dict()
1628    params['name'] = name
1629    if rw_ios_per_sec is not None:
1630        params['rw_ios_per_sec'] = rw_ios_per_sec
1631    if rw_mbytes_per_sec is not None:
1632        params['rw_mbytes_per_sec'] = rw_mbytes_per_sec
1633    if r_mbytes_per_sec is not None:
1634        params['r_mbytes_per_sec'] = r_mbytes_per_sec
1635    if w_mbytes_per_sec is not None:
1636        params['w_mbytes_per_sec'] = w_mbytes_per_sec
1637    return client.call('bdev_set_qos_limit', params)
1638
1639
1640def bdev_nvme_apply_firmware(client, bdev_name, filename):
1641    """Download and commit firmware to NVMe device.
1642    Args:
1643        bdev_name: name of NVMe block device
1644        filename: filename of the firmware to download
1645    """
1646    params = dict()
1647    params['bdev_name'] = bdev_name
1648    params['filename'] = filename
1649    return client.call('bdev_nvme_apply_firmware', params)
1650
1651
1652def bdev_nvme_get_transport_statistics(client):
1653    """Get bdev_nvme poll group transport statistics"""
1654    return client.call('bdev_nvme_get_transport_statistics')
1655
1656
1657def bdev_nvme_get_controller_health_info(client, name):
1658    """Display health log of the required NVMe bdev controller.
1659    Args:
1660        name: name of the required NVMe bdev controller
1661    Returns:
1662        Health log for the requested NVMe bdev controller.
1663    """
1664    params = dict()
1665    params['name'] = name
1666    return client.call('bdev_nvme_get_controller_health_info', params)
1667
1668
1669def bdev_daos_create(client, num_blocks, block_size, pool, cont, name, oclass=None, uuid=None):
1670    """Construct DAOS block device.
1671    Args:
1672        num_blocks: size of block device in blocks
1673        block_size: block size of device; must be a power of 2 and at least 512
1674        pool: UUID of DAOS pool
1675        cont: UUID of DAOS container
1676        name: name of block device (also the name of the backend file on DAOS DFS)
1677        oclass: DAOS object class (optional)
1678        uuid: UUID of block device (optional)
1679    Returns:
1680        Name of created block device.
1681    """
1682    params = dict()
1683    params['num_blocks'] = num_blocks
1684    params['block_size'] = block_size
1685    params['pool'] = pool
1686    params['cont'] = cont
1687    params['name'] = name
1688    if oclass is not None:
1689        params['oclass'] = oclass
1690    if uuid is not None:
1691        params['uuid'] = uuid
1692    return client.call('bdev_daos_create', params)
1693
1694
1695def bdev_daos_delete(client, name):
1696    """Delete DAOS block device.
1697    Args:
1698        bdev_name: name of DAOS bdev to delete
1699    """
1700    params = dict()
1701    params['name'] = name
1702    return client.call('bdev_daos_delete', params)
1703
1704
1705def bdev_daos_resize(client, name, new_size):
1706    """Resize DAOS bdev in the system.
1707    Args:
1708        name: name of DAOS bdev to resize
1709        new_size: new bdev size of resize operation. The unit is MiB
1710    """
1711    params = dict()
1712    params['name'] = name
1713    params['new_size'] = new_size
1714    return client.call('bdev_daos_resize', params)
1715
1716
1717def bdev_nvme_start_mdns_discovery(client, name, svcname, hostnqn=None):
1718    """Start discovery with mDNS
1719    Args:
1720        name: bdev name prefix; "n" + unique seqno + namespace ID will be appended to create unique names
1721        svcname: service to discover ("_nvme-disc._tcp")
1722        hostnqn: NQN to connect from (optional)
1723    """
1724    params = dict()
1725    params['name'] = name
1726    params['svcname'] = svcname
1727    if hostnqn is not None:
1728        params['hostnqn'] = hostnqn
1729    return client.call('bdev_nvme_start_mdns_discovery', params)
1730
1731
1732def bdev_nvme_stop_mdns_discovery(client, name):
1733    """Stop a previously started mdns discovery service
1734    Args:
1735        name: name of the discovery service to stop
1736    """
1737    params = dict()
1738    params['name'] = name
1739    return client.call('bdev_nvme_stop_mdns_discovery', params)
1740
1741
1742def bdev_nvme_get_mdns_discovery_info(client):
1743    """Get information about the automatic mdns discovery
1744    """
1745    return client.call('bdev_nvme_get_mdns_discovery_info')
1746