find_inode_nowait(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ find_inode_nowait(9) β€” a Kernel API Manual moment πŸ¦‹

Okay bestie, this one is so niche but honestly kind of iconic. It’s the manual page for find_inode_nowait, and we’re about to make inode-cache searching make sense. No cap.


πŸ’– NAME πŸ’–

find_inode_nowait β€” find an inode in the inode cache. That’s the whole vibe. πŸŽ€

✨ SYNOPSIS ✨

struct inode * find_inode_nowait (struct super_block *sb , u64 hashval , int (*match)(struct inode *, u64, void *) , void *data );

πŸŽ€ ARGUMENTS πŸŽ€

  • sb β€” super block of file system to search. Like, which filesystem’s cache are we digging through? πŸ—‚οΈ
  • hashval β€” hash value (usually inode number) to search for. This is the target. 🎯
  • match β€” callback used for comparisons between inodes. It’s the little judge that says yes/no/stop. βš–οΈ
  • data β€” opaque data pointer to pass to match. Extra luggage, but make it cute. 🧳

πŸ’… DESCRIPTION πŸ’…

So we’re searching for the inode specified by hashval and data in the inode cache. The helper function match is the one doing the vibe check: it returns 0 if the inode does not match, 1 if the inode does match, and -1 if the search should be stopped. Very demure, very mindful. 🧚

But bestie, match has responsibilities. It must be responsible for taking the i_lock spin_lock and checking i_state for an inode being freed or being initialized, and incrementing the reference count before returning 1. It also must not sleep, since it is called with the inode_hash_lock spinlock held. Literally do not nap on the job. 😭

🚨 Warning-ish energy: match must not sleep β€” it’s running with the inode_hash_lock spinlock held. Also, the reference-count increment and the i_lock / i_state checks are on match to handle. No passing the buck. πŸ’€

This is a even more generalized version of ilookup5 when the function must never block --- find_inode can block in __wait_on_freeing_inode --- or when the caller can not increment the reference count because the resulting iput might cause an inode eviction. The tradeoff is that the match funtion must be very carefully implemented. Like, highkey carefully. πŸ”₯

πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./fs/inode.c and the whole friend group:


xoxo, bestie β€” source/version: ./fs πŸ’œ date: October 2026 πŸ’œ manual: find_inode_nowait(9)

πŸ“¦ where this page comes from