fs/ocfs2/cluster/heartbeat.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/cluster/heartbeat.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/cluster/heartbeat.c- Extension
.c- Size
- 68780 bytes
- Lines
- 2579
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kstrtox.hlinux/kernel.hlinux/sched.hlinux/jiffies.hlinux/module.hlinux/fs.hlinux/bio.hlinux/blkdev.hlinux/delay.hlinux/file.hlinux/kthread.hlinux/configfs.hlinux/random.hlinux/crc32.hlinux/time.hlinux/debugfs.hlinux/slab.hlinux/bitmap.hlinux/ktime.hheartbeat.htcp.hnodemanager.hquorum.hmasklog.h
Detected Declarations
struct o2hb_debug_bufstruct o2hb_node_eventstruct o2hb_disk_slotstruct o2hb_regionstruct o2hb_bio_wait_ctxtstruct o2hb_nego_msgstruct o2hb_heartbeat_groupenum o2hb_heartbeat_modesfunction o2hb_dead_threshold_setfunction o2hb_global_heartbeat_mode_setfunction o2hb_write_timeoutfunction o2hb_arm_timeoutfunction o2hb_disarm_timeoutfunction o2hb_send_nego_msgfunction o2hb_nego_timeoutfunction o2hb_nego_timeout_handlerfunction o2hb_nego_approve_handlerfunction o2hb_bio_wait_initfunction o2hb_bio_wait_decfunction o2hb_wait_on_iofunction o2hb_bio_end_iofunction o2hb_read_slotsfunction o2hb_issue_node_writefunction o2hb_compute_block_crc_lefunction o2hb_dump_slotfunction o2hb_verify_crcfunction o2hb_check_own_slotfunction o2hb_prepare_blockfunction o2hb_fire_callbacksfunction list_for_each_entryfunction o2hb_run_event_listfunction o2hb_queue_node_eventfunction o2hb_shutdown_slotfunction o2hb_set_quorum_devicefunction o2hb_check_slotfunction o2hb_highest_nodefunction o2hb_lowest_nodefunction o2hb_do_disk_heartbeatfunction o2hb_threadfunction o2hb_debug_openfunction o2hb_debug_releasefunction o2hb_debug_readfunction o2hb_debug_openfunction o2hb_debug_releasefunction o2hb_debug_readfunction o2hb_exitfunction o2hb_debug_createfunction o2hb_debug_init
Annotated Snippet
static const struct file_operations o2hb_debug_fops = {
.open = o2hb_debug_open,
.release = o2hb_debug_release,
.read = o2hb_debug_read,
.llseek = generic_file_llseek,
};
void o2hb_exit(void)
{
debugfs_remove_recursive(o2hb_debug_dir);
kfree(o2hb_db_livenodes);
kfree(o2hb_db_liveregions);
kfree(o2hb_db_quorumregions);
kfree(o2hb_db_failedregions);
}
static void o2hb_debug_create(const char *name, struct dentry *dir,
struct o2hb_debug_buf **db, int db_len, int type,
int size, int len, void *data)
{
*db = kmalloc(db_len, GFP_KERNEL);
if (!*db)
return;
(*db)->db_type = type;
(*db)->db_size = size;
(*db)->db_len = len;
(*db)->db_data = data;
debugfs_create_file(name, S_IFREG|S_IRUSR, dir, *db, &o2hb_debug_fops);
}
static void o2hb_debug_init(void)
{
o2hb_debug_dir = debugfs_create_dir(O2HB_DEBUG_DIR, NULL);
o2hb_debug_create(O2HB_DEBUG_LIVENODES, o2hb_debug_dir,
&o2hb_db_livenodes, sizeof(*o2hb_db_livenodes),
O2HB_DB_TYPE_LIVENODES, sizeof(o2hb_live_node_bitmap),
O2NM_MAX_NODES, o2hb_live_node_bitmap);
o2hb_debug_create(O2HB_DEBUG_LIVEREGIONS, o2hb_debug_dir,
&o2hb_db_liveregions, sizeof(*o2hb_db_liveregions),
O2HB_DB_TYPE_LIVEREGIONS,
sizeof(o2hb_live_region_bitmap), O2NM_MAX_REGIONS,
o2hb_live_region_bitmap);
o2hb_debug_create(O2HB_DEBUG_QUORUMREGIONS, o2hb_debug_dir,
&o2hb_db_quorumregions,
sizeof(*o2hb_db_quorumregions),
O2HB_DB_TYPE_QUORUMREGIONS,
sizeof(o2hb_quorum_region_bitmap), O2NM_MAX_REGIONS,
o2hb_quorum_region_bitmap);
o2hb_debug_create(O2HB_DEBUG_FAILEDREGIONS, o2hb_debug_dir,
&o2hb_db_failedregions,
sizeof(*o2hb_db_failedregions),
O2HB_DB_TYPE_FAILEDREGIONS,
sizeof(o2hb_failed_region_bitmap), O2NM_MAX_REGIONS,
o2hb_failed_region_bitmap);
}
void o2hb_init(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(o2hb_callbacks); i++)
INIT_LIST_HEAD(&o2hb_callbacks[i].list);
for (i = 0; i < ARRAY_SIZE(o2hb_live_slots); i++)
INIT_LIST_HEAD(&o2hb_live_slots[i]);
bitmap_zero(o2hb_live_node_bitmap, O2NM_MAX_NODES);
bitmap_zero(o2hb_region_bitmap, O2NM_MAX_REGIONS);
bitmap_zero(o2hb_live_region_bitmap, O2NM_MAX_REGIONS);
bitmap_zero(o2hb_quorum_region_bitmap, O2NM_MAX_REGIONS);
bitmap_zero(o2hb_failed_region_bitmap, O2NM_MAX_REGIONS);
o2hb_dependent_users = 0;
o2hb_debug_init();
}
/* if we're already in a callback then we're already serialized by the sem */
static void o2hb_fill_node_map_from_callback(unsigned long *map,
unsigned int bits)
{
bitmap_copy(map, o2hb_live_node_bitmap, bits);
}
Annotation
- Immediate include surface: `linux/kstrtox.h`, `linux/kernel.h`, `linux/sched.h`, `linux/jiffies.h`, `linux/module.h`, `linux/fs.h`, `linux/bio.h`, `linux/blkdev.h`.
- Detected declarations: `struct o2hb_debug_buf`, `struct o2hb_node_event`, `struct o2hb_disk_slot`, `struct o2hb_region`, `struct o2hb_bio_wait_ctxt`, `struct o2hb_nego_msg`, `struct o2hb_heartbeat_group`, `enum o2hb_heartbeat_modes`, `function o2hb_dead_threshold_set`, `function o2hb_global_heartbeat_mode_set`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.