drivers/md/dm-vdo/vio.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/vio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/vio.c- Extension
.c- Size
- 13989 bytes
- Lines
- 513
- Domain
- Driver Families
- Bucket
- drivers/md
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vio.hlinux/bio.hlinux/blkdev.hlinux/kernel.hlinux/ratelimit.hlogger.hmemory-alloc.hpermassert.hconstants.hio-submitter.hvdo.h
Detected Declarations
struct vio_poolfunction pbn_from_vio_biofunction create_multi_block_biofunction vdo_create_biofunction vdo_free_biofunction allocate_vio_componentsfunction create_multi_block_metadata_viofunction free_vio_componentsfunction free_viofunction vdo_set_bio_propertiesfunction vio_reset_biofunction vio_reset_bio_with_sizefunction update_vio_error_statsfunction vio_record_metadata_io_errorfunction make_vio_poolfunction free_vio_poolfunction list_for_each_entry_safefunction is_vio_pool_busyfunction acquire_vio_from_poolfunction return_vio_to_poolfunction vdo_count_biosfunction count_all_bios_completedfunction vdo_count_completed_bios
Annotated Snippet
struct vio_pool {
/* The number of objects managed by the pool */
size_t size;
/* The list of objects which are available */
struct list_head available;
/* The queue of requestors waiting for objects from the pool */
struct vdo_wait_queue waiting;
/* The number of objects currently in use */
size_t busy_count;
/* The list of objects which are in use */
struct list_head busy;
/* The ID of the thread on which this pool may be used */
thread_id_t thread_id;
/* The buffer backing the pool's vios */
char *buffer;
/* The pool entries */
struct pooled_vio vios[];
};
physical_block_number_t pbn_from_vio_bio(struct bio *bio)
{
struct vio *vio = bio->bi_private;
struct vdo *vdo = vio->completion.vdo;
physical_block_number_t pbn = bio->bi_iter.bi_sector / VDO_SECTORS_PER_BLOCK;
return ((pbn == VDO_GEOMETRY_BLOCK_LOCATION) ? pbn : pbn + vdo->geometry.bio_offset);
}
static int create_multi_block_bio(block_count_t size, struct bio **bio_ptr)
{
struct bio *bio = NULL;
int result;
result = vdo_allocate_memory(sizeof(struct bio) + sizeof(struct bio_vec) * (size + 1),
__alignof__(struct bio), "bio", &bio);
if (result != VDO_SUCCESS)
return result;
*bio_ptr = bio;
return VDO_SUCCESS;
}
int vdo_create_bio(struct bio **bio_ptr)
{
return create_multi_block_bio(1, bio_ptr);
}
void vdo_free_bio(struct bio *bio)
{
if (bio == NULL)
return;
bio_uninit(bio);
vdo_free(vdo_forget(bio));
}
int allocate_vio_components(struct vdo *vdo, enum vio_type vio_type,
enum vio_priority priority, void *parent,
unsigned int block_count, char *data, struct vio *vio)
{
struct bio *bio;
int result;
result = VDO_ASSERT(block_count <= MAX_BLOCKS_PER_VIO,
"block count %u does not exceed maximum %u", block_count,
MAX_BLOCKS_PER_VIO);
if (result != VDO_SUCCESS)
return result;
result = VDO_ASSERT(((vio_type != VIO_TYPE_UNINITIALIZED) && (vio_type != VIO_TYPE_DATA)),
"%d is a metadata type", vio_type);
if (result != VDO_SUCCESS)
return result;
result = create_multi_block_bio(block_count, &bio);
if (result != VDO_SUCCESS)
return result;
initialize_vio(vio, bio, block_count, vio_type, priority, vdo);
vio->completion.parent = parent;
vio->data = data;
return VDO_SUCCESS;
}
/**
* create_multi_block_metadata_vio() - Create a vio.
* @vdo: The vdo on which the vio will operate.
* @vio_type: The type of vio to create.
* @priority: The relative priority to assign to the vio.
* @parent: The parent of the vio.
Annotation
- Immediate include surface: `vio.h`, `linux/bio.h`, `linux/blkdev.h`, `linux/kernel.h`, `linux/ratelimit.h`, `logger.h`, `memory-alloc.h`, `permassert.h`.
- Detected declarations: `struct vio_pool`, `function pbn_from_vio_bio`, `function create_multi_block_bio`, `function vdo_create_bio`, `function vdo_free_bio`, `function allocate_vio_components`, `function create_multi_block_metadata_vio`, `function free_vio_components`, `function free_vio`, `function vdo_set_bio_properties`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.