drivers/md/dm-vdo/thread-registry.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/thread-registry.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/thread-registry.c- Extension
.c- Size
- 2287 bytes
- Lines
- 94
- 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
thread-registry.hasm/current.hlinux/rculist.hpermassert.h
Detected Declarations
function vdo_initialize_thread_registryfunction vdo_register_threadfunction vdo_unregister_thread
Annotated Snippet
if (thread->task == current) {
/* There should be no existing entry. */
list_del_rcu(&thread->links);
found_it = true;
break;
}
}
list_add_tail_rcu(&new_thread->links, ®istry->links);
spin_unlock(®istry->lock);
VDO_ASSERT_LOG_ONLY(!found_it, "new thread not already in registry");
if (found_it) {
/* Ensure no RCU iterators see it before re-initializing. */
synchronize_rcu();
INIT_LIST_HEAD(&thread->links);
}
}
void vdo_unregister_thread(struct thread_registry *registry)
{
struct registered_thread *thread;
bool found_it = false;
spin_lock(®istry->lock);
list_for_each_entry(thread, ®istry->links, links) {
if (thread->task == current) {
list_del_rcu(&thread->links);
found_it = true;
break;
}
}
spin_unlock(®istry->lock);
VDO_ASSERT_LOG_ONLY(found_it, "thread found in registry");
if (found_it) {
/* Ensure no RCU iterators see it before re-initializing. */
synchronize_rcu();
INIT_LIST_HEAD(&thread->links);
}
}
const void *vdo_lookup_thread(struct thread_registry *registry)
{
struct registered_thread *thread;
const void *result = NULL;
rcu_read_lock();
list_for_each_entry_rcu(thread, ®istry->links, links) {
if (thread->task == current) {
result = thread->pointer;
break;
}
}
rcu_read_unlock();
return result;
}
Annotation
- Immediate include surface: `thread-registry.h`, `asm/current.h`, `linux/rculist.h`, `permassert.h`.
- Detected declarations: `function vdo_initialize_thread_registry`, `function vdo_register_thread`, `function vdo_unregister_thread`.
- 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.