fs/ext4/fast_commit.c
Source file repositories/reference/linux-study-clean/fs/ext4/fast_commit.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ext4/fast_commit.c- Extension
.c- Size
- 80773 bytes
- Lines
- 2778
- 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
ext4.hext4_jbd2.hext4_extents.hmballoc.hlinux/lockdep.hlinux/wait_bit.htrace/events/ext4.h
Detected Declarations
struct __track_dentry_update_argsstruct __track_range_argsstruct ext4_fc_rangestruct ext4_fc_inode_snapstruct dentry_info_argsstruct ext4_fc_tl_memfunction jbd2_journal_lock_updatesfunction ext4_end_buffer_io_syncfunction ext4_fc_reset_inodefunction ext4_fc_init_inodefunction ext4_fc_disabledfunction ext4_fc_eligiblefunction ext4_fc_wait_inode_statefunction ext4_fc_wake_inode_statefunction ext4_fc_snap_stats_update_maxfunction ext4_fc_delfunction ext4_fc_mark_ineligiblefunction __fc_track_fnfunction __track_dentry_updatefunction ext4_fc_delfunction __ext4_fc_track_unlinkfunction ext4_fc_track_unlinkfunction __ext4_fc_track_linkfunction ext4_fc_track_linkfunction __ext4_fc_track_createfunction ext4_fc_track_createfunction __track_inodefunction ext4_fc_track_inodefunction __track_rangefunction ext4_fc_track_rangefunction ext4_fc_submit_bhfunction ext4_fc_write_tailfunction ext4_fc_add_tlvfunction ext4_fc_add_dentry_tlvfunction ext4_fc_write_inodefunction ext4_fc_write_inode_datafunction list_for_each_entryfunction ext4_fc_free_rangesfunction list_for_each_entry_safefunction ext4_fc_free_inode_snapfunction ext4_fc_snapshot_inode_datafunction ext4_es_is_unwrittenfunction ext4_fc_snapshot_inodefunction ext4_fc_flush_datafunction list_for_each_entryfunction list_for_each_entryfunction ext4_fc_commit_dentry_updatesfunction ext4_fc_snapshot_inodes
Annotated Snippet
struct __track_dentry_update_args {
struct dentry *dentry;
int op;
};
/* __track_fn for directory entry updates. Called with ei->i_fc_lock. */
static int __track_dentry_update(handle_t *handle, struct inode *inode,
void *arg, bool update)
{
struct ext4_fc_dentry_update *node;
struct ext4_inode_info *ei = EXT4_I(inode);
struct __track_dentry_update_args *dentry_update =
(struct __track_dentry_update_args *)arg;
struct dentry *dentry = dentry_update->dentry;
struct inode *dir = dentry->d_parent->d_inode;
struct super_block *sb = inode->i_sb;
struct ext4_sb_info *sbi = EXT4_SB(sb);
int alloc_ctx;
spin_unlock(&ei->i_fc_lock);
if (IS_ENCRYPTED(dir)) {
ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_ENCRYPTED_FILENAME,
handle);
spin_lock(&ei->i_fc_lock);
return -EOPNOTSUPP;
}
node = kmem_cache_alloc(ext4_fc_dentry_cachep, GFP_NOFS);
if (!node) {
ext4_fc_mark_ineligible(sb, EXT4_FC_REASON_NOMEM, handle);
spin_lock(&ei->i_fc_lock);
return -ENOMEM;
}
node->fcd_op = dentry_update->op;
node->fcd_parent = dir->i_ino;
node->fcd_ino = inode->i_ino;
take_dentry_name_snapshot(&node->fcd_name, dentry);
INIT_LIST_HEAD(&node->fcd_dilist);
INIT_LIST_HEAD(&node->fcd_list);
alloc_ctx = ext4_fc_lock(sb);
if (sbi->s_journal->j_flags & JBD2_FULL_COMMIT_ONGOING ||
sbi->s_journal->j_flags & JBD2_FAST_COMMIT_ONGOING)
list_add_tail(&node->fcd_list,
&sbi->s_fc_dentry_q[FC_Q_STAGING]);
else
list_add_tail(&node->fcd_list, &sbi->s_fc_dentry_q[FC_Q_MAIN]);
/*
* This helps us keep a track of all fc_dentry updates which is part of
* this ext4 inode. So in case the inode is getting unlinked, before
* even we get a chance to fsync, we could remove all fc_dentry
* references while evicting the inode in ext4_fc_del().
* Also with this, we don't need to loop over all the inodes in
* sbi->s_fc_q to get the corresponding inode in
* ext4_fc_commit_dentry_updates().
*/
if (dentry_update->op == EXT4_FC_TAG_CREAT) {
WARN_ON(!list_empty(&ei->i_fc_dilist));
list_add_tail(&node->fcd_dilist, &ei->i_fc_dilist);
}
ext4_fc_unlock(sb, alloc_ctx);
spin_lock(&ei->i_fc_lock);
return 0;
}
void __ext4_fc_track_unlink(handle_t *handle,
struct inode *inode, struct dentry *dentry)
{
struct __track_dentry_update_args args;
int ret;
args.dentry = dentry;
args.op = EXT4_FC_TAG_UNLINK;
ret = ext4_fc_track_template(handle, inode, __track_dentry_update,
(void *)&args, 0);
trace_ext4_fc_track_unlink(handle, inode, dentry, ret);
}
void ext4_fc_track_unlink(handle_t *handle, struct dentry *dentry)
{
struct inode *inode = d_inode(dentry);
if (ext4_fc_eligible(inode->i_sb))
__ext4_fc_track_unlink(handle, inode, dentry);
}
Annotation
- Immediate include surface: `ext4.h`, `ext4_jbd2.h`, `ext4_extents.h`, `mballoc.h`, `linux/lockdep.h`, `linux/wait_bit.h`, `trace/events/ext4.h`.
- Detected declarations: `struct __track_dentry_update_args`, `struct __track_range_args`, `struct ext4_fc_range`, `struct ext4_fc_inode_snap`, `struct dentry_info_args`, `struct ext4_fc_tl_mem`, `function jbd2_journal_lock_updates`, `function ext4_end_buffer_io_sync`, `function ext4_fc_reset_inode`, `function ext4_fc_init_inode`.
- 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.