fs/ubifs/tnc_commit.c
Source file repositories/reference/linux-study-clean/fs/ubifs/tnc_commit.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ubifs/tnc_commit.c- Extension
.c- Size
- 28386 bytes
- Lines
- 1113
- 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/random.hubifs.h
Detected Declarations
function Copyrightfunction fill_gapfunction find_old_idxfunction is_idx_node_in_usefunction layout_leb_in_gapsfunction get_leb_cntfunction layout_in_gapsfunction layout_in_empty_spacefunction layout_commitfunction get_znodes_to_commitfunction alloc_idx_lebsfunction free_unused_idx_lebsfunction free_idx_lebsfunction ubifs_tnc_start_commitfunction write_indexfunction incrementedfunction free_obsolete_znodesfunction return_gap_lebsfunction ubifs_tnc_end_commit
Annotated Snippet
if (!zbr->lnum || !zbr->len) {
ubifs_err(c, "bad ref in znode");
ubifs_dump_znode(c, znode);
if (zbr->znode)
ubifs_dump_znode(c, zbr->znode);
return -EINVAL;
}
}
ubifs_prepare_node(c, idx, len, 0);
ubifs_node_calc_hash(c, idx, hash);
znode->lnum = lnum;
znode->offs = offs;
znode->len = len;
err = insert_old_idx_znode(c, znode);
/* Update the parent */
zp = znode->parent;
if (zp) {
struct ubifs_zbranch *zbr;
zbr = &zp->zbranch[znode->iip];
zbr->lnum = lnum;
zbr->offs = offs;
zbr->len = len;
ubifs_copy_hash(c, hash, zbr->hash);
} else {
c->zroot.lnum = lnum;
c->zroot.offs = offs;
c->zroot.len = len;
ubifs_copy_hash(c, hash, c->zroot.hash);
}
c->calc_idx_sz += ALIGN(len, 8);
atomic_long_dec(&c->dirty_zn_cnt);
ubifs_assert(c, ubifs_zn_dirty(znode));
ubifs_assert(c, ubifs_zn_cow(znode));
/*
* Note, unlike 'write_index()' we do not add memory barriers here
* because this function is called with @c->tnc_mutex locked.
*/
__clear_bit(DIRTY_ZNODE, &znode->flags);
__clear_bit(COW_ZNODE, &znode->flags);
return err;
}
/**
* fill_gap - make index nodes in gaps in dirty index LEBs.
* @c: UBIFS file-system description object
* @lnum: LEB number that gap appears in
* @gap_start: offset of start of gap
* @gap_end: offset of end of gap
* @dirt: adds dirty space to this
*
* This function returns the number of index nodes written into the gap.
*/
static int fill_gap(struct ubifs_info *c, int lnum, int gap_start, int gap_end,
int *dirt)
{
int len, gap_remains, gap_pos, written, pad_len;
ubifs_assert(c, (gap_start & 7) == 0);
ubifs_assert(c, (gap_end & 7) == 0);
ubifs_assert(c, gap_end >= gap_start);
gap_remains = gap_end - gap_start;
if (!gap_remains)
return 0;
gap_pos = gap_start;
written = 0;
while (c->enext) {
len = ubifs_idx_node_sz(c, c->enext->child_cnt);
if (len < gap_remains) {
struct ubifs_znode *znode = c->enext;
const int alen = ALIGN(len, 8);
int err;
ubifs_assert(c, alen <= gap_remains);
err = make_idx_node(c, c->ileb_buf + gap_pos, znode,
lnum, gap_pos, len);
if (err)
return err;
gap_remains -= alen;
gap_pos += alen;
c->enext = znode->cnext;
Annotation
- Immediate include surface: `linux/random.h`, `ubifs.h`.
- Detected declarations: `function Copyright`, `function fill_gap`, `function find_old_idx`, `function is_idx_node_in_use`, `function layout_leb_in_gaps`, `function get_leb_cnt`, `function layout_in_gaps`, `function layout_in_empty_space`, `function layout_commit`, `function get_znodes_to_commit`.
- 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.