drivers/md/dm-vdo/vdo.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/vdo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/vdo.c- Extension
.c- Size
- 58062 bytes
- Lines
- 1858
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
vdo.hlinux/completion.hlinux/device-mapper.hlinux/lz4.hlinux/mutex.hlinux/spinlock.hlinux/string.hlinux/types.hlinux/uuid.hlogger.hmemory-alloc.hpermassert.hstring-utils.hblock-map.hcompletion.hdata-vio.hdedupe.hencodings.hfunnel-workqueue.hio-submitter.hlogical-zone.hpacker.hphysical-zone.hrecovery-journal.hslab-depot.hstatistics.hstatus-codes.htime-utils.hvio.h
Detected Declarations
struct sync_completionstruct device_registryfunction vdo_initialize_device_registry_oncefunction vdo_is_equalfunction filter_vdos_lockedfunction list_for_each_entryfunction vdo_find_matchingfunction start_vdo_request_queuefunction finish_vdo_request_queuefunction uninitialize_thread_configfunction assign_thread_idsfunction initialize_thread_configfunction initialize_geometry_blockfunction initialize_super_blockfunction get_zone_thread_namefunction get_thread_namefunction vdo_make_threadfunction register_vdofunction vdo_formatfunction initialize_vdofunction vdo_makefunction finish_vdofunction free_listenersfunction uninitialize_geometry_blockfunction uninitialize_super_blockfunction unregister_vdofunction vdo_destroyfunction finish_reading_super_blockfunction handle_super_block_read_errorfunction read_super_block_endiofunction vdo_load_super_blockfunction vdo_get_backing_devicefunction vdo_get_device_namefunction vdo_synchronous_flushfunction vdo_get_statefunction vdo_set_statefunction vdo_get_admin_statefunction record_vdofunction clear_partitionfunction vdo_clear_layoutfunction continue_parentfunction handle_write_endiofunction handle_geometry_block_save_errorfunction vdo_save_geometry_blockfunction handle_super_block_save_errorfunction vdo_save_super_blockfunction vdo_save_componentsfunction vdo_register_read_only_listener
Annotated Snippet
struct sync_completion {
struct vdo_completion vdo_completion;
struct completion completion;
};
/* A linked list is adequate for the small number of entries we expect. */
struct device_registry {
struct list_head links;
/* TODO: Convert to rcu per kernel recommendation. */
rwlock_t lock;
};
static struct device_registry registry;
/**
* vdo_initialize_device_registry_once() - Initialize the necessary structures for the device
* registry.
*/
void vdo_initialize_device_registry_once(void)
{
INIT_LIST_HEAD(®istry.links);
rwlock_init(®istry.lock);
}
/** vdo_is_equal() - Implements vdo_filter_fn. */
static bool vdo_is_equal(struct vdo *vdo, const void *context)
{
return (vdo == context);
}
/**
* filter_vdos_locked() - Find a vdo in the registry if it exists there.
* @filter: The filter function to apply to devices.
* @context: A bit of context to provide the filter.
*
* Context: Must be called holding the lock.
*
* Return: the vdo object found, if any.
*/
static struct vdo * __must_check filter_vdos_locked(vdo_filter_fn filter,
const void *context)
{
struct vdo *vdo;
list_for_each_entry(vdo, ®istry.links, registration) {
if (filter(vdo, context))
return vdo;
}
return NULL;
}
/**
* vdo_find_matching() - Find and return the first (if any) vdo matching a given filter function.
* @filter: The filter function to apply to vdos.
* @context: A bit of context to provide the filter.
*/
struct vdo *vdo_find_matching(vdo_filter_fn filter, const void *context)
{
struct vdo *vdo;
read_lock(®istry.lock);
vdo = filter_vdos_locked(filter, context);
read_unlock(®istry.lock);
return vdo;
}
static void start_vdo_request_queue(void *ptr)
{
struct vdo_thread *thread = vdo_get_work_queue_owner(vdo_get_current_work_queue());
vdo_register_allocating_thread(&thread->allocating_thread,
&thread->vdo->allocations_allowed);
}
static void finish_vdo_request_queue(void *ptr)
{
vdo_unregister_allocating_thread();
}
static const struct vdo_work_queue_type default_queue_type = {
.start = start_vdo_request_queue,
.finish = finish_vdo_request_queue,
.max_priority = VDO_DEFAULT_Q_MAX_PRIORITY,
.default_priority = VDO_DEFAULT_Q_COMPLETION_PRIORITY,
};
static const struct vdo_work_queue_type bio_ack_q_type = {
.start = NULL,
Annotation
- Immediate include surface: `vdo.h`, `linux/completion.h`, `linux/device-mapper.h`, `linux/lz4.h`, `linux/mutex.h`, `linux/spinlock.h`, `linux/string.h`, `linux/types.h`.
- Detected declarations: `struct sync_completion`, `struct device_registry`, `function vdo_initialize_device_registry_once`, `function vdo_is_equal`, `function filter_vdos_locked`, `function list_for_each_entry`, `function vdo_find_matching`, `function start_vdo_request_queue`, `function finish_vdo_request_queue`, `function uninitialize_thread_config`.
- 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.