drivers/block/drbd/drbd_debugfs.c
Source file repositories/reference/linux-study-clean/drivers/block/drbd/drbd_debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/block/drbd/drbd_debugfs.c- Extension
.c- Size
- 27737 bytes
- Lines
- 892
- Domain
- Driver Families
- Bucket
- drivers/block
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/debugfs.hlinux/seq_file.hlinux/stat.hlinux/jiffies.hlinux/list.hdrbd_int.hdrbd_req.hdrbd_debugfs.h
Detected Declarations
function seq_print_age_or_dashfunction __seq_print_rq_state_bitfunction seq_print_rq_state_bitfunction seq_print_request_statefunction seq_print_one_requestfunction seq_print_minor_vnr_reqfunction seq_print_resource_pending_meta_iofunction seq_print_waiting_for_ALfunction seq_print_device_bitmap_iofunction seq_print_resource_pending_bitmap_iofunction seq_print_peer_request_flagsfunction seq_print_peer_requestfunction seq_print_device_peer_requestsfunction seq_print_resource_pending_peer_requestsfunction seq_print_resource_transfer_log_summaryfunction in_flight_summary_showfunction drbd_single_openfunction in_flight_summary_openfunction in_flight_summary_releasefunction drbd_debugfs_resource_addfunction drbd_debugfs_removefunction drbd_debugfs_resource_cleanupfunction seq_print_one_timing_detailfunction seq_print_timing_detailsfunction callback_history_showfunction callback_history_openfunction callback_history_releasefunction connection_oldest_requests_showfunction connection_oldest_requests_openfunction connection_oldest_requests_releasefunction drbd_debugfs_connection_addfunction drbd_debugfs_connection_cleanupfunction resync_dump_detailfunction device_resync_extents_showfunction device_act_log_extents_showfunction device_oldest_requests_showfunction device_data_gen_id_showfunction device_ed_gen_id_showfunction drbd_debugfs_device_addfunction drbd_debugfs_device_cleanupfunction drbd_debugfs_peer_device_addfunction drbd_debugfs_peer_device_cleanupfunction drbd_version_showfunction drbd_version_openfunction drbd_debugfs_cleanupfunction drbd_debugfs_init
Annotated Snippet
static const struct file_operations in_flight_summary_fops = {
.owner = THIS_MODULE,
.open = in_flight_summary_open,
.read = seq_read,
.llseek = seq_lseek,
.release = in_flight_summary_release,
};
void drbd_debugfs_resource_add(struct drbd_resource *resource)
{
struct dentry *dentry;
dentry = debugfs_create_dir(resource->name, drbd_debugfs_resources);
resource->debugfs_res = dentry;
dentry = debugfs_create_dir("volumes", resource->debugfs_res);
resource->debugfs_res_volumes = dentry;
dentry = debugfs_create_dir("connections", resource->debugfs_res);
resource->debugfs_res_connections = dentry;
dentry = debugfs_create_file("in_flight_summary", 0440,
resource->debugfs_res, resource,
&in_flight_summary_fops);
resource->debugfs_res_in_flight_summary = dentry;
}
static void drbd_debugfs_remove(struct dentry **dp)
{
debugfs_remove(*dp);
*dp = NULL;
}
void drbd_debugfs_resource_cleanup(struct drbd_resource *resource)
{
/* it is ok to call debugfs_remove(NULL) */
drbd_debugfs_remove(&resource->debugfs_res_in_flight_summary);
drbd_debugfs_remove(&resource->debugfs_res_connections);
drbd_debugfs_remove(&resource->debugfs_res_volumes);
drbd_debugfs_remove(&resource->debugfs_res);
}
static void seq_print_one_timing_detail(struct seq_file *m,
const struct drbd_thread_timing_details *tdp,
unsigned long now)
{
struct drbd_thread_timing_details td;
/* No locking...
* use temporary assignment to get at consistent data. */
do {
td = *tdp;
} while (td.cb_nr != tdp->cb_nr);
if (!td.cb_addr)
return;
seq_printf(m, "%u\t%d\t%s:%u\t%ps\n",
td.cb_nr,
jiffies_to_msecs(now - td.start_jif),
td.caller_fn, td.line,
td.cb_addr);
}
static void seq_print_timing_details(struct seq_file *m,
const char *title,
unsigned int cb_nr, struct drbd_thread_timing_details *tdp, unsigned long now)
{
unsigned int start_idx;
unsigned int i;
seq_printf(m, "%s\n", title);
/* If not much is going on, this will result in natural ordering.
* If it is very busy, we will possibly skip events, or even see wrap
* arounds, which could only be avoided with locking.
*/
start_idx = cb_nr % DRBD_THREAD_DETAILS_HIST;
for (i = start_idx; i < DRBD_THREAD_DETAILS_HIST; i++)
seq_print_one_timing_detail(m, tdp+i, now);
for (i = 0; i < start_idx; i++)
seq_print_one_timing_detail(m, tdp+i, now);
}
static int callback_history_show(struct seq_file *m, void *ignored)
{
struct drbd_connection *connection = m->private;
unsigned long jif = jiffies;
/* BUMP me if you change the file format/content/presentation */
seq_printf(m, "v: %u\n\n", 0);
seq_puts(m, "n\tage\tcallsite\tfn\n");
seq_print_timing_details(m, "worker", connection->w_cb_nr, connection->w_timing_details, jif);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/debugfs.h`, `linux/seq_file.h`, `linux/stat.h`, `linux/jiffies.h`, `linux/list.h`, `drbd_int.h`.
- Detected declarations: `function seq_print_age_or_dash`, `function __seq_print_rq_state_bit`, `function seq_print_rq_state_bit`, `function seq_print_request_state`, `function seq_print_one_request`, `function seq_print_minor_vnr_req`, `function seq_print_resource_pending_meta_io`, `function seq_print_waiting_for_AL`, `function seq_print_device_bitmap_io`, `function seq_print_resource_pending_bitmap_io`.
- Atlas domain: Driver Families / drivers/block.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.