fs/f2fs/node.c
Source file repositories/reference/linux-study-clean/fs/f2fs/node.c
File Facts
- System
- Linux kernel
- Corpus path
fs/f2fs/node.c- Extension
.c- Size
- 89092 bytes
- Lines
- 3568
- 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/f2fs_fs.hlinux/mpage.hlinux/sched/mm.hlinux/blkdev.hlinux/folio_batch.hlinux/swap.hf2fs.hnode.hsegment.hxattr.hiostat.htrace/events/f2fs.h
Detected Declarations
function is_invalid_nidfunction f2fs_check_nid_rangefunction f2fs_available_free_memoryfunction clear_node_folio_dirtyfunction __free_nat_entryfunction __gang_lookup_nat_cachefunction __del_from_nat_cachefunction __set_nat_cache_dirtyfunction __clear_nat_cache_dirtyfunction __gang_lookup_nat_setfunction f2fs_in_warm_node_listfunction f2fs_init_fsync_node_infofunction f2fs_add_fsync_node_entryfunction f2fs_del_fsync_node_entryfunction f2fs_reset_fsync_node_infofunction f2fs_need_dentry_markfunction f2fs_is_checkpointed_nodefunction f2fs_need_inode_block_updatefunction cache_nat_entryfunction set_node_addrfunction f2fs_try_to_free_natsfunction f2fs_get_node_infofunction f2fs_ra_node_pagesfunction f2fs_get_next_page_offsetfunction get_node_pathfunction f2fs_put_dnodefunction truncate_nodefunction truncate_dnodefunction truncate_nodesfunction truncate_partial_nodesfunction f2fs_truncate_inode_blocksfunction f2fs_truncate_xattr_nodefunction f2fs_lock_opfunction read_node_foliofunction f2fs_ra_node_pagefunction f2fs_sanity_check_node_footerfunction flush_inline_datafunction __write_node_foliofunction f2fs_write_single_node_foliofunction f2fs_move_node_foliofunction f2fs_fsync_node_pagesfunction f2fs_match_inofunction flush_dirty_inodefunction f2fs_flush_inline_datafunction f2fs_sync_node_pagesfunction f2fs_wait_on_node_pages_writebackfunction f2fs_write_node_pagesfunction f2fs_dirty_node_folio
Annotated Snippet
if (fn->folio == folio) {
list_del(&fn->list);
sbi->fsync_node_num--;
spin_unlock_irqrestore(&sbi->fsync_node_lock, flags);
kmem_cache_free(fsync_node_entry_slab, fn);
folio_put(folio);
return;
}
}
spin_unlock_irqrestore(&sbi->fsync_node_lock, flags);
f2fs_bug_on(sbi, 1);
}
void f2fs_reset_fsync_node_info(struct f2fs_sb_info *sbi)
{
unsigned long flags;
spin_lock_irqsave(&sbi->fsync_node_lock, flags);
sbi->fsync_seg_id = 0;
spin_unlock_irqrestore(&sbi->fsync_node_lock, flags);
}
bool f2fs_need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid)
{
struct f2fs_nm_info *nm_i = NM_I(sbi);
struct nat_entry *e;
bool need = false;
f2fs_down_read(&nm_i->nat_tree_lock);
e = __lookup_nat_cache(nm_i, nid, false);
if (e) {
if (!get_nat_flag(e, IS_CHECKPOINTED) &&
!get_nat_flag(e, HAS_FSYNCED_INODE))
need = true;
}
f2fs_up_read(&nm_i->nat_tree_lock);
return need;
}
bool f2fs_is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
{
struct f2fs_nm_info *nm_i = NM_I(sbi);
struct nat_entry *e;
bool is_cp = true;
f2fs_down_read(&nm_i->nat_tree_lock);
e = __lookup_nat_cache(nm_i, nid, false);
if (e && !get_nat_flag(e, IS_CHECKPOINTED))
is_cp = false;
f2fs_up_read(&nm_i->nat_tree_lock);
return is_cp;
}
bool f2fs_need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino)
{
struct f2fs_nm_info *nm_i = NM_I(sbi);
struct nat_entry *e;
bool need_update = true;
struct f2fs_lock_context lc;
f2fs_down_read_trace(&sbi->node_write, &lc);
f2fs_down_read(&nm_i->nat_tree_lock);
e = __lookup_nat_cache(nm_i, ino, false);
if (e && get_nat_flag(e, HAS_LAST_FSYNC) &&
(get_nat_flag(e, IS_CHECKPOINTED) ||
get_nat_flag(e, HAS_FSYNCED_INODE)))
need_update = false;
f2fs_up_read(&nm_i->nat_tree_lock);
f2fs_up_read_trace(&sbi->node_write, &lc);
return need_update;
}
/* must be locked by nat_tree_lock */
static void cache_nat_entry(struct f2fs_sb_info *sbi, nid_t nid,
struct f2fs_nat_entry *ne)
{
struct f2fs_nm_info *nm_i = NM_I(sbi);
struct nat_entry *new, *e;
/* Let's mitigate lock contention of nat_tree_lock during checkpoint */
if (f2fs_rwsem_is_locked(&sbi->cp_global_sem))
return;
new = __alloc_nat_entry(sbi, nid, false);
if (!new)
return;
f2fs_down_write(&nm_i->nat_tree_lock);
e = __lookup_nat_cache(nm_i, nid, false);
if (!e)
Annotation
- Immediate include surface: `linux/fs.h`, `linux/f2fs_fs.h`, `linux/mpage.h`, `linux/sched/mm.h`, `linux/blkdev.h`, `linux/folio_batch.h`, `linux/swap.h`, `f2fs.h`.
- Detected declarations: `function is_invalid_nid`, `function f2fs_check_nid_range`, `function f2fs_available_free_memory`, `function clear_node_folio_dirty`, `function __free_nat_entry`, `function __gang_lookup_nat_cache`, `function __del_from_nat_cache`, `function __set_nat_cache_dirty`, `function __clear_nat_cache_dirty`, `function __gang_lookup_nat_set`.
- 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.