fs/ubifs/orphan.c
Source file repositories/reference/linux-study-clean/fs/ubifs/orphan.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ubifs/orphan.c- Extension
.c- Size
- 24312 bytes
- Lines
- 948
- 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
ubifs.h
Detected Declarations
struct check_orphanstruct check_infofunction ubifs_add_orphanfunction __orphan_dropfunction orphan_deletefunction ubifs_delete_orphanfunction ubifs_orphan_start_commitfunction avail_orphsfunction tot_avail_orphsfunction do_write_orph_nodefunction write_orph_nodefunction write_orph_nodesfunction consolidatefunction list_for_each_entryfunction commit_orphansfunction erase_deletedfunction ubifs_orphan_end_commitfunction ubifs_clear_orphansfunction do_kill_orphansfunction list_for_each_entryfunction linkatfunction sessionfunction ubifs_mount_orphansfunction dbg_find_orphanfunction dbg_ins_check_orphanfunction dbg_find_check_orphanfunction dbg_free_check_treefunction dbg_orphan_checkfunction dbg_read_orphansfunction list_for_each_entryfunction dbg_scan_orphansfunction dbg_check_orphans
Annotated Snippet
struct check_orphan {
struct rb_node rb;
ino_t inum;
};
struct check_info {
unsigned long last_ino;
unsigned long tot_inos;
unsigned long missing;
unsigned long long leaf_cnt;
struct ubifs_ino_node *node;
struct rb_root root;
};
static bool dbg_find_orphan(struct ubifs_info *c, ino_t inum)
{
bool found = false;
spin_lock(&c->orphan_lock);
found = !!lookup_orphan(c, inum);
spin_unlock(&c->orphan_lock);
return found;
}
static int dbg_ins_check_orphan(struct rb_root *root, ino_t inum)
{
struct check_orphan *orphan, *o;
struct rb_node **p, *parent = NULL;
orphan = kzalloc_obj(struct check_orphan, GFP_NOFS);
if (!orphan)
return -ENOMEM;
orphan->inum = inum;
p = &root->rb_node;
while (*p) {
parent = *p;
o = rb_entry(parent, struct check_orphan, rb);
if (inum < o->inum)
p = &(*p)->rb_left;
else if (inum > o->inum)
p = &(*p)->rb_right;
else {
kfree(orphan);
return 0;
}
}
rb_link_node(&orphan->rb, parent, p);
rb_insert_color(&orphan->rb, root);
return 0;
}
static int dbg_find_check_orphan(struct rb_root *root, ino_t inum)
{
struct check_orphan *o;
struct rb_node *p;
p = root->rb_node;
while (p) {
o = rb_entry(p, struct check_orphan, rb);
if (inum < o->inum)
p = p->rb_left;
else if (inum > o->inum)
p = p->rb_right;
else
return 1;
}
return 0;
}
static void dbg_free_check_tree(struct rb_root *root)
{
struct check_orphan *o, *n;
rbtree_postorder_for_each_entry_safe(o, n, root, rb)
kfree(o);
}
static int dbg_orphan_check(struct ubifs_info *c, struct ubifs_zbranch *zbr,
void *priv)
{
struct check_info *ci = priv;
ino_t inum;
int err;
inum = key_inum(c, &zbr->key);
if (inum != ci->last_ino) {
/*
* Lowest node type is the inode node or xattr entry(when
Annotation
- Immediate include surface: `ubifs.h`.
- Detected declarations: `struct check_orphan`, `struct check_info`, `function ubifs_add_orphan`, `function __orphan_drop`, `function orphan_delete`, `function ubifs_delete_orphan`, `function ubifs_orphan_start_commit`, `function avail_orphs`, `function tot_avail_orphs`, `function do_write_orph_node`.
- 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.