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 allow_unrecognized_csi=None): 706 """Construct block device for each NVMe namespace in the attached controller. 707 Args: 708 name: bdev name prefix; "n" + namespace ID will be appended to create unique names 709 trtype: transport type ("PCIe", "RDMA", "FC", "TCP") 710 traddr: transport address (PCI BDF or IP address) 711 adrfam: address family ("IPv4", "IPv6", "IB", or "FC") 712 trsvcid: transport service ID (port number for IP-based addresses) 713 priority: transport connection priority (Sock priority for TCP-based transports; optional) 714 subnqn: subsystem NQN to connect to (optional) 715 hostnqn: NQN to connect from (optional) 716 hostaddr: host transport address (IP address for IP-based transports, NULL for PCIe or FC; optional) 717 hostsvcid: host transport service ID (port number for IP-based transports, NULL for PCIe or FC; optional) 718 prchk_reftag: Enable checking of PI reference tag for I/O processing (optional) 719 prchk_guard: Enable checking of PI guard for I/O processing (optional) 720 hdgst: Enable TCP header digest (optional) 721 ddgst: Enable TCP data digest (optional) 722 fabrics_connect_timeout_us: Fabrics connect timeout in us (optional) 723 multipath: The behavior when multiple paths are created ("disable", "failover", or "multipath"; failover if not specified) 724 num_io_queues: The number of IO queues to request during initialization. (optional) 725 ctrlr_loss_timeout_sec: Time to wait until ctrlr is reconnected before deleting ctrlr. 726 -1 means infinite reconnect retries. 0 means no reconnect retry. 727 If reconnect_delay_sec is zero, ctrlr_loss_timeout_sec has to be zero. 728 If reconnect_delay_sec is non-zero, ctrlr_loss_timeout_sec has to be -1 or not less than reconnect_delay_sec. 729 (optional) 730 reconnect_delay_sec: Time to delay a reconnect retry. 731 If ctrlr_loss_timeout_sec is zero, reconnect_delay_sec has to be zero. 732 If ctrlr_loss_timeout_sec is -1, reconnect_delay_sec has to be non-zero. 733 If ctrlr_loss_timeout_sec is not -1 or zero, reconnect_sec has to be non-zero and less than ctrlr_loss_timeout_sec. 734 (optional) 735 fast_io_fail_timeout_sec: Time to wait until ctrlr is reconnected before failing I/O to ctrlr. 736 0 means no such timeout. 737 If fast_io_fail_timeout_sec is not zero, it has to be not less than reconnect_delay_sec and less than 738 ctrlr_loss_timeout_sec if ctrlr_loss_timeout_sec is not -1. (optional) 739 psk: Set PSK file path and enable TCP SSL socket implementation (optional) 740 max_bdevs: Size of the name array for newly created bdevs. Default is 128. (optional) 741 dhchap_key: DH-HMAC-CHAP key name. 742 dhchap_ctrlr_key: DH-HMAC-CHAP controller key name. 743 allow_unrecognized_csi: Allow attaching namespaces with unrecognized command set identifiers. These will only support NVMe 744 passthrough. 745 Returns: 746 Names of created block devices. 747 """ 748 params = dict() 749 params['name'] = name 750 params['trtype'] = trtype 751 params['traddr'] = traddr 752 if adrfam is not None: 753 params['adrfam'] = adrfam 754 if trsvcid is not None: 755 params['trsvcid'] = trsvcid 756 if priority is not None: 757 params['priority'] = priority 758 if subnqn is not None: 759 params['subnqn'] = subnqn 760 if hostnqn is not None: 761 params['hostnqn'] = hostnqn 762 if hostaddr is not None: 763 params['hostaddr'] = hostaddr 764 if hostsvcid is not None: 765 params['hostsvcid'] = hostsvcid 766 if prchk_reftag is not None: 767 params['prchk_reftag'] = prchk_reftag 768 if prchk_guard is not None: 769 params['prchk_guard'] = prchk_guard 770 if hdgst is not None: 771 params['hdgst'] = hdgst 772 if ddgst is not None: 773 params['ddgst'] = ddgst 774 if fabrics_connect_timeout_us is not None: 775 params['fabrics_connect_timeout_us'] = fabrics_connect_timeout_us 776 if multipath is not None: 777 params['multipath'] = multipath 778 if num_io_queues is not None: 779 params['num_io_queues'] = num_io_queues 780 if ctrlr_loss_timeout_sec is not None: 781 params['ctrlr_loss_timeout_sec'] = ctrlr_loss_timeout_sec 782 if reconnect_delay_sec is not None: 783 params['reconnect_delay_sec'] = reconnect_delay_sec 784 if fast_io_fail_timeout_sec is not None: 785 params['fast_io_fail_timeout_sec'] = fast_io_fail_timeout_sec 786 if psk is not None: 787 params['psk'] = psk 788 if max_bdevs is not None: 789 params['max_bdevs'] = max_bdevs 790 if dhchap_key is not None: 791 params['dhchap_key'] = dhchap_key 792 if dhchap_ctrlr_key is not None: 793 params['dhchap_ctrlr_key'] = dhchap_ctrlr_key 794 if allow_unrecognized_csi is not None: 795 params['allow_unrecognized_csi'] = allow_unrecognized_csi 796 return client.call('bdev_nvme_attach_controller', params) 797 798 799def bdev_nvme_detach_controller(client, name, trtype=None, traddr=None, 800 adrfam=None, trsvcid=None, subnqn=None, 801 hostaddr=None, hostsvcid=None): 802 """Detach NVMe controller and delete any associated bdevs. Optionally, 803 If all of the transport ID options are specified, only remove that 804 transport path from the specified controller. If that is the only 805 available path for the controller, this will also result in the 806 controller being detached and the associated bdevs being deleted. 807 Args: 808 name: controller name 809 trtype: transport type ("PCIe", "RDMA") 810 traddr: transport address (PCI BDF or IP address) 811 adrfam: address family ("IPv4", "IPv6", "IB", or "FC") 812 trsvcid: transport service ID (port number for IP-based addresses) 813 subnqn: subsystem NQN to connect to (optional) 814 hostaddr: Host address (IP address) 815 hostsvcid: transport service ID on host side (port number) 816 """ 817 params = dict() 818 params['name'] = name 819 if trtype is not None: 820 params['trtype'] = trtype 821 if traddr is not None: 822 params['traddr'] = traddr 823 if adrfam is not None: 824 params['adrfam'] = adrfam 825 if trsvcid is not None: 826 params['trsvcid'] = trsvcid 827 if subnqn is not None: 828 params['subnqn'] = subnqn 829 if hostaddr is not None: 830 params['hostaddr'] = hostaddr 831 if hostsvcid is not None: 832 params['hostsvcid'] = hostsvcid 833 return client.call('bdev_nvme_detach_controller', params) 834 835 836def bdev_nvme_reset_controller(client, name, cntlid=None): 837 """Reset an NVMe controller or all NVMe controllers in an NVMe bdev controller. 838 Args: 839 name: controller name 840 cntlid: NVMe controller ID (optional) 841 """ 842 params = dict() 843 params['name'] = name 844 if cntlid is not None: 845 params['cntlid'] = cntlid 846 return client.call('bdev_nvme_reset_controller', params) 847 848 849def bdev_nvme_enable_controller(client, name, cntlid=None): 850 """Enable an NVMe controller or all NVMe controllers in an NVMe bdev controller. 851 Args: 852 name: controller name 853 cntlid: NVMe controller ID (optional) 854 """ 855 params = dict() 856 params['name'] = name 857 if cntlid is not None: 858 params['cntlid'] = cntlid 859 return client.call('bdev_nvme_enable_controller', params) 860 861 862def bdev_nvme_disable_controller(client, name, cntlid=None): 863 """Disable an NVMe controller or all NVMe controllers in an NVMe bdev controller. 864 Args: 865 name: controller name 866 cntlid: NVMe controller ID (optional) 867 """ 868 params = dict() 869 params['name'] = name 870 if cntlid is not None: 871 params['cntlid'] = cntlid 872 return client.call('bdev_nvme_disable_controller', params) 873 874 875def bdev_nvme_start_discovery(client, name, trtype, traddr, adrfam=None, trsvcid=None, 876 hostnqn=None, wait_for_attach=None, ctrlr_loss_timeout_sec=None, 877 reconnect_delay_sec=None, fast_io_fail_timeout_sec=None, 878 attach_timeout_ms=None): 879 """Start discovery with the specified discovery subsystem 880 Args: 881 name: bdev name prefix; "n" + namespace ID will be appended to create unique names 882 trtype: transport type ("PCIe", "RDMA", "FC", "TCP") 883 traddr: transport address (PCI BDF or IP address) 884 adrfam: address family ("IPv4", "IPv6", "IB", or "FC") 885 trsvcid: transport service ID (port number for IP-based addresses) 886 hostnqn: NQN to connect from (optional) 887 wait_for_attach: Wait to complete RPC until all discovered NVM subsystems have attached (optional) 888 ctrlr_loss_timeout_sec: Time to wait until ctrlr is reconnected before deleting ctrlr. 889 -1 means infinite reconnect retries. 0 means no reconnect retry. 890 If reconnect_delay_sec is zero, ctrlr_loss_timeout_sec has to be zero. 891 If reconnect_delay_sec is non-zero, ctrlr_loss_timeout_sec has to be -1 or not less than reconnect_delay_sec. 892 (optional) 893 reconnect_delay_sec: Time to delay a reconnect retry. 894 If ctrlr_loss_timeout_sec is zero, reconnect_delay_sec has to be zero. 895 If ctrlr_loss_timeout_sec is -1, reconnect_delay_sec has to be non-zero. 896 If ctrlr_loss_timeout_sec is not -1 or zero, reconnect_sec has to be non-zero and less than ctrlr_loss_timeout_sec. 897 (optional) 898 fast_io_fail_timeout_sec: Time to wait until ctrlr is reconnected before failing I/O to ctrlr. 899 0 means no such timeout. 900 If fast_io_fail_timeout_sec is not zero, it has to be not less than reconnect_delay_sec and less than 901 ctrlr_loss_timeout_sec if ctrlr_loss_timeout_sec is not -1. (optional) 902 attach_timeout_ms: Time to wait until the discovery and all discovered NVM subsystems are attached (optional) 903 """ 904 params = dict() 905 params['name'] = name 906 params['trtype'] = trtype 907 params['traddr'] = traddr 908 if adrfam is not None: 909 params['adrfam'] = adrfam 910 if trsvcid is not None: 911 params['trsvcid'] = trsvcid 912 if hostnqn is not None: 913 params['hostnqn'] = hostnqn 914 if wait_for_attach is not None: 915 params['wait_for_attach'] = wait_for_attach 916 if ctrlr_loss_timeout_sec is not None: 917 params['ctrlr_loss_timeout_sec'] = ctrlr_loss_timeout_sec 918 if reconnect_delay_sec is not None: 919 params['reconnect_delay_sec'] = reconnect_delay_sec 920 if fast_io_fail_timeout_sec is not None: 921 params['fast_io_fail_timeout_sec'] = fast_io_fail_timeout_sec 922 if attach_timeout_ms is not None: 923 params['attach_timeout_ms'] = attach_timeout_ms 924 return client.call('bdev_nvme_start_discovery', params) 925 926 927def bdev_nvme_stop_discovery(client, name): 928 """Stop a previously started discovery service 929 Args: 930 name: name of discovery service to start 931 """ 932 params = dict() 933 params['name'] = name 934 return client.call('bdev_nvme_stop_discovery', params) 935 936 937def bdev_nvme_get_discovery_info(client): 938 """Get information about the automatic discovery 939 """ 940 return client.call('bdev_nvme_get_discovery_info') 941 942 943def bdev_nvme_get_io_paths(client, name=None): 944 """Display all or the specified NVMe bdev's active I/O paths 945 Args: 946 name: Name of the NVMe bdev (optional) 947 Returns: 948 List of active I/O paths 949 """ 950 params = dict() 951 if name is not None: 952 params['name'] = name 953 return client.call('bdev_nvme_get_io_paths', params) 954 955 956def bdev_nvme_set_preferred_path(client, name, cntlid): 957 """Set the preferred I/O path for an NVMe bdev when in multipath mode 958 Args: 959 name: NVMe bdev name 960 cntlid: NVMe-oF controller ID 961 """ 962 params = dict() 963 params['name'] = name 964 params['cntlid'] = cntlid 965 return client.call('bdev_nvme_set_preferred_path', params) 966 967 968def bdev_nvme_set_multipath_policy(client, name, policy, selector=None, rr_min_io=None): 969 """Set multipath policy of the NVMe bdev 970 Args: 971 name: NVMe bdev name 972 policy: Multipath policy (active_passive or active_active) 973 selector: Multipath selector (round_robin, queue_depth) 974 rr_min_io: Number of IO to route to a path before switching to another one (optional) 975 """ 976 params = dict() 977 params['name'] = name 978 params['policy'] = policy 979 if selector is not None: 980 params['selector'] = selector 981 if rr_min_io is not None: 982 params['rr_min_io'] = rr_min_io 983 return client.call('bdev_nvme_set_multipath_policy', params) 984 985 986def bdev_nvme_get_path_iostat(client, name): 987 """Get I/O statistics for IO paths of the block device. 988 Args: 989 name: bdev name to query 990 Returns: 991 I/O statistics for IO paths of the requested block device. 992 """ 993 params = dict() 994 params['name'] = name 995 return client.call('bdev_nvme_get_path_iostat', params) 996 997 998def bdev_nvme_cuse_register(client, name): 999 """Register CUSE devices on NVMe controller. 1000 Args: 1001 name: Name of the operating NVMe controller 1002 """ 1003 params = dict() 1004 params['name'] = name 1005 return client.call('bdev_nvme_cuse_register', params) 1006 1007 1008def bdev_nvme_cuse_unregister(client, name): 1009 """Unregister CUSE devices on NVMe controller. 1010 Args: 1011 name: Name of the operating NVMe controller 1012 """ 1013 params = dict() 1014 params['name'] = name 1015 return client.call('bdev_nvme_cuse_unregister', params) 1016 1017 1018def bdev_zone_block_create(client, name, base_bdev, zone_capacity, optimal_open_zones): 1019 """Creates a virtual zone device on top of existing non-zoned bdev. 1020 Args: 1021 name: Zone device name 1022 base_bdev: Base Nvme bdev name 1023 zone_capacity: Surfaced zone capacity in blocks 1024 optimal_open_zones: Number of zones required to reach optimal write speed (optional, default: 1) 1025 Returns: 1026 Name of created block device. 1027 """ 1028 params = dict() 1029 params['name'] = name 1030 params['base_bdev'] = base_bdev 1031 params['zone_capacity'] = zone_capacity 1032 params['optimal_open_zones'] = optimal_open_zones 1033 return client.call('bdev_zone_block_create', params) 1034 1035 1036def bdev_zone_block_delete(client, name): 1037 """Remove block zone bdev from the system. 1038 Args: 1039 name: name of block zone bdev to delete 1040 """ 1041 params = dict() 1042 params['name'] = name 1043 return client.call('bdev_zone_block_delete', params) 1044 1045 1046def bdev_rbd_register_cluster(client, name=None, user_id=None, config_param=None, config_file=None, key_file=None, core_mask=None): 1047 """Create a Rados Cluster object of the Ceph RBD backend. 1048 Args: 1049 name: name of Rados Cluster 1050 user_id: Ceph user name (optional) 1051 config_param: map of config keys to values (optional) 1052 config_file: file path of Ceph configuration file (optional) 1053 key_file: file path of Ceph key file (optional) 1054 core_mask: core mask for librbd IO context threads (optional) 1055 Returns: 1056 Name of registered Rados Cluster object. 1057 """ 1058 params = dict() 1059 if name is not None: 1060 params['name'] = name 1061 if user_id is not None: 1062 params['user_id'] = user_id 1063 if config_param is not None: 1064 params['config_param'] = config_param 1065 if config_file is not None: 1066 params['config_file'] = config_file 1067 if key_file is not None: 1068 params['key_file'] = key_file 1069 if core_mask is not None: 1070 params['core_mask'] = core_mask 1071 return client.call('bdev_rbd_register_cluster', params) 1072 1073 1074def bdev_rbd_unregister_cluster(client, name): 1075 """Remove Rados cluster object from the system. 1076 Args: 1077 name: name of Rados cluster object to unregister 1078 """ 1079 params = dict() 1080 params['name'] = name 1081 return client.call('bdev_rbd_unregister_cluster', params) 1082 1083 1084def bdev_rbd_get_clusters_info(client, name=None): 1085 """Get the cluster(s) info 1086 Args: 1087 name: name of Rados cluster object to query (optional; if omitted, query all clusters) 1088 Returns: 1089 List of registered Rados cluster information objects. 1090 """ 1091 params = dict() 1092 if name is not None: 1093 params['name'] = name 1094 return client.call('bdev_rbd_get_clusters_info', params) 1095 1096 1097def bdev_rbd_create(client, pool_name, rbd_name, block_size, name=None, user_id=None, config=None, cluster_name=None, uuid=None): 1098 """Create a Ceph RBD block device. 1099 Args: 1100 pool_name: Ceph RBD pool name 1101 rbd_name: Ceph RBD image name 1102 block_size: block size of RBD volume 1103 name: name of block device (optional) 1104 user_id: Ceph user name (optional) 1105 config: map of config keys to values (optional) 1106 cluster_name: Name to identify Rados cluster (optional) 1107 uuid: UUID of block device (optional) 1108 Returns: 1109 Name of created block device. 1110 """ 1111 params = dict() 1112 params['pool_name'] = pool_name 1113 params['rbd_name'] = rbd_name 1114 params['block_size'] = block_size 1115 if name is not None: 1116 params['name'] = name 1117 if user_id is not None: 1118 params['user_id'] = user_id 1119 if config is not None: 1120 params['config'] = config 1121 if cluster_name is not None: 1122 params['cluster_name'] = cluster_name 1123 else: 1124 print("WARNING:bdev_rbd_create should be used with specifying -c to have a cluster name after bdev_rbd_register_cluster.") 1125 if uuid is not None: 1126 params['uuid'] = uuid 1127 return client.call('bdev_rbd_create', params) 1128 1129 1130def bdev_rbd_delete(client, name): 1131 """Remove rbd bdev from the system. 1132 Args: 1133 name: name of rbd bdev to delete 1134 """ 1135 params = dict() 1136 params['name'] = name 1137 return client.call('bdev_rbd_delete', params) 1138 1139 1140def bdev_rbd_resize(client, name, new_size): 1141 """Resize rbd bdev in the system. 1142 Args: 1143 name: name of rbd bdev to resize 1144 new_size: new bdev size of resize operation. The unit is MiB 1145 """ 1146 params = dict() 1147 params['name'] = name 1148 params['new_size'] = new_size 1149 return client.call('bdev_rbd_resize', params) 1150 1151 1152def bdev_error_create(client, base_name, uuid=None): 1153 """Construct an error injection block device. 1154 Args: 1155 base_name: base bdev name 1156 uuid: UUID for this bdev (optional) 1157 """ 1158 params = dict() 1159 params['base_name'] = base_name 1160 if uuid is not None: 1161 params['uuid'] = uuid 1162 return client.call('bdev_error_create', params) 1163 1164 1165def bdev_delay_create(client, base_bdev_name, name, avg_read_latency, p99_read_latency, avg_write_latency, p99_write_latency, uuid=None): 1166 """Construct a delay block device. 1167 Args: 1168 base_bdev_name: name of the existing bdev 1169 name: name of block device 1170 avg_read_latency: complete 99% of read ops with this delay 1171 p99_read_latency: complete 1% of read ops with this delay 1172 avg_write_latency: complete 99% of write ops with this delay 1173 p99_write_latency: complete 1% of write ops with this delay 1174 uuid: UUID of block device (optional) 1175 Returns: 1176 Name of created block device. 1177 """ 1178 params = dict() 1179 params['base_bdev_name'] = base_bdev_name 1180 params['name'] = name 1181 params['avg_read_latency'] = avg_read_latency 1182 params['p99_read_latency'] = p99_read_latency 1183 params['avg_write_latency'] = avg_write_latency 1184 params['p99_write_latency'] = p99_write_latency 1185 if uuid is not None: 1186 params['uuid'] = uuid 1187 return client.call('bdev_delay_create', params) 1188 1189 1190def bdev_delay_delete(client, name): 1191 """Remove delay bdev from the system. 1192 Args: 1193 name: name of delay bdev to delete 1194 """ 1195 params = dict() 1196 params['name'] = name 1197 return client.call('bdev_delay_delete', params) 1198 1199 1200def bdev_delay_update_latency(client, delay_bdev_name, latency_type, latency_us): 1201 """Update the latency value for a delay block device 1202 Args: 1203 delay_bdev_name: name of the delay bdev 1204 latency_type: 'one of: avg_read, avg_write, p99_read, p99_write. No other values accepted.' 1205 latency_us: 'new latency value.' 1206 Returns: 1207 True if successful, or a specific error otherwise. 1208 """ 1209 params = dict() 1210 params['delay_bdev_name'] = delay_bdev_name 1211 params['latency_type'] = latency_type 1212 params['latency_us'] = latency_us 1213 return client.call('bdev_delay_update_latency', params) 1214 1215 1216def bdev_error_delete(client, name): 1217 """Remove error bdev from the system. 1218 Args: 1219 bdev_name: name of error bdev to delete 1220 """ 1221 params = dict() 1222 params['name'] = name 1223 return client.call('bdev_error_delete', params) 1224 1225 1226def bdev_iscsi_set_options(client, timeout_sec=None): 1227 """Set options for the bdev iscsi. 1228 Args: 1229 timeout_sec: Timeout for command, in seconds, if 0, don't track timeout 1230 """ 1231 params = dict() 1232 if timeout_sec is not None: 1233 params['timeout_sec'] = timeout_sec 1234 return client.call('bdev_iscsi_set_options', params) 1235 1236 1237def bdev_iscsi_create(client, name, url, initiator_iqn): 1238 """Construct an iSCSI block device. 1239 Args: 1240 name: name of block device 1241 url: iSCSI URL 1242 initiator_iqn: IQN name to be used by initiator 1243 Returns: 1244 Name of created block device. 1245 """ 1246 params = dict() 1247 params['name'] = name 1248 params['url'] = url 1249 params['initiator_iqn'] = initiator_iqn 1250 return client.call('bdev_iscsi_create', params) 1251 1252 1253def bdev_iscsi_delete(client, name): 1254 """Remove iSCSI bdev from the system. 1255 Args: 1256 bdev_name: name of iSCSI bdev to delete 1257 """ 1258 params = dict() 1259 params['name'] = name 1260 return client.call('bdev_iscsi_delete', params) 1261 1262 1263def bdev_passthru_create(client, base_bdev_name, name, uuid=None): 1264 """Construct a pass-through block device. 1265 Args: 1266 base_bdev_name: name of the existing bdev 1267 name: name of block device 1268 uuid: UUID of block device (optional) 1269 Returns: 1270 Name of created block device. 1271 """ 1272 params = dict() 1273 params['base_bdev_name'] = base_bdev_name 1274 params['name'] = name 1275 if uuid is not None: 1276 params['uuid'] = uuid 1277 return client.call('bdev_passthru_create', params) 1278 1279 1280def bdev_passthru_delete(client, name): 1281 """Remove pass through bdev from the system. 1282 Args: 1283 name: name of pass through bdev to delete 1284 """ 1285 params = dict() 1286 params['name'] = name 1287 return client.call('bdev_passthru_delete', params) 1288 1289 1290def bdev_opal_create(client, nvme_ctrlr_name, nsid, locking_range_id, range_start, range_length, password): 1291 """Create opal virtual block devices from a base nvme bdev. 1292 Args: 1293 nvme_ctrlr_name: name of the nvme ctrlr 1294 nsid: namespace ID of nvme ctrlr 1295 locking_range_id: locking range ID corresponding to this virtual bdev 1296 range_start: start address of this locking range 1297 range_length: length of this locking range 1298 password: admin password of base nvme bdev 1299 Returns: 1300 Name of the new created block devices. 1301 """ 1302 params = dict() 1303 params['nvme_ctrlr_name'] = nvme_ctrlr_name 1304 params['nsid'] = nsid 1305 params['locking_range_id'] = locking_range_id 1306 params['range_start'] = range_start 1307 params['range_length'] = range_length 1308 params['password'] = password 1309 return client.call('bdev_opal_create', params) 1310 1311 1312def bdev_opal_get_info(client, bdev_name, password): 1313 """Get opal locking range info. 1314 Args: 1315 bdev_name: name of opal vbdev to get info 1316 password: admin password 1317 Returns: 1318 Locking range info. 1319 """ 1320 params = dict() 1321 params['bdev_name'] = bdev_name 1322 params['password'] = password 1323 return client.call('bdev_opal_get_info', params) 1324 1325 1326def bdev_opal_delete(client, bdev_name, password): 1327 """Delete opal virtual bdev from the system. 1328 Args: 1329 bdev_name: name of opal vbdev to delete 1330 password: admin password of base nvme bdev 1331 """ 1332 params = dict() 1333 params['bdev_name'] = bdev_name 1334 params['password'] = password 1335 return client.call('bdev_opal_delete', params) 1336 1337 1338def bdev_opal_new_user(client, bdev_name, admin_password, user_id, user_password): 1339 """Add a user to opal bdev who can set lock state for this bdev. 1340 Args: 1341 bdev_name: name of opal vbdev 1342 admin_password: admin password 1343 user_id: ID of the user who will be added to this opal bdev 1344 user_password: password set for this user 1345 """ 1346 params = dict() 1347 params['bdev_name'] = bdev_name 1348 params['admin_password'] = admin_password 1349 params['user_id'] = user_id 1350 params['user_password'] = user_password 1351 return client.call('bdev_opal_new_user', params) 1352 1353 1354def bdev_opal_set_lock_state(client, bdev_name, user_id, password, lock_state): 1355 """set lock state for an opal bdev. 1356 Args: 1357 bdev_name: name of opal vbdev 1358 user_id: ID of the user who will set lock state 1359 password: password of the user 1360 lock_state: lock state to set 1361 """ 1362 params = dict() 1363 params['bdev_name'] = bdev_name 1364 params['user_id'] = user_id 1365 params['password'] = password 1366 params['lock_state'] = lock_state 1367 return client.call('bdev_opal_set_lock_state', params) 1368 1369 1370def bdev_split_create(client, base_bdev, split_count, split_size_mb=None): 1371 """Create split block devices from a base bdev. 1372 Args: 1373 base_bdev: name of bdev to split 1374 split_count: number of split bdevs to create 1375 split_size_mb: size of each split volume in MiB (optional) 1376 Returns: 1377 List of created block devices. 1378 """ 1379 params = dict() 1380 params['base_bdev'] = base_bdev 1381 params['split_count'] = split_count 1382 if split_size_mb is not None: 1383 params['split_size_mb'] = split_size_mb 1384 return client.call('bdev_split_create', params) 1385 1386 1387def bdev_split_delete(client, base_bdev): 1388 """Delete split block devices. 1389 Args: 1390 base_bdev: name of previously split bdev 1391 """ 1392 params = dict() 1393 params['base_bdev'] = base_bdev 1394 return client.call('bdev_split_delete', params) 1395 1396 1397def bdev_ftl_create(client, name, base_bdev, cache, **kwargs): 1398 """Construct FTL bdev 1399 Args: 1400 name: name of the bdev 1401 base_bdev: name of the base bdev 1402 cache: name of the cache device 1403 kwargs: optional parameters 1404 """ 1405 params = dict() 1406 params['name'] = name 1407 params['base_bdev'] = base_bdev 1408 params['cache'] = cache 1409 for key, value in kwargs.items(): 1410 if value is not None: 1411 params[key] = value 1412 return client.call('bdev_ftl_create', params) 1413 1414 1415def bdev_ftl_load(client, name, base_bdev, cache, **kwargs): 1416 """Load FTL bdev 1417 Args: 1418 name: name of the bdev 1419 base_bdev: name of the base bdev 1420 cache: Name of the cache device 1421 kwargs: optional parameters 1422 """ 1423 params = dict() 1424 params['name'] = name 1425 params['base_bdev'] = base_bdev 1426 params['cache'] = cache 1427 for key, value in kwargs.items(): 1428 if value is not None: 1429 params[key] = value 1430 return client.call('bdev_ftl_load', params) 1431 1432 1433def bdev_ftl_unload(client, name, fast_shutdown=None): 1434 """Unload FTL bdev 1435 Args: 1436 name: name of the bdev 1437 fast_shutdown: When set FTL will minimize persisted data during deletion and rely on shared memory during next load 1438 """ 1439 params = dict() 1440 params['name'] = name 1441 if fast_shutdown is not None: 1442 params['fast_shutdown'] = fast_shutdown 1443 return client.call('bdev_ftl_unload', params) 1444 1445 1446def bdev_ftl_delete(client, name, fast_shutdown=None): 1447 """Delete FTL bdev 1448 Args: 1449 name: name of the bdev 1450 fast_shutdown: When set FTL will minimize persisted data during deletion and rely on shared memory during next load 1451 """ 1452 params = dict() 1453 params['name'] = name 1454 if fast_shutdown is not None: 1455 params['fast_shutdown'] = fast_shutdown 1456 return client.call('bdev_ftl_delete', params) 1457 1458 1459def bdev_ftl_unmap(client, name, lba, num_blocks): 1460 """FTL unmap 1461 Args: 1462 name: name of the bdev 1463 lba: starting lba to be unmapped 1464 num_blocks: number of blocks to unmap 1465 """ 1466 params = dict() 1467 params['name'] = name 1468 params['lba'] = lba 1469 params['num_blocks'] = num_blocks 1470 return client.call('bdev_ftl_unmap', params) 1471 1472 1473def bdev_ftl_get_stats(client, name): 1474 """get FTL stats 1475 Args: 1476 name: name of the bdev 1477 """ 1478 params = dict() 1479 params['name'] = name 1480 return client.call('bdev_ftl_get_stats', params) 1481 1482 1483def bdev_ftl_get_properties(client, name): 1484 """Get FTL properties 1485 Args: 1486 name: name of the bdev 1487 """ 1488 params = dict() 1489 params['name'] = name 1490 return client.call('bdev_ftl_get_properties', params) 1491 1492 1493def bdev_ftl_set_property(client, name, ftl_property, value): 1494 """Set FTL property 1495 Args: 1496 name: name of the bdev 1497 ftl_property: name of the property to be set 1498 value: The new value of the updated property 1499 """ 1500 params = dict() 1501 params['name'] = name 1502 params['ftl_property'] = ftl_property 1503 params['value'] = value 1504 return client.call('bdev_ftl_set_property', params) 1505 1506 1507def bdev_get_bdevs(client, name=None, timeout=None): 1508 """Get information about block devices. 1509 Args: 1510 name: bdev name to query (optional; if omitted, query all bdevs) 1511 timeout: time in ms to wait for the bdev with specified name to appear 1512 Returns: 1513 List of bdev information objects. 1514 """ 1515 params = dict() 1516 if name is not None: 1517 params['name'] = name 1518 if timeout is not None: 1519 params['timeout'] = timeout 1520 return client.call('bdev_get_bdevs', params) 1521 1522 1523def bdev_get_iostat(client, name=None, per_channel=None): 1524 """Get I/O statistics for block devices. 1525 Args: 1526 name: bdev name to query (optional; if omitted, query all bdevs) 1527 per_channel: display per channel IO stats for specified bdev 1528 Returns: 1529 I/O statistics for the requested block devices. 1530 """ 1531 params = dict() 1532 if name is not None: 1533 params['name'] = name 1534 if per_channel is not None: 1535 params['per_channel'] = per_channel 1536 return client.call('bdev_get_iostat', params) 1537 1538 1539def bdev_reset_iostat(client, name=None, mode=None): 1540 """Reset I/O statistics for block devices. 1541 Args: 1542 name: bdev name to reset (optional; if omitted, reset all bdevs) 1543 mode: mode to reset: all, maxmin (optional: if omitted, reset all fields) 1544 """ 1545 params = dict() 1546 if name is not None: 1547 params['name'] = name 1548 if mode is not None: 1549 params['mode'] = mode 1550 return client.call('bdev_reset_iostat', params) 1551 1552 1553def bdev_enable_histogram(client, name, enable, opc): 1554 """Control whether histogram is enabled for specified bdev. 1555 Args: 1556 name: name of bdev 1557 enable: Enable or disable histogram on specified device 1558 opc: name of io_type (optional) 1559 """ 1560 params = dict() 1561 params['name'] = name 1562 params['enable'] = enable 1563 if opc: 1564 params['opc'] = opc 1565 return client.call('bdev_enable_histogram', params) 1566 1567 1568def bdev_get_histogram(client, name): 1569 """Get histogram for specified bdev. 1570 Args: 1571 name: name of bdev 1572 """ 1573 params = dict() 1574 params['name'] = name 1575 return client.call('bdev_get_histogram', params) 1576 1577 1578def bdev_error_inject_error(client, name, io_type, error_type, num=None, 1579 queue_depth=None, corrupt_offset=None, corrupt_value=None): 1580 """Inject an error via an error bdev. 1581 Args: 1582 name: name of error bdev 1583 io_type: one of "clear", "read", "write", "unmap", "flush", or "all" 1584 error_type: one of "failure", "pending", "corrupt_data" or "nomem" 1585 num: number of commands to fail 1586 queue_depth: the queue depth at which to trigger the error 1587 corrupt_offset: offset in bytes to xor with corrupt_value 1588 corrupt_value: value for xor (1-255, 0 is invalid) 1589 """ 1590 params = dict() 1591 params['name'] = name 1592 params['io_type'] = io_type 1593 params['error_type'] = error_type 1594 if num is not None: 1595 params['num'] = num 1596 if queue_depth is not None: 1597 params['queue_depth'] = queue_depth 1598 if corrupt_offset is not None: 1599 params['corrupt_offset'] = corrupt_offset 1600 if corrupt_value is not None: 1601 params['corrupt_value'] = corrupt_value 1602 return client.call('bdev_error_inject_error', params) 1603 1604 1605def bdev_set_qd_sampling_period(client, name, period): 1606 """Enable queue depth tracking on a specified bdev. 1607 Args: 1608 name: name of a bdev on which to track queue depth. 1609 period: period (in microseconds) at which to update the queue depth reading. If set to 0, polling will be disabled. 1610 """ 1611 params = dict() 1612 params['name'] = name 1613 params['period'] = period 1614 return client.call('bdev_set_qd_sampling_period', params) 1615 1616 1617def bdev_set_qos_limit( 1618 client, 1619 name, 1620 rw_ios_per_sec=None, 1621 rw_mbytes_per_sec=None, 1622 r_mbytes_per_sec=None, 1623 w_mbytes_per_sec=None): 1624 """Set QoS rate limit on a block device. 1625 Args: 1626 name: name of block device 1627 rw_ios_per_sec: R/W IOs per second limit (>=1000, example: 20000). 0 means unlimited. 1628 rw_mbytes_per_sec: R/W megabytes per second limit (>=10, example: 100). 0 means unlimited. 1629 r_mbytes_per_sec: Read megabytes per second limit (>=10, example: 100). 0 means unlimited. 1630 w_mbytes_per_sec: Write megabytes per second limit (>=10, example: 100). 0 means unlimited. 1631 """ 1632 params = dict() 1633 params['name'] = name 1634 if rw_ios_per_sec is not None: 1635 params['rw_ios_per_sec'] = rw_ios_per_sec 1636 if rw_mbytes_per_sec is not None: 1637 params['rw_mbytes_per_sec'] = rw_mbytes_per_sec 1638 if r_mbytes_per_sec is not None: 1639 params['r_mbytes_per_sec'] = r_mbytes_per_sec 1640 if w_mbytes_per_sec is not None: 1641 params['w_mbytes_per_sec'] = w_mbytes_per_sec 1642 return client.call('bdev_set_qos_limit', params) 1643 1644 1645def bdev_nvme_apply_firmware(client, bdev_name, filename): 1646 """Download and commit firmware to NVMe device. 1647 Args: 1648 bdev_name: name of NVMe block device 1649 filename: filename of the firmware to download 1650 """ 1651 params = dict() 1652 params['bdev_name'] = bdev_name 1653 params['filename'] = filename 1654 return client.call('bdev_nvme_apply_firmware', params) 1655 1656 1657def bdev_nvme_get_transport_statistics(client): 1658 """Get bdev_nvme poll group transport statistics""" 1659 return client.call('bdev_nvme_get_transport_statistics') 1660 1661 1662def bdev_nvme_get_controller_health_info(client, name): 1663 """Display health log of the required NVMe bdev controller. 1664 Args: 1665 name: name of the required NVMe bdev controller 1666 Returns: 1667 Health log for the requested NVMe bdev controller. 1668 """ 1669 params = dict() 1670 params['name'] = name 1671 return client.call('bdev_nvme_get_controller_health_info', params) 1672 1673 1674def bdev_daos_create(client, num_blocks, block_size, pool, cont, name, oclass=None, uuid=None): 1675 """Construct DAOS block device. 1676 Args: 1677 num_blocks: size of block device in blocks 1678 block_size: block size of device; must be a power of 2 and at least 512 1679 pool: UUID of DAOS pool 1680 cont: UUID of DAOS container 1681 name: name of block device (also the name of the backend file on DAOS DFS) 1682 oclass: DAOS object class (optional) 1683 uuid: UUID of block device (optional) 1684 Returns: 1685 Name of created block device. 1686 """ 1687 params = dict() 1688 params['num_blocks'] = num_blocks 1689 params['block_size'] = block_size 1690 params['pool'] = pool 1691 params['cont'] = cont 1692 params['name'] = name 1693 if oclass is not None: 1694 params['oclass'] = oclass 1695 if uuid is not None: 1696 params['uuid'] = uuid 1697 return client.call('bdev_daos_create', params) 1698 1699 1700def bdev_daos_delete(client, name): 1701 """Delete DAOS block device. 1702 Args: 1703 bdev_name: name of DAOS bdev to delete 1704 """ 1705 params = dict() 1706 params['name'] = name 1707 return client.call('bdev_daos_delete', params) 1708 1709 1710def bdev_daos_resize(client, name, new_size): 1711 """Resize DAOS bdev in the system. 1712 Args: 1713 name: name of DAOS bdev to resize 1714 new_size: new bdev size of resize operation. The unit is MiB 1715 """ 1716 params = dict() 1717 params['name'] = name 1718 params['new_size'] = new_size 1719 return client.call('bdev_daos_resize', params) 1720 1721 1722def bdev_nvme_start_mdns_discovery(client, name, svcname, hostnqn=None): 1723 """Start discovery with mDNS 1724 Args: 1725 name: bdev name prefix; "n" + unique seqno + namespace ID will be appended to create unique names 1726 svcname: service to discover ("_nvme-disc._tcp") 1727 hostnqn: NQN to connect from (optional) 1728 """ 1729 params = dict() 1730 params['name'] = name 1731 params['svcname'] = svcname 1732 if hostnqn is not None: 1733 params['hostnqn'] = hostnqn 1734 return client.call('bdev_nvme_start_mdns_discovery', params) 1735 1736 1737def bdev_nvme_stop_mdns_discovery(client, name): 1738 """Stop a previously started mdns discovery service 1739 Args: 1740 name: name of the discovery service to stop 1741 """ 1742 params = dict() 1743 params['name'] = name 1744 return client.call('bdev_nvme_stop_mdns_discovery', params) 1745 1746 1747def bdev_nvme_get_mdns_discovery_info(client): 1748 """Get information about the automatic mdns discovery 1749 """ 1750 return client.call('bdev_nvme_get_mdns_discovery_info') 1751