lnc_add(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… lnc_add β€” from the Kernel API Manual, bestie πŸ’–

Okay so real talk, we're in lnc_add(9) today and it's literally the "add a leaf node to the leaf node cache" girlie. That's the whole vibe. Let's get into it ✨


🌸 SYNOPSIS 🌸

int lnc_add (struct ubifs_info *c , struct ubifs_zbranch *zbr , const
       void *node );

Like, she takes three things and returns an int. Periodt.


πŸŽ€ ARGUMENTS πŸŽ€

  • c β€” the UBIFS file-system description object, your classic main-character context struct 🫢
  • zbr β€” the zbranch of the leaf node. yes. that one.
  • node β€” the leaf node itself, the whole point of the function ngl

πŸ¦‹ DESCRIPTION πŸ¦‹

So first things first: leaf nodes are the non-index nodes β€” either directory entry nodes or data nodes. That's the definition, no cap.

The purpose of the leaf node cache (LNC for the girlies in the know, iykyk) is to save re-reading the same leaf node over and over again 😭 because doing that is giving wasted effort. Most things are cached by VFS, but β€” and this is the plot twist β€” the file system must cache directory entries for readdir and for resolving hash collisions. So LNC exists. Slay.

The present implementation of the leaf node cache is extremely simple, and it allows for error returns that are not used but that may be needed if a more complex implementation is created later. So like, the error returns are just sitting there being iconic and unemployed πŸ’€ but they're there for the future.

⚠️ Note bestie, this is important: this function does not add the node object to LNC directly. It allocates a copy of the object and adds the copy to LNC. Don't get it twisted πŸ™ˆ

The reason for that whole copy situation is that node has been allocated outside of the TNC subsystem and will be used with c->tnc_mutex unlock upon return from the TNC subsystem. But LNC may be changed at any time β€” e.g. freed by the shrinker. So yeah, the copy is protecting you. She's a bodyguard 🧚


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./fs/ubifs/tnc.c plus this absolutely stacked friend group, fr fr:


Okay that's the whole page, bestie, you ate that πŸ’…βœ¨ This little gem comes to you from ./fs/ubifs, dated October 2026 β€” mwah, go read some more kernel docs, ily πŸ“πŸ’œ

πŸ“¦ where this page comes from