VDO¶
This section documents the Virtual Data Optimizer (VDO) functionality, which provides block-level deduplication and compression.
sts.vdo
¶
VDO device management.
This module provides functionality for managing VDO devices: - VDO volume creation/removal - Deduplication and compression - Device statistics
VDO (Virtual Data Optimizer) is a kernel module that provides inline data reduction through: - Deduplication: Eliminates duplicate blocks - Compression: Reduces block size using LZ4 algorithm - Thin provisioning: Allocates space on demand
VdoCalculateSize
dataclass
¶
VDO space and memory usage calculator.
This class encapsulates the vdocalculatesize command for calculating VDO space and memory requirements. It helps determine: - Physical storage requirements - Memory usage for deduplication index - Block map cache sizing
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logical_size
|
str | None
|
VDO logical size in MB (e.g. '2048' for 2GB) |
None
|
physical_size
|
str | None
|
VDO physical size in MB (e.g. '600' for 600MB) |
None
|
slab_bits
|
int | None
|
Slab size as power of 2 (13-23, default 19 = 2GB) |
None
|
slab_size
|
str | None
|
Slab size in MB (mutually exclusive with slab_bits) |
None
|
block_map_cache_size
|
int | None
|
Block map cache size in 4K blocks |
None
|
index_memory_size
|
float | None
|
Memory for deduplication index in GB |
None
|
sparse_index
|
bool
|
Use sparse index for deduplication |
False
|
Note
The slab_bits and slab_size parameters are mutually exclusive. Use slab_bits for power-of-2 sizes, or slab_size for direct MB values.
Example
calc = VdoCalculateSize(physical_size='600G', logical_size='2T', slab_bits=22, index_memory_size=1)
result = calc.calculate()
Source code in sts_libs/src/sts/vdo.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
calculate()
¶
Calculate VDO space and memory usage.
Runs vdocalculatesize with the configured options and returns the command result.
Returns:
| Type | Description |
|---|---|
CommandResult
|
CommandResult with rc, stdout, and stderr |
Example
calc = VdoCalculateSize(
physical_size='600G', logical_size='2T', slab_bits=22, index_memory_size=1, block_map_cache_size=32768
)
result = calc.calculate()
if result.succeeded:
print(result.stdout)
Source code in sts_libs/src/sts/vdo.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
VdoDevice
dataclass
¶
Bases: LogicalVolume
VDO device.
This class extends LogicalVolume to provide VDO-specific functionality: - Inline deduplication - Inline compression - Configurable write policy - Statistics reporting
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Device name |
None
|
path
|
Path | str | None
|
Device path |
None
|
size
|
int | None
|
Device size in bytes |
None
|
model
|
str | None
|
Device model (optional) |
None
|
yes
|
bool
|
Automatically answer yes to prompts |
True
|
force
|
bool
|
Force operations without confirmation |
False
|
vg
|
str | None
|
Volume group name |
None
|
deduplication
|
bool
|
Enable deduplication |
True
|
compression
|
bool
|
Enable compression |
True
|
write_policy
|
WritePolicy
|
Write policy (sync/async) |
'sync'
|
slab_size
|
str | None
|
Slab size (e.g. '2G', '512M') |
None
|
Example
device = VdoDevice.create('vdo0', vg='vg0', size='1G')
device.exists
True
Source code in sts_libs/src/sts/vdo.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | |
create(*args, **options)
¶
Create VDO volume.
Creates a new VDO volume with specified options: - Compression and deduplication state - Write policy (sync/async) - Slab size for memory allocation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**options
|
str
|
VDO parameters (see VdoOptions) |
{}
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Example
device = VdoDevice('vdo0', vg='vg0')
device.create(size='1G')
True
Source code in sts_libs/src/sts/vdo.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |
get_stats(*, human_readable=True)
¶
Get VDO statistics.
Retrieves statistics about: - Space usage (physical vs logical) - Deduplication ratio - Compression ratio - Block allocation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
human_readable
|
bool
|
Use human readable sizes (e.g. '1.0G' vs bytes) |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, str] | None
|
Dictionary of statistics or None if error |
Example
device = VdoDevice('vdo0', vg='vg0')
stats = device.get_stats()
stats['physical_blocks'] # Actually used space
'1.0G'
stats['data_blocks'] # Space before optimization
'500M'
Source code in sts_libs/src/sts/vdo.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | |
remove(*args, **options)
¶
Remove VDO volume.
Removes the VDO volume and its metadata. All data will be lost.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**options
|
str
|
VDO parameters (see VdoOptions) |
{}
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Example
device = VdoDevice('vdo0', vg='vg0')
device.remove()
True
Source code in sts_libs/src/sts/vdo.py
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | |
set_compression(*, enabled=True)
¶
Set compression state.
Enables or disables inline compression: - When enabled, blocks are compressed using LZ4 - When disabled, blocks are stored uncompressed
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Enable or disable compression |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Example
device = VdoDevice('vdo0', vg='vg0')
device.set_compression(enabled=False)
True
Source code in sts_libs/src/sts/vdo.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | |
set_deduplication(*, enabled=True)
¶
Set deduplication state.
Enables or disables inline deduplication: - When enabled, duplicate blocks are detected and eliminated - When disabled, all blocks are stored as-is
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Enable or disable deduplication |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Example
device = VdoDevice('vdo0', vg='vg0')
device.set_deduplication(enabled=False)
True
Source code in sts_libs/src/sts/vdo.py
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | |
set_write_policy(policy)
¶
Set write policy.
Changes how writes are acknowledged: - sync: Wait for physical write (safer but slower) - async: Acknowledge after memory write (faster but risk data loss)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
WritePolicy
|
Write policy (sync/async) |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Example
device = VdoDevice('vdo0', vg='vg0')
device.set_write_policy('async')
True
Source code in sts_libs/src/sts/vdo.py
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | |
VdoFormat
dataclass
¶
VDO format utility.
This class encapsulates the vdoformat command for formatting block devices as VDO volumes. It handles: - Low-level VDO device formatting - Logical size configuration - Slab size configuration via slab bits - UDS index memory allocation - Sparse index configuration
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
str | Path
|
Block device path to format |
required |
logical_size
|
str | None
|
Logical (provisioned) size (e.g. '1G', '500M') |
None
|
slab_bits
|
int | None
|
Slab size as power of 2 (13-23, default 19 = 2GB) |
None
|
uds_memory_size
|
float | None
|
Memory for deduplication index in GB |
None
|
uds_sparse
|
bool
|
Use sparse index for deduplication |
False
|
force
|
bool
|
Format even if VDO already exists |
False
|
verbose
|
bool
|
Show detailed formatting information |
False
|
Note
The slab_bits parameter controls the slab size: - 13 = 32 MB (minimum) - 19 = 2 GB (default) - 23 = 32 GB (maximum)
Maximum 8192 slabs per volume, so slab size determines the maximum physical volume size.
Example
fmt = VdoFormat('/dev/sda1', logical_size='10G')
fmt.format()
True
Source code in sts_libs/src/sts/vdo.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
slab_size_mb: int
property
¶
Get slab size in megabytes.
Calculates the actual slab size based on slab_bits: slab_size = 2^slab_bits * 4KB
Returns:
| Type | Description |
|---|---|
int
|
Slab size in megabytes |
Example
fmt = VdoFormat('/dev/sda1', slab_bits=19)
fmt.slab_size_mb
2048
__post_init__()
¶
Convert device to Path after initialization.
Source code in sts_libs/src/sts/vdo.py
134 135 136 | |
format()
¶
Format device as VDO volume.
Performs low-level VDO formatting on the device. The device will not be formatted if it already contains a VDO, unless force=True was set.
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Example
fmt = VdoFormat('/dev/sda1', logical_size='10G')
fmt.format()
True
# Force reformat existing VDO
fmt = VdoFormat('/dev/sda1', force=True)
fmt.format()
True
Source code in sts_libs/src/sts/vdo.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
get_version()
staticmethod
¶
Get vdoformat version.
Returns:
| Type | Description |
|---|---|
str | None
|
Version string or None if command failed |
Example
VdoFormat.get_version()
'8.2.0.2'
Source code in sts_libs/src/sts/vdo.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
VdoOptions
¶
Bases: TypedDict
VDO volume options.
Common options: - size: Volume size (e.g. '1G', '500M') - extents: Volume size in LVM extents - type: Volume type (must be 'vdo') - compression: Enable compression (y/n) - deduplication: Enable deduplication (y/n) - vdowritepolicy: Write policy (sync/async) - vdoslabsize: Slab size - allocation unit (e.g. '2G', '512M')
The slab size affects memory usage and performance: - Larger slabs = Better performance but more memory - Smaller slabs = Less memory but lower performance
Source code in sts_libs/src/sts/vdo.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
VdoState
¶
Bases: str, Enum
VDO feature state.
Used to enable/disable features like compression and deduplication.
Source code in sts_libs/src/sts/vdo.py
44 45 46 47 48 49 50 51 | |
get_minimum_slab_size(device, *, use_default=True)
¶
Get minimum slab size for device.
Calculates the minimum slab size based on device size: 1. Get device size 2. Calculate minimum size that allows MAX_SLABS 3. Ensure size is at least MIN_SLAB_SIZE_MB 4. Optionally use default if calculated size is smaller
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
str | Path
|
Device path |
required |
use_default
|
bool
|
Return default size if calculated size is smaller |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Slab size string (e.g. '2G') |
Example
get_minimum_slab_size('/dev/sda')
'2G'
get_minimum_slab_size('/dev/sdb', use_default=False)
'512M'
Source code in sts_libs/src/sts/vdo.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |