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.

Dependency Surface

Detected Declarations

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, &registry->links);
	spin_unlock(&registry->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(&registry->lock);
	list_for_each_entry(thread, &registry->links, links) {
		if (thread->task == current) {
			list_del_rcu(&thread->links);
			found_it = true;
			break;
		}
	}
	spin_unlock(&registry->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, &registry->links, links) {
		if (thread->task == current) {
			result = thread->pointer;
			break;
		}
	}
	rcu_read_unlock();

	return result;
}

Annotation

Implementation Notes