drivers/md/dm-vdo/admin-state.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/admin-state.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/admin-state.c- Extension
.c- Size
- 18299 bytes
- Lines
- 532
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
admin-state.hlogger.hmemory-alloc.hpermassert.hcompletion.htypes.h
Detected Declarations
function get_next_statefunction vdo_finish_operationfunction begin_operationfunction start_operationfunction check_codefunction assert_vdo_drain_operationfunction vdo_start_drainingfunction vdo_finish_drainingfunction vdo_finish_draining_with_resultfunction vdo_assert_load_operationfunction vdo_start_loadingfunction vdo_finish_loadingfunction vdo_finish_loading_with_resultfunction assert_vdo_resume_operationfunction vdo_start_resumingfunction vdo_finish_resumingfunction vdo_finish_resuming_with_resultfunction vdo_resume_if_quiescentfunction vdo_start_operationfunction vdo_start_operation_with_waiter
Annotated Snippet
if (initiator != NULL) {
state->starting = true;
initiator(state);
state->starting = false;
if (state->complete)
vdo_finish_operation(state, VDO_SUCCESS);
}
return VDO_SUCCESS;
}
if (waiter != NULL)
vdo_continue_completion(waiter, result);
return result;
}
/**
* start_operation() - Start an operation if it may be started given the current state.
* @state: The current admin state.
* @operation: The operation to be started.
* @waiter: A completion to notify when the operation is complete; may be NULL.
* @initiator: The vdo_admin_initiator_fn to call if the operation may begin; may be NULL.
*
* Return: true if the operation was started.
*/
static inline bool __must_check start_operation(struct admin_state *state,
const struct admin_state_code *operation,
struct vdo_completion *waiter,
vdo_admin_initiator_fn initiator)
{
return (begin_operation(state, operation, waiter, initiator) == VDO_SUCCESS);
}
/**
* check_code() - Check the result of a state validation.
* @valid: True if the code is of an appropriate type.
* @code: The code which failed to be of the correct type.
* @what: What the code failed to be, for logging.
* @waiter: The completion to notify of the error; may be NULL.
*
* If the result failed, log an invalid state error and, if there is a waiter, notify it.
*
* Return: The result of the check.
*/
static bool check_code(bool valid, const struct admin_state_code *code, const char *what,
struct vdo_completion *waiter)
{
int result;
if (valid)
return true;
result = vdo_log_error_strerror(VDO_INVALID_ADMIN_STATE,
"%s is not a %s", code->name, what);
if (waiter != NULL)
vdo_continue_completion(waiter, result);
return false;
}
/**
* assert_vdo_drain_operation() - Check that an operation is a drain.
* @operation: The operation to check.
* @waiter: The completion to finish with an error if the operation is not a drain.
*
* Return: true if the specified operation is a drain.
*/
static bool __must_check assert_vdo_drain_operation(const struct admin_state_code *operation,
struct vdo_completion *waiter)
{
return check_code(operation->draining, operation, "drain operation", waiter);
}
/**
* vdo_start_draining() - Initiate a drain operation if the current state permits it.
* @state: The current admin state.
* @operation: The type of drain to initiate.
* @waiter: The completion to notify when the drain is complete.
* @initiator: The vdo_admin_initiator_fn to call if the operation may begin; may be NULL.
*
* Return: true if the drain was initiated, if not the waiter will be notified.
*/
bool vdo_start_draining(struct admin_state *state,
const struct admin_state_code *operation,
struct vdo_completion *waiter, vdo_admin_initiator_fn initiator)
{
const struct admin_state_code *code = vdo_get_admin_state_code(state);
if (!assert_vdo_drain_operation(operation, waiter))
Annotation
- Immediate include surface: `admin-state.h`, `logger.h`, `memory-alloc.h`, `permassert.h`, `completion.h`, `types.h`.
- Detected declarations: `function get_next_state`, `function vdo_finish_operation`, `function begin_operation`, `function start_operation`, `function check_code`, `function assert_vdo_drain_operation`, `function vdo_start_draining`, `function vdo_finish_draining`, `function vdo_finish_draining_with_result`, `function vdo_assert_load_operation`.
- Atlas domain: Driver Families / drivers/md.
- Implementation status: source implementation candidate.
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.