fs/ubifs/lpt_commit.c
Source file repositories/reference/linux-study-clean/fs/ubifs/lpt_commit.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ubifs/lpt_commit.c- Extension
.c- Size
- 51788 bytes
- Lines
- 1996
- 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/crc16.hlinux/slab.hlinux/random.hubifs.h
Detected Declarations
function get_cnodes_to_commitfunction upd_ltabfunction alloc_lpt_lebfunction layout_cnodesfunction realloc_lpt_lebfunction write_cnodesfunction add_pnode_dirtfunction do_make_pnode_dirtyfunction make_tree_dirtyfunction need_write_allfunction lpt_tgc_startfunction completedfunction populate_lsavefunction list_for_each_entryfunction make_nnode_dirtyfunction make_pnode_dirtyfunction make_ltab_dirtyfunction make_lsave_dirtyfunction make_node_dirtyfunction get_lpt_node_lenfunction get_pad_lenfunction get_lpt_node_typefunction is_a_nodefunction lpt_gc_lnumfunction lpt_gcfunction ubifs_lpt_start_commitfunction free_obsolete_cnodesfunction ubifs_lpt_end_commitfunction ubifs_lpt_post_commitfunction ubifs_lpt_freefunction dbg_is_all_fffunction dbg_is_nnode_dirtyfunction dbg_is_pnode_dirtyfunction dbg_is_ltab_dirtyfunction dbg_is_lsave_dirtyfunction dbg_is_node_dirtyfunction dbg_check_ltab_lnumfunction dbg_check_ltabfunction dbg_chk_lpt_free_spcfunction dbg_chk_lpt_szfunction areafunction ubifs_dump_lpt_lebsfunction populated
Annotated Snippet
test_bit(DIRTY_CNODE, &cnode->flags)) {
if (cnode->level == 0)
return cnode;
nnode = (struct ubifs_nnode *)cnode;
cont = 1;
break;
}
}
if (!cont)
return (struct ubifs_cnode *)nnode;
}
}
/**
* next_dirty_cnode - find next dirty cnode.
* @c: UBIFS file-system description object
* @cnode: cnode from which to begin searching
*
* This function returns the next dirty cnode or %NULL if there is not one.
*/
static struct ubifs_cnode *next_dirty_cnode(const struct ubifs_info *c, struct ubifs_cnode *cnode)
{
struct ubifs_nnode *nnode;
int i;
ubifs_assert(c, cnode);
nnode = cnode->parent;
if (!nnode)
return NULL;
for (i = cnode->iip + 1; i < UBIFS_LPT_FANOUT; i++) {
cnode = nnode->nbranch[i].cnode;
if (cnode && test_bit(DIRTY_CNODE, &cnode->flags)) {
if (cnode->level == 0)
return cnode; /* cnode is a pnode */
/* cnode is a nnode */
return first_dirty_cnode(c, (struct ubifs_nnode *)cnode);
}
}
return (struct ubifs_cnode *)nnode;
}
/**
* get_cnodes_to_commit - create list of dirty cnodes to commit.
* @c: UBIFS file-system description object
*
* This function returns the number of cnodes to commit.
*/
static int get_cnodes_to_commit(struct ubifs_info *c)
{
struct ubifs_cnode *cnode, *cnext;
int cnt = 0;
if (!c->nroot)
return 0;
if (!test_bit(DIRTY_CNODE, &c->nroot->flags))
return 0;
c->lpt_cnext = first_dirty_cnode(c, c->nroot);
cnode = c->lpt_cnext;
if (!cnode)
return 0;
cnt += 1;
while (1) {
ubifs_assert(c, !test_bit(COW_CNODE, &cnode->flags));
__set_bit(COW_CNODE, &cnode->flags);
cnext = next_dirty_cnode(c, cnode);
if (!cnext) {
cnode->cnext = c->lpt_cnext;
break;
}
cnode->cnext = cnext;
cnode = cnext;
cnt += 1;
}
dbg_cmt("committing %d cnodes", cnt);
dbg_lp("committing %d cnodes", cnt);
ubifs_assert(c, cnt == c->dirty_nn_cnt + c->dirty_pn_cnt);
return cnt;
}
/**
* upd_ltab - update LPT LEB properties.
* @c: UBIFS file-system description object
* @lnum: LEB number
* @free: amount of free space
* @dirty: amount of dirty space to add
*/
static void upd_ltab(struct ubifs_info *c, int lnum, int free, int dirty)
{
Annotation
- Immediate include surface: `linux/crc16.h`, `linux/slab.h`, `linux/random.h`, `ubifs.h`.
- Detected declarations: `function get_cnodes_to_commit`, `function upd_ltab`, `function alloc_lpt_leb`, `function layout_cnodes`, `function realloc_lpt_leb`, `function write_cnodes`, `function add_pnode_dirt`, `function do_make_pnode_dirty`, `function make_tree_dirty`, `function need_write_all`.
- 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.