Skip to main content

Module virtio_block

Module virtio_block 

Source
Expand description

VirtIO Block Device driver

Provides disk I/O via VirtIO-blk protocol for QEMU/KVM environments. Implements the BlockDevice trait for integration with filesystem layers.

Reference: VirtIO spec v1.2, Section 5.2 (Block Device)

Modulesยง

features
VirtIO block device features

Structsยง

BlockConfig ๐Ÿ”’
Block device configuration space
BlockRequestHeader
VirtIO block request header
BouncePool ๐Ÿ”’
Pre-allocated DMA buffer used for all data transfers.
MetaPool ๐Ÿ”’
Pre-allocated metadata frame: [Header (16 B)] + padding + [Status (1 B)]. Reused for every request : never alloc/freed per I/O.
VirtioBlockDevice
VirtIO Block Device driver

Enumsยง

BlockError
BlockStatus
VirtIO block request status
RequestType
VirtIO block request types

Constantsยง

BOUNCE_POOL_SIZE ๐Ÿ”’
Size of the pre-allocated bounce buffer pool (64 KB = 128 sectors). Requests up to this size avoid per-I/O buddy allocator calls.
SECTOR_SIZE
Block device sector size

Staticsยง

VIRTIO_BLK_DONE ๐Ÿ”’
Atomic flag set by the IRQ handler to signal request completion.
VIRTIO_BLK_ERROR ๐Ÿ”’
Atomic flag set by the IRQ handler on error.
VIRTIO_BLK_WQ ๐Ÿ”’
WaitQueue used for IRQ-driven completion (see handle_interrupt / do_request).
VIRTIO_BLOCK_IRQ ๐Ÿ”’
VirtIO block IRQ line (will be set during init)
VIRTIO_BLOCK_PTR ๐Ÿ”’
Global VirtIO block device reference (leaked Box, never freed).

Traitsยง

BlockDevice
Block device trait (implemented by VirtIO-blk and AHCI drivers)

Functionsยง

get_device
Get the global VirtIO block device
get_irq
Get the VirtIO block IRQ line
handle_interrupt
Handle VirtIO block device interrupt
init
Initialize VirtIO block device