drivers/md/dm-vdo/logger.c
Source file repositories/reference/linux-study-clean/drivers/md/dm-vdo/logger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/md/dm-vdo/logger.c- Extension
.c- Size
- 5923 bytes
- Lines
- 240
- 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
logger.hasm/current.hlinux/delay.hlinux/hardirq.hlinux/module.hlinux/printk.hlinux/sched.herrors.hthread-device.hthread-utils.h
Detected Declarations
function vdo_get_log_levelfunction emit_log_message_to_kernelfunction emit_log_messagefunction vdo_log_embedded_messagefunction vdo_vlog_strerrorfunction __vdo_log_strerrorfunction vdo_log_backtracefunction __vdo_log_messagefunction vdo_pause_for_logger
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2023 Red Hat
*/
#include "logger.h"
#include <asm/current.h>
#include <linux/delay.h>
#include <linux/hardirq.h>
#include <linux/module.h>
#include <linux/printk.h>
#include <linux/sched.h>
#include "errors.h"
#include "thread-device.h"
#include "thread-utils.h"
int vdo_log_level = VDO_LOG_DEFAULT;
int vdo_get_log_level(void)
{
int log_level_latch = READ_ONCE(vdo_log_level);
if (unlikely(log_level_latch > VDO_LOG_MAX)) {
log_level_latch = VDO_LOG_DEFAULT;
WRITE_ONCE(vdo_log_level, log_level_latch);
}
return log_level_latch;
}
static const char *get_current_interrupt_type(void)
{
if (in_nmi())
return "NMI";
if (in_hardirq())
return "HI";
if (in_softirq())
return "SI";
return "INTR";
}
/**
* emit_log_message_to_kernel() - Emit a log message to the kernel at the specified priority.
*
* @priority: The priority at which to log the message
* @fmt: The format string of the message
*/
static void emit_log_message_to_kernel(int priority, const char *fmt, ...)
{
va_list args;
struct va_format vaf;
if (priority > vdo_get_log_level())
return;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
switch (priority) {
case VDO_LOG_EMERG:
case VDO_LOG_ALERT:
case VDO_LOG_CRIT:
pr_crit("%pV", &vaf);
break;
case VDO_LOG_ERR:
pr_err("%pV", &vaf);
break;
case VDO_LOG_WARNING:
pr_warn("%pV", &vaf);
break;
case VDO_LOG_NOTICE:
case VDO_LOG_INFO:
pr_info("%pV", &vaf);
break;
case VDO_LOG_DEBUG:
pr_debug("%pV", &vaf);
break;
default:
printk(KERN_DEFAULT "%pV", &vaf);
break;
}
va_end(args);
}
Annotation
- Immediate include surface: `logger.h`, `asm/current.h`, `linux/delay.h`, `linux/hardirq.h`, `linux/module.h`, `linux/printk.h`, `linux/sched.h`, `errors.h`.
- Detected declarations: `function vdo_get_log_level`, `function emit_log_message_to_kernel`, `function emit_log_message`, `function vdo_log_embedded_message`, `function vdo_vlog_strerror`, `function __vdo_log_strerror`, `function vdo_log_backtrace`, `function __vdo_log_message`, `function vdo_pause_for_logger`.
- 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.