fs/ubifs/recovery.c
Source file repositories/reference/linux-study-clean/fs/ubifs/recovery.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ubifs/recovery.c- Extension
.c- Size
- 44072 bytes
- Lines
- 1587
- 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/crc32.hlinux/slab.hubifs.h
Detected Declarations
struct size_entryfunction Copyrightfunction first_non_fffunction get_master_nodefunction write_rcvrd_mst_nodefunction ubifs_recover_master_nodefunction ubifs_write_rcvrd_mst_nodefunction is_last_writefunction boundaryfunction no_more_nodesfunction fix_unclean_lebfunction drop_last_groupfunction drop_last_nodefunction get_cs_sqnumfunction recover_headfunction ubifs_recover_inl_headsfunction clean_an_unclean_lebfunction ubifs_clean_lebsfunction LEBfunction ubifs_rcvry_gc_commitfunction add_inofunction remove_inofunction ubifs_destroy_size_treefunction rbtree_postorder_for_each_entry_safefunction ubifs_recover_size_accumfunction fix_size_in_placefunction inode_fix_sizefunction ubifs_recover_size
Annotated Snippet
struct size_entry {
struct rb_node rb;
ino_t inum;
loff_t i_size;
loff_t d_size;
int exists;
struct inode *inode;
};
/**
* add_ino - add an entry to the size tree.
* @c: UBIFS file-system description object
* @inum: inode number
* @i_size: size on inode
* @d_size: maximum size based on data nodes
* @exists: indicates whether the inode exists
*/
static int add_ino(struct ubifs_info *c, ino_t inum, loff_t i_size,
loff_t d_size, int exists)
{
struct rb_node **p = &c->size_tree.rb_node, *parent = NULL;
struct size_entry *e;
while (*p) {
parent = *p;
e = rb_entry(parent, struct size_entry, rb);
if (inum < e->inum)
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
}
e = kzalloc_obj(struct size_entry);
if (!e)
return -ENOMEM;
e->inum = inum;
e->i_size = i_size;
e->d_size = d_size;
e->exists = exists;
rb_link_node(&e->rb, parent, p);
rb_insert_color(&e->rb, &c->size_tree);
return 0;
}
/**
* find_ino - find an entry on the size tree.
* @c: UBIFS file-system description object
* @inum: inode number
*/
static struct size_entry *find_ino(struct ubifs_info *c, ino_t inum)
{
struct rb_node *p = c->size_tree.rb_node;
struct size_entry *e;
while (p) {
e = rb_entry(p, struct size_entry, rb);
if (inum < e->inum)
p = p->rb_left;
else if (inum > e->inum)
p = p->rb_right;
else
return e;
}
return NULL;
}
/**
* remove_ino - remove an entry from the size tree.
* @c: UBIFS file-system description object
* @inum: inode number
*/
static void remove_ino(struct ubifs_info *c, ino_t inum)
{
struct size_entry *e = find_ino(c, inum);
if (!e)
return;
rb_erase(&e->rb, &c->size_tree);
kfree(e);
}
/**
* ubifs_destroy_size_tree - free resources related to the size tree.
* @c: UBIFS file-system description object
*/
void ubifs_destroy_size_tree(struct ubifs_info *c)
{
Annotation
- Immediate include surface: `linux/crc32.h`, `linux/slab.h`, `ubifs.h`.
- Detected declarations: `struct size_entry`, `function Copyright`, `function first_non_ff`, `function get_master_node`, `function write_rcvrd_mst_node`, `function ubifs_recover_master_node`, `function ubifs_write_rcvrd_mst_node`, `function is_last_write`, `function boundary`, `function no_more_nodes`.
- 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.