drivers/md/dm-vdo/action-manager.c

Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/action-manager.c

File Facts

System
Linux kernel
Corpus path
drivers/md/dm-vdo/action-manager.c
Extension
.c
Size
14059 bytes
Lines
389
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

struct action {
	bool in_use;
	const struct admin_state_code *operation;
	vdo_action_preamble_fn preamble;
	vdo_zone_action_fn zone_action;
	vdo_action_conclusion_fn conclusion;
	struct vdo_completion *parent;
	void *context;
	struct action *next;
};

/**
 * struct action_manager - Definition of an action manager.
 * @completion: The completion for performing actions.
 * @state: The state of this action manager.
 * @actions: The two action slots.
 * @current_action: The current action slot.
 * @zones: The number of zones in which an action is to be applied.
 * @scheduler: A function to schedule a default next action.
 * @get_zone_thread_id: A function to get the id of the thread on which to apply an action to a
 *                      zone.
 * @initiator_thread_id: The ID of the thread on which actions may be initiated.
 * @context: Opaque data associated with this action manager.
 * @acting_zone: The zone currently being acted upon.
 */
struct action_manager {
	struct vdo_completion completion;
	struct admin_state state;
	struct action actions[2];
	struct action *current_action;
	zone_count_t zones;
	vdo_action_scheduler_fn scheduler;
	vdo_zone_thread_getter_fn get_zone_thread_id;
	thread_id_t initiator_thread_id;
	void *context;
	zone_count_t acting_zone;
};

static inline struct action_manager *as_action_manager(struct vdo_completion *completion)
{
	vdo_assert_completion_type(completion, VDO_ACTION_COMPLETION);
	return container_of(completion, struct action_manager, completion);
}

/* Implements vdo_action_scheduler_fn. */
static bool no_default_action(void *context __always_unused)
{
	return false;
}

/* Implements vdo_action_preamble_fn. */
static void no_preamble(void *context __always_unused, struct vdo_completion *completion)
{
	vdo_finish_completion(completion);
}

/* Implements vdo_action_conclusion_fn. */
static int no_conclusion(void *context __always_unused)
{
	return VDO_SUCCESS;
}

/**
 * vdo_make_action_manager() - Make an action manager.
 * @zones: The number of zones to which actions will be applied.
 * @get_zone_thread_id: A function to get the thread id associated with a zone.
 * @initiator_thread_id: The thread on which actions may initiated.
 * @context: The object which holds the per-zone context for the action.
 * @scheduler: A function to schedule a next action after an action concludes if there is no
 *             pending action (may be NULL).
 * @vdo: The vdo used to initialize completions.
 * @manager_ptr: A pointer to hold the new action manager.
 *
 * Return: VDO_SUCCESS or an error code.
 */
int vdo_make_action_manager(zone_count_t zones,
			    vdo_zone_thread_getter_fn get_zone_thread_id,
			    thread_id_t initiator_thread_id, void *context,
			    vdo_action_scheduler_fn scheduler, struct vdo *vdo,
			    struct action_manager **manager_ptr)
{
	struct action_manager *manager;
	int result = vdo_allocate(1, __func__, &manager);

	if (result != VDO_SUCCESS)
		return result;

	*manager = (struct action_manager) {
		.zones = zones,
		.scheduler =

Annotation

Implementation Notes