fs/ubifs/lprops.c
Source file repositories/reference/linux-study-clean/fs/ubifs/lprops.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ubifs/lprops.c- Extension
.c- Size
- 36244 bytes
- Lines
- 1308
- 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
function Copyrightfunction move_up_lpt_heapfunction adjust_lpt_heapfunction add_to_lpt_heapfunction remove_from_lpt_heapfunction pnodefunction ubifs_add_to_catfunction ubifs_remove_from_catfunction pnodefunction ubifs_ensure_catfunction ubifs_categorize_lpropsfunction change_categoryfunction ubifs_calc_darkfunction is_lprops_dirtyfunction propertiesfunction ubifs_get_lp_statsfunction ubifs_change_one_lpfunction ubifs_update_one_lpfunction ubifs_read_one_lpfunction dbg_check_catsfunction list_for_each_entryfunction list_for_each_entryfunction dbg_check_heapfunction memoryfunction list_for_each_entryfunction locked
Annotated Snippet
if (val1 > val2) {
/* Greater than parent so move up */
while (1) {
heap->arr[ppos]->hpos = hpos;
heap->arr[hpos] = heap->arr[ppos];
heap->arr[ppos] = lprops;
lprops->hpos = ppos;
hpos = ppos;
if (!hpos)
return;
ppos = (hpos - 1) / 2;
val2 = get_heap_comp_val(heap->arr[ppos], cat);
if (val1 <= val2)
return;
/* Still greater than parent so keep going */
}
}
}
/* Not greater than parent, so compare to children */
while (1) {
/* Compare to left child */
cpos = hpos * 2 + 1;
if (cpos >= heap->cnt)
return;
val2 = get_heap_comp_val(heap->arr[cpos], cat);
if (val1 < val2) {
/* Less than left child, so promote biggest child */
if (cpos + 1 < heap->cnt) {
val3 = get_heap_comp_val(heap->arr[cpos + 1],
cat);
if (val3 > val2)
cpos += 1; /* Right child is bigger */
}
heap->arr[cpos]->hpos = hpos;
heap->arr[hpos] = heap->arr[cpos];
heap->arr[cpos] = lprops;
lprops->hpos = cpos;
hpos = cpos;
continue;
}
/* Compare to right child */
cpos += 1;
if (cpos >= heap->cnt)
return;
val3 = get_heap_comp_val(heap->arr[cpos], cat);
if (val1 < val3) {
/* Less than right child, so promote right child */
heap->arr[cpos]->hpos = hpos;
heap->arr[hpos] = heap->arr[cpos];
heap->arr[cpos] = lprops;
lprops->hpos = cpos;
hpos = cpos;
continue;
}
return;
}
}
/**
* add_to_lpt_heap - add LEB properties to a LEB category heap.
* @c: UBIFS file-system description object
* @lprops: LEB properties to add
* @cat: LEB category
*
* This function returns %1 if @lprops is added to the heap for LEB category
* @cat, otherwise %0 is returned because the heap is full.
*/
static int add_to_lpt_heap(struct ubifs_info *c, struct ubifs_lprops *lprops,
int cat)
{
struct ubifs_lpt_heap *heap = &c->lpt_heap[cat - 1];
if (heap->cnt >= heap->max_cnt) {
const int b = LPT_HEAP_SZ / 2 - 1;
int cpos, val1, val2;
/* Compare to some other LEB on the bottom of heap */
/* Pick a position kind of randomly */
cpos = (((size_t)lprops >> 4) & b) + b;
ubifs_assert(c, cpos >= b);
ubifs_assert(c, cpos < LPT_HEAP_SZ);
ubifs_assert(c, cpos < heap->cnt);
val1 = get_heap_comp_val(lprops, cat);
val2 = get_heap_comp_val(heap->arr[cpos], cat);
if (val1 > val2) {
struct ubifs_lprops *lp;
lp = heap->arr[cpos];
Annotation
- Immediate include surface: `ubifs.h`.
- Detected declarations: `function Copyright`, `function move_up_lpt_heap`, `function adjust_lpt_heap`, `function add_to_lpt_heap`, `function remove_from_lpt_heap`, `function pnode`, `function ubifs_add_to_cat`, `function ubifs_remove_from_cat`, `function pnode`, `function ubifs_ensure_cat`.
- 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.