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.

Dependency Surface

Detected Declarations

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

Implementation Notes