fs/ocfs2/heartbeat.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/heartbeat.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/heartbeat.c- Extension
.c- Size
- 2271 bytes
- Lines
- 102
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source 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.
- 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/bitmap.hlinux/fs.hlinux/types.hlinux/highmem.hcluster/masklog.hocfs2.halloc.hheartbeat.hinode.hjournal.hocfs2_trace.hbuffer_head_io.h
Detected Declarations
function Copyrightfunction ocfs2_init_node_mapsfunction ocfs2_do_node_downfunction ocfs2_node_map_set_bitfunction ocfs2_node_map_clear_bitfunction ocfs2_node_map_test_bit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* heartbeat.c
*
* Register ourselves with the heartbeat service, keep our node maps
* up to date, and fire off recovery when needed.
*
* Copyright (C) 2002, 2004 Oracle. All rights reserved.
*/
#include <linux/bitmap.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/highmem.h>
#include <cluster/masklog.h>
#include "ocfs2.h"
#include "alloc.h"
#include "heartbeat.h"
#include "inode.h"
#include "journal.h"
#include "ocfs2_trace.h"
#include "buffer_head_io.h"
/* special case -1 for now
* TODO: should *really* make sure the calling func never passes -1!! */
static void ocfs2_node_map_init(struct ocfs2_node_map *map)
{
map->num_nodes = OCFS2_NODE_MAP_MAX_NODES;
bitmap_zero(map->map, OCFS2_NODE_MAP_MAX_NODES);
}
void ocfs2_init_node_maps(struct ocfs2_super *osb)
{
spin_lock_init(&osb->node_map_lock);
ocfs2_node_map_init(&osb->osb_recovering_orphan_dirs);
}
void ocfs2_do_node_down(int node_num, void *data)
{
struct ocfs2_super *osb = data;
BUG_ON(osb->node_num == node_num);
trace_ocfs2_do_node_down(node_num);
if (!osb->cconn) {
/*
* No cluster connection means we're not even ready to
* participate yet. We check the slots after the cluster
* comes up, so we will notice the node death then. We
* can safely ignore it here.
*/
return;
}
ocfs2_recovery_thread(osb, node_num);
}
void ocfs2_node_map_set_bit(struct ocfs2_super *osb,
struct ocfs2_node_map *map,
int bit)
{
if (bit==-1)
return;
BUG_ON(bit >= map->num_nodes);
spin_lock(&osb->node_map_lock);
set_bit(bit, map->map);
spin_unlock(&osb->node_map_lock);
}
void ocfs2_node_map_clear_bit(struct ocfs2_super *osb,
struct ocfs2_node_map *map,
int bit)
{
if (bit==-1)
return;
BUG_ON(bit >= map->num_nodes);
spin_lock(&osb->node_map_lock);
clear_bit(bit, map->map);
spin_unlock(&osb->node_map_lock);
}
int ocfs2_node_map_test_bit(struct ocfs2_super *osb,
struct ocfs2_node_map *map,
int bit)
{
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/fs.h`, `linux/types.h`, `linux/highmem.h`, `cluster/masklog.h`, `ocfs2.h`, `alloc.h`, `heartbeat.h`.
- Detected declarations: `function Copyright`, `function ocfs2_init_node_maps`, `function ocfs2_do_node_down`, `function ocfs2_node_map_set_bit`, `function ocfs2_node_map_clear_bit`, `function ocfs2_node_map_test_bit`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.