fs/ext4/ext4_jbd2.c
Source file repositories/reference/linux-study-clean/fs/ext4/ext4_jbd2.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ext4/ext4_jbd2.c- Extension
.c- Size
- 10971 bytes
- Lines
- 409
- 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
ext4_jbd2.htrace/events/ext4.h
Detected Declarations
function ext4_inode_journal_modefunction ext4_test_inode_flagfunction ext4_put_nojournalfunction ext4_journal_check_startfunction backsfunction __ext4_journal_stopfunction __ext4_journal_ensure_creditsfunction ext4_journal_abort_handlefunction ext4_check_bdev_write_errorfunction __ext4_journal_get_write_accessfunction __ext4_forgetfunction __ext4_journal_get_create_accessfunction __ext4_handle_dirty_metadata
Annotated Snippet
if (err) {
ext4_journal_abort_handle(where, line, __func__, bh,
handle, err);
return err;
}
} else
ext4_check_bdev_write_error(sb);
if (trigger_type == EXT4_JTR_NONE ||
!ext4_has_feature_metadata_csum(sb))
return 0;
BUG_ON(trigger_type >= EXT4_JOURNAL_TRIGGER_COUNT);
jbd2_journal_set_triggers(bh,
&EXT4_SB(sb)->s_journal_triggers[trigger_type].tr_triggers);
return 0;
}
/*
* The ext4 forget function must perform a revoke if we are freeing data
* which has been journaled. Metadata (eg. indirect blocks) must be
* revoked in all cases.
*
* "bh" may be NULL: a metadata block may have been freed from memory
* but there may still be a record of it in the journal, and that record
* still needs to be revoked.
*/
int __ext4_forget(const char *where, unsigned int line, handle_t *handle,
int is_metadata, struct inode *inode,
struct buffer_head *bh, ext4_fsblk_t blocknr)
{
int err;
might_sleep();
trace_ext4_forget(inode, is_metadata, blocknr);
BUFFER_TRACE(bh, "enter");
ext4_debug("forgetting bh %p: is_metadata=%d, mode %o, data mode %x\n",
bh, is_metadata, inode->i_mode,
test_opt(inode->i_sb, DATA_FLAGS));
/*
* In the no journal case, we should wait for the ongoing buffer
* to complete and do a forget.
*/
if (!ext4_handle_valid(handle)) {
if (bh) {
clear_buffer_dirty(bh);
wait_on_buffer(bh);
__bforget(bh);
}
return 0;
}
/* Never use the revoke function if we are doing full data
* journaling: there is no need to, and a V1 superblock won't
* support it. Otherwise, only skip the revoke on un-journaled
* data blocks. */
if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
(!is_metadata && !ext4_should_journal_data(inode))) {
if (bh) {
BUFFER_TRACE(bh, "call jbd2_journal_forget");
err = jbd2_journal_forget(handle, bh);
if (err)
ext4_journal_abort_handle(where, line, __func__,
bh, handle, err);
return err;
}
return 0;
}
/*
* data!=journal && (is_metadata || should_journal_data(inode))
*/
BUFFER_TRACE(bh, "call jbd2_journal_revoke");
err = jbd2_journal_revoke(handle, blocknr, bh);
if (err) {
ext4_journal_abort_handle(where, line, __func__,
bh, handle, err);
__ext4_error(inode->i_sb, where, line, true, -err, 0,
"error %d when attempting revoke", err);
}
BUFFER_TRACE(bh, "exit");
return err;
}
int __ext4_journal_get_create_access(const char *where, unsigned int line,
handle_t *handle, struct super_block *sb,
struct buffer_head *bh,
enum ext4_journal_trigger_type trigger_type)
Annotation
- Immediate include surface: `ext4_jbd2.h`, `trace/events/ext4.h`.
- Detected declarations: `function ext4_inode_journal_mode`, `function ext4_test_inode_flag`, `function ext4_put_nojournal`, `function ext4_journal_check_start`, `function backs`, `function __ext4_journal_stop`, `function __ext4_journal_ensure_credits`, `function ext4_journal_abort_handle`, `function ext4_check_bdev_write_error`, `function __ext4_journal_get_write_access`.
- 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.