fs/ocfs2/slot_map.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/slot_map.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/slot_map.c- Extension
.c- Size
- 12371 bytes
- Lines
- 543
- 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.
- 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/types.hlinux/slab.hlinux/highmem.hcluster/masklog.hocfs2.hdlmglue.hextent_map.hheartbeat.hinode.hslot_map.hsuper.hsysfile.hocfs2_trace.hbuffer_head_io.h
Detected Declarations
struct ocfs2_slotstruct ocfs2_slot_infofunction ocfs2_invalidate_slotfunction ocfs2_set_slotfunction ocfs2_update_slot_info_extendedfunction ocfs2_update_slot_info_oldfunction ocfs2_update_slot_infofunction ocfs2_refresh_slot_infofunction ocfs2_update_disk_slot_extendedfunction ocfs2_update_disk_slot_oldfunction ocfs2_update_disk_slotfunction ocfs2_slot_map_physical_sizefunction __ocfs2_node_num_to_slotfunction __ocfs2_find_empty_slotfunction ocfs2_node_num_to_slotfunction ocfs2_slot_to_node_num_lockedfunction __ocfs2_free_slot_infofunction ocfs2_clear_slotfunction ocfs2_validate_slot_map_blockfunction ocfs2_map_slot_buffersfunction ocfs2_init_slot_infofunction ocfs2_free_slot_infofunction ocfs2_find_slotfunction ocfs2_put_slot
Annotated Snippet
struct ocfs2_slot {
int sl_valid;
unsigned int sl_node_num;
};
struct ocfs2_slot_info {
int si_extended;
int si_slots_per_block;
struct inode *si_inode;
unsigned int si_blocks;
struct buffer_head **si_bh;
unsigned int si_num_slots;
struct ocfs2_slot si_slots[] __counted_by(si_num_slots);
};
static int __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si,
unsigned int node_num);
static int ocfs2_validate_slot_map_block(struct super_block *sb,
struct buffer_head *bh);
static void ocfs2_invalidate_slot(struct ocfs2_slot_info *si,
int slot_num)
{
BUG_ON((slot_num < 0) || (slot_num >= si->si_num_slots));
si->si_slots[slot_num].sl_valid = 0;
}
static void ocfs2_set_slot(struct ocfs2_slot_info *si,
int slot_num, unsigned int node_num)
{
BUG_ON((slot_num < 0) || (slot_num >= si->si_num_slots));
si->si_slots[slot_num].sl_valid = 1;
si->si_slots[slot_num].sl_node_num = node_num;
}
/* This version is for the extended slot map */
static void ocfs2_update_slot_info_extended(struct ocfs2_slot_info *si)
{
int b, i, slotno;
struct ocfs2_slot_map_extended *se;
slotno = 0;
for (b = 0; b < si->si_blocks; b++) {
se = (struct ocfs2_slot_map_extended *)si->si_bh[b]->b_data;
for (i = 0;
(i < si->si_slots_per_block) &&
(slotno < si->si_num_slots);
i++, slotno++) {
if (se->se_slots[i].es_valid)
ocfs2_set_slot(si, slotno,
le32_to_cpu(se->se_slots[i].es_node_num));
else
ocfs2_invalidate_slot(si, slotno);
}
}
}
/*
* Post the slot information on disk into our slot_info struct.
* Must be protected by osb_lock.
*/
static void ocfs2_update_slot_info_old(struct ocfs2_slot_info *si)
{
int i;
struct ocfs2_slot_map *sm;
sm = (struct ocfs2_slot_map *)si->si_bh[0]->b_data;
for (i = 0; i < si->si_num_slots; i++) {
if (le16_to_cpu(sm->sm_slots[i]) == (u16)OCFS2_INVALID_SLOT)
ocfs2_invalidate_slot(si, i);
else
ocfs2_set_slot(si, i, le16_to_cpu(sm->sm_slots[i]));
}
}
static void ocfs2_update_slot_info(struct ocfs2_slot_info *si)
{
/*
* The slot data will have been refreshed when ocfs2_super_lock
* was taken.
*/
if (si->si_extended)
ocfs2_update_slot_info_extended(si);
else
ocfs2_update_slot_info_old(si);
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/slab.h`, `linux/highmem.h`, `cluster/masklog.h`, `ocfs2.h`, `dlmglue.h`, `extent_map.h`, `heartbeat.h`.
- Detected declarations: `struct ocfs2_slot`, `struct ocfs2_slot_info`, `function ocfs2_invalidate_slot`, `function ocfs2_set_slot`, `function ocfs2_update_slot_info_extended`, `function ocfs2_update_slot_info_old`, `function ocfs2_update_slot_info`, `function ocfs2_refresh_slot_info`, `function ocfs2_update_disk_slot_extended`, `function ocfs2_update_disk_slot_old`.
- 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.