fs/ocfs2/journal.h
Source file repositories/reference/linux-study-clean/fs/ocfs2/journal.h
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/journal.h- Extension
.h- Size
- 22302 bytes
- Lines
- 614
- 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/fs.hlinux/jbd2.h
Detected Declarations
struct ocfs2_superstruct ocfs2_dinodestruct ocfs2_recovery_mapstruct ocfs2_journalenum ocfs2_journal_statefunction ocfs2_inc_trans_idfunction ocfs2_set_ci_lock_transfunction ocfs2_ci_fully_checkpointedfunction newfunction ocfs2_inode_is_newfunction ocfs2_ci_set_newfunction ocfs2_start_checkpointfunction ocfs2_checkpoint_inodefunction set_infofunction ocfs2_inline_to_extents_creditsfunction ocfs2_remove_extent_creditsfunction ocfs2_add_dir_index_creditsfunction ocfs2_mknod_creditsfunction ocfs2_link_creditsfunction ocfs2_unlink_creditsfunction ocfs2_rename_creditsfunction ocfs2_calc_dxi_expand_creditsfunction ocfs2_calc_extend_creditsfunction ocfs2_calc_symlink_creditsfunction ocfs2_calc_group_alloc_creditsfunction ocfs2_calc_group_alloc_creditsfunction ocfs2_jbd2_inode_add_writefunction ocfs2_begin_ordered_truncatefunction ocfs2_update_inode_fsync_trans
Annotated Snippet
struct ocfs2_recovery_map {
unsigned int rm_used;
unsigned int rm_entries[];
};
struct ocfs2_journal {
enum ocfs2_journal_state j_state; /* Journals current state */
journal_t *j_journal; /* The kernels journal type */
struct inode *j_inode; /* Kernel inode pointing to
* this journal */
struct ocfs2_super *j_osb; /* pointer to the super
* block for the node
* we're currently
* running on -- not
* necessarily the super
* block from the node
* which we usually run
* from (recovery,
* etc) */
struct buffer_head *j_bh; /* Journal disk inode block */
atomic_t j_num_trans; /* Number of transactions
* currently in the system. */
spinlock_t j_lock;
unsigned long j_trans_id;
struct rw_semaphore j_trans_barrier;
wait_queue_head_t j_checkpointed;
/* both fields protected by j_lock*/
struct list_head j_la_cleanups;
struct work_struct j_recovery_work;
};
extern spinlock_t trans_inc_lock;
/* wrap j_trans_id so we never have it equal to zero. */
static inline unsigned long ocfs2_inc_trans_id(struct ocfs2_journal *j)
{
unsigned long old_id;
spin_lock(&trans_inc_lock);
old_id = j->j_trans_id++;
if (unlikely(!j->j_trans_id))
j->j_trans_id = 1;
spin_unlock(&trans_inc_lock);
return old_id;
}
static inline void ocfs2_set_ci_lock_trans(struct ocfs2_journal *journal,
struct ocfs2_caching_info *ci)
{
spin_lock(&trans_inc_lock);
ci->ci_last_trans = journal->j_trans_id;
spin_unlock(&trans_inc_lock);
}
/* Used to figure out whether it's safe to drop a metadata lock on an
* cached object. Returns true if all the object's changes have been
* checkpointed to disk. You should be holding the spinlock on the
* metadata lock while calling this to be sure that nobody can take
* the lock and put it on another transaction. */
static inline int ocfs2_ci_fully_checkpointed(struct ocfs2_caching_info *ci)
{
int ret;
struct ocfs2_journal *journal =
OCFS2_SB(ocfs2_metadata_cache_get_super(ci))->journal;
spin_lock(&trans_inc_lock);
ret = time_after(journal->j_trans_id, ci->ci_last_trans);
spin_unlock(&trans_inc_lock);
return ret;
}
/* convenience function to check if an object backed by struct
* ocfs2_caching_info is still new (has never hit disk) Will do you a
* favor and set created_trans = 0 when you've
* been checkpointed. returns '1' if the ci is still new. */
static inline int ocfs2_ci_is_new(struct ocfs2_caching_info *ci)
{
int ret;
struct ocfs2_journal *journal =
OCFS2_SB(ocfs2_metadata_cache_get_super(ci))->journal;
spin_lock(&trans_inc_lock);
ret = !(time_after(journal->j_trans_id, ci->ci_created_trans));
if (!ret)
ci->ci_created_trans = 0;
spin_unlock(&trans_inc_lock);
return ret;
}
Annotation
- Immediate include surface: `linux/fs.h`, `linux/jbd2.h`.
- Detected declarations: `struct ocfs2_super`, `struct ocfs2_dinode`, `struct ocfs2_recovery_map`, `struct ocfs2_journal`, `enum ocfs2_journal_state`, `function ocfs2_inc_trans_id`, `function ocfs2_set_ci_lock_trans`, `function ocfs2_ci_fully_checkpointed`, `function new`, `function ocfs2_inode_is_new`.
- 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.