sort_nodes(9)
β¨ sort_nodes(9) β the UBIFS glow-up π
okay so real talk, bestie: this is a Kernel API Manual page for sort_nodes, and it is genuinely the main character of garbage collection in UBIFS. It's the function that literally sorts your nodes so GC doesn't have to be messy. no cap. π
πΈ NAME πΈ
sort_nodes β sort nodes for GC. that's it, that's the vibe. β¨
π¦ SYNOPSIS π¦
int sort_nodes (struct ubifs_info *c , struct ubifs_scan_leb *sleb ,
struct list_head *nondata , int *min );
π ARGUMENTS π
cβ the UBIFS file-system description object. your whole file-system situation, basically. π«Άslebβ describes the nodes to sort, and on exit it's holding the result. so it comes in describing, goes out serving. πnondataβ on exit this contains the non-data nodes. that's the whole job. β¨minβ the minimum node size gets returned right here. cute little out-param. π
π₯ DESCRIPTION π₯
okay so this function sorts the list of inodes to garbage collect. that's the mission. π«‘
First of all, it kills obsolete nodes (π bye bestie) and separates data and non-data nodes off into the sleb->nodes and nondata lists correspondingly.
Then the data nodes get sorted in block number order β and this is important for bulk-read, iykyk. the rules are:
- data nodes with lower inode number go before data nodes with higher inode number β
- data nodes with lower block number go before data nodes with higher block number β
Non-data nodes get sorted like this:
- first go inode nodes β they're sorted in descending length order π
- then go directory entry nodes β they're sorted in hash order, which should supposedly optimize
'readdir'. and specifically:- direntry nodes with lower parent inode number go before direntry nodes with higher parent inode number π
- direntry nodes with lower name hash values go before direntry nodes with higher name hash values π
This function returns zero in case of success and a negative error code in case of failure. no in-between, no drama (well, the negative error code is the drama π).
π SEE ALSO π
Kernel file ./fs/ubifs/gc.c and its whole friend group, fr fr:
switch_gc_head(9)data_nodes_cmp(9)move_node(9)move_nodes(9)gc_sync_wbufs(9)ubifs_garbage_collect_leb(9)ubifs_garbage_collect(9)ubifs_gc_start_commit(9)ubifs_gc_end_commit(9)ubifs_destroy_idx_gc(9)ubifs_get_idx_gc_leb(9)
π‘ friendly reminder: this page lives under ./fs/ubifs, and it's the October 2026 vintage. slay.
and that's the whole page, bestie β go forth and sort responsibly. π§π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms