drivers/md/dm-vdo/status-codes.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/status-codes.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/status-codes.c- Extension
.c- Size
- 3462 bytes
- Lines
- 97
- 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
status-codes.herrors.hlogger.hpermassert.hthread-utils.h
Detected Declarations
function vdo_register_status_codesfunction consume
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2023 Red Hat
*/
#include "status-codes.h"
#include "errors.h"
#include "logger.h"
#include "permassert.h"
#include "thread-utils.h"
const struct error_info vdo_status_list[] = {
{ "VDO_NOT_IMPLEMENTED", "Not implemented" },
{ "VDO_OUT_OF_RANGE", "Out of range" },
{ "VDO_REF_COUNT_INVALID", "Reference count would become invalid" },
{ "VDO_NO_SPACE", "Out of space" },
{ "VDO_BAD_CONFIGURATION", "Bad configuration option" },
{ "VDO_COMPONENT_BUSY", "Prior operation still in progress" },
{ "VDO_BAD_PAGE", "Corrupt or incorrect page" },
{ "VDO_UNSUPPORTED_VERSION", "Unsupported component version" },
{ "VDO_INCORRECT_COMPONENT", "Component id mismatch in decoder" },
{ "VDO_PARAMETER_MISMATCH", "Parameters have conflicting values" },
{ "VDO_UNKNOWN_PARTITION", "No partition exists with a given id" },
{ "VDO_PARTITION_EXISTS", "A partition already exists with a given id" },
{ "VDO_INCREMENT_TOO_SMALL", "Physical block growth of too few blocks" },
{ "VDO_CHECKSUM_MISMATCH", "Incorrect checksum" },
{ "VDO_LOCK_ERROR", "A lock is held incorrectly" },
{ "VDO_READ_ONLY", "The device is in read-only mode" },
{ "VDO_SHUTTING_DOWN", "The device is shutting down" },
{ "VDO_CORRUPT_JOURNAL", "Recovery journal corrupted" },
{ "VDO_TOO_MANY_SLABS", "Exceeds maximum number of slabs supported" },
{ "VDO_INVALID_FRAGMENT", "Compressed block fragment is invalid" },
{ "VDO_RETRY_AFTER_REBUILD", "Retry operation after rebuilding finishes" },
{ "VDO_BAD_MAPPING", "Invalid page mapping" },
{ "VDO_BIO_CREATION_FAILED", "Bio creation failed" },
{ "VDO_BAD_MAGIC", "Bad magic number" },
{ "VDO_BAD_NONCE", "Bad nonce" },
{ "VDO_JOURNAL_OVERFLOW", "Journal sequence number overflow" },
{ "VDO_INVALID_ADMIN_STATE", "Invalid operation for current state" },
};
/**
* vdo_register_status_codes() - Register the VDO status codes.
* Return: A success or error code.
*/
int vdo_register_status_codes(void)
{
int result;
BUILD_BUG_ON((VDO_STATUS_CODE_LAST - VDO_STATUS_CODE_BASE) !=
ARRAY_SIZE(vdo_status_list));
result = uds_register_error_block("VDO Status", VDO_STATUS_CODE_BASE,
VDO_STATUS_CODE_BLOCK_END, vdo_status_list,
sizeof(vdo_status_list));
return (result == UDS_SUCCESS) ? VDO_SUCCESS : result;
}
/**
* vdo_status_to_errno() - Given an error code, return a value we can return to the OS.
* @error: The error code to convert.
*
* The input error code may be a system-generated value (such as -EIO), an errno macro used in our
* code (such as EIO), or a UDS or VDO status code; the result must be something the rest of the OS
* can consume (negative errno values such as -EIO, in the case of the kernel).
*
* Return: A system error code value.
*/
int vdo_status_to_errno(int error)
{
char error_name[VDO_MAX_ERROR_NAME_SIZE];
char error_message[VDO_MAX_ERROR_MESSAGE_SIZE];
/* 0 is success, negative a system error code */
if (likely(error <= 0))
return error;
if (error < 1024)
return -error;
/* VDO or UDS error */
switch (error) {
case VDO_BAD_CONFIGURATION:
return -EINVAL;
case VDO_NO_SPACE:
return -ENOSPC;
case VDO_READ_ONLY:
return -EIO;
default:
vdo_log_info("%s: mapping internal status code %d (%s: %s) to EIO",
Annotation
- Immediate include surface: `status-codes.h`, `errors.h`, `logger.h`, `permassert.h`, `thread-utils.h`.
- Detected declarations: `function vdo_register_status_codes`, `function consume`.
- 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.