fs/ocfs2/journal.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/journal.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/journal.c- Extension
.c- Size
- 66806 bytes
- Lines
- 2481
- 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/fs.hlinux/types.hlinux/slab.hlinux/highmem.hlinux/kthread.hlinux/time.hlinux/random.hlinux/delay.hlinux/writeback.hcluster/masklog.hocfs2.halloc.hblockcheck.hdir.hdlmglue.hextent_map.hheartbeat.hinode.hjournal.hlocalalloc.hslot_map.hsuper.hsysfile.huptodate.hquota.hfile.hnamei.hbuffer_head_io.hocfs2_trace.h
Detected Declarations
struct ocfs2_replay_mapstruct ocfs2_la_recovery_itemstruct ocfs2_orphan_filldir_privenum ocfs2_replay_statefunction ocfs2_wait_on_mountfunction ocfs2_wait_on_quotasfunction ocfs2_replay_map_set_statefunction ocfs2_compute_replay_slotsfunction ocfs2_queue_replay_slotsfunction ocfs2_free_replay_slotsfunction ocfs2_recovery_initfunction ocfs2_recovery_thread_runningfunction ocfs2_recovery_disablefunction ocfs2_recovery_disable_quotafunction ocfs2_recovery_exitfunction __ocfs2_recovery_map_testfunction ocfs2_recovery_map_setfunction ocfs2_recovery_map_clearfunction ocfs2_commit_cachefunction ocfs2_commit_transfunction jbd2_journal_restartfunction ocfs2_extend_transfunction ocfs2_allocate_extend_transfunction ocfs2_frozen_triggerfunction ocfs2_dq_frozen_triggerfunction ocfs2_db_frozen_triggerfunction ocfs2_abort_triggerfunction ocfs2_setup_csum_triggersfunction ocfs2_initialize_journal_triggersfunction __ocfs2_journal_accessfunction ocfs2_journal_access_difunction ocfs2_journal_access_ebfunction ocfs2_journal_access_rbfunction ocfs2_journal_access_gdfunction ocfs2_journal_access_dbfunction ocfs2_journal_access_xbfunction ocfs2_journal_access_dqfunction ocfs2_journal_access_drfunction ocfs2_journal_access_dlfunction ocfs2_journal_accessfunction ocfs2_journal_dirtyfunction ocfs2_set_journal_paramsfunction ocfs2_journal_initfunction ocfs2_journal_submit_inode_data_buffersfunction ocfs2_journal_initfunction ocfs2_bump_recovery_generationfunction ocfs2_get_recovery_generationfunction ocfs2_journal_toggle_dirty
Annotated Snippet
struct ocfs2_replay_map {
unsigned int rm_slots;
enum ocfs2_replay_state rm_state;
unsigned char rm_replay_slots[] __counted_by(rm_slots);
};
static void ocfs2_replay_map_set_state(struct ocfs2_super *osb, int state)
{
if (!osb->replay_map)
return;
/* If we've already queued the replay, we don't have any more to do */
if (osb->replay_map->rm_state == REPLAY_DONE)
return;
osb->replay_map->rm_state = state;
}
int ocfs2_compute_replay_slots(struct ocfs2_super *osb)
{
struct ocfs2_replay_map *replay_map;
int i, node_num;
/* If replay map is already set, we don't do it again */
if (osb->replay_map)
return 0;
replay_map = kzalloc_flex(*replay_map, rm_replay_slots, osb->max_slots);
if (!replay_map) {
mlog_errno(-ENOMEM);
return -ENOMEM;
}
spin_lock(&osb->osb_lock);
replay_map->rm_slots = osb->max_slots;
replay_map->rm_state = REPLAY_UNNEEDED;
/* set rm_replay_slots for offline slot(s) */
for (i = 0; i < replay_map->rm_slots; i++) {
if (ocfs2_slot_to_node_num_locked(osb, i, &node_num) == -ENOENT)
replay_map->rm_replay_slots[i] = 1;
}
osb->replay_map = replay_map;
spin_unlock(&osb->osb_lock);
return 0;
}
static void ocfs2_queue_replay_slots(struct ocfs2_super *osb,
enum ocfs2_orphan_reco_type orphan_reco_type)
{
struct ocfs2_replay_map *replay_map = osb->replay_map;
int i;
if (!replay_map)
return;
if (replay_map->rm_state != REPLAY_NEEDED)
return;
for (i = 0; i < replay_map->rm_slots; i++)
if (replay_map->rm_replay_slots[i])
ocfs2_queue_recovery_completion(osb->journal, i, NULL,
NULL, NULL,
orphan_reco_type);
replay_map->rm_state = REPLAY_DONE;
}
void ocfs2_free_replay_slots(struct ocfs2_super *osb)
{
struct ocfs2_replay_map *replay_map = osb->replay_map;
if (!osb->replay_map)
return;
kfree(replay_map);
osb->replay_map = NULL;
}
int ocfs2_recovery_init(struct ocfs2_super *osb)
{
struct ocfs2_recovery_map *rm;
mutex_init(&osb->recovery_lock);
osb->recovery_state = OCFS2_REC_ENABLED;
osb->recovery_thread_task = NULL;
init_waitqueue_head(&osb->recovery_event);
rm = kzalloc_flex(*rm, rm_entries, osb->max_slots);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/types.h`, `linux/slab.h`, `linux/highmem.h`, `linux/kthread.h`, `linux/time.h`, `linux/random.h`, `linux/delay.h`.
- Detected declarations: `struct ocfs2_replay_map`, `struct ocfs2_la_recovery_item`, `struct ocfs2_orphan_filldir_priv`, `enum ocfs2_replay_state`, `function ocfs2_wait_on_mount`, `function ocfs2_wait_on_quotas`, `function ocfs2_replay_map_set_state`, `function ocfs2_compute_replay_slots`, `function ocfs2_queue_replay_slots`, `function ocfs2_free_replay_slots`.
- 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.