inode_insert5(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… inode_insert5(9) β€” like, the Kernel API Manual one, bestie

okay so picture this: it's the kernel, it's the inode cache, and you've already got an inode pre-made in your hand like a little πŸŽ€ gift πŸŽ€ and you just need to know β€” is this thing already in the cache, or do we slide it in? That's the whole vibe of inode_insert5(9). Let's get into it. ✨


✨ NAME ✨

inode_insert5 β€” obtain an inode from a mounted file system πŸ¦‹


✨ SYNOPSIS ✨

struct inode * inode_insert5 (struct inode *inode , u64 hashval , int
(*test)(struct inode *, void *) , int (*set)(struct inode *, void *) ,
void *data );

✨ ARGUMENTS ✨

  • inode β€” the pre-allocated inode you're gonna use for the insert into the cache 🫢 it's already yours, you're just deciding if it goes in.
  • hashval β€” the hash value (usually the inode number, ngl) that you're trying to get πŸ’«
  • test β€” the callback used for comparisons between inodes, i.e. the "are these two the same actually" checker πŸ‘€
  • set β€” the callback used to initialize a new struct inode 🌱 (this is how the fresh one gets its glow-up)
  • data β€” an opaque data pointer that gets passed to both test and set 🎁 iykyk

🌸 DESCRIPTION 🌸

So what it does: it searches the inode cache for the inode specified by hashval and data, and if it's already there β€” iconic β€” it returns it with an increased reference count πŸ’–

It's basically a variant of iget5_locked that doesn't allocate an inode. no cap, that's the whole difference. the allocation part? not her problem. πŸ™…β€β™€οΈ

But if the inode is not present in the cache? Then bestie, you insert the pre-allocated inode and return it locked, hashed, and with the I_NEW flag set πŸ”₯ The file system gets to fill it in before unlocking it via unlock_new_inode. That's the whole plan. ⭐

⚠️ important caveat, don't skip this one: both test and set are called with the inode_hash_lock held, so they can't sleep 😴🚫 like literally cannot. do not try it. πŸ’€

πŸ’œ SEE ALSO πŸ’œ

Kernel file ./fs/inode.c β€” and the whole extended friend group πŸ«‚βœ¨:


okay that's the whole page, you ate that πŸ“ this one came from ./fs in the October 2026 era of the Kernel API Manual, so go forth and insert those inodes correctly, bestie πŸ’…πŸ‘‘

πŸ“¦ where this page comes from