inode_insert5(9)
π 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 newstruct inodeπ± (this is how the fresh one gets its glow-up)dataβ an opaque data pointer that gets passed to bothtestandsetπ 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: bothtestandsetare called with theinode_hash_lockheld, 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 π«β¨:
inode_init_always_gfp(9)alloc_inode(9)drop_nlink(9)clear_nlink(9)set_nlink(9)inc_nlink(9)inode_sb_list_add(9)__insert_inode_hash(9)__remove_inode_hash(9)evict_inodes(9)new_inode(9)unlock_new_inode(9)lock_two_nondirectories(9)unlock_two_nondirectories(9)iget5_locked(9)iget5_locked_rcu(9)iget_locked(9)iunique(9)ihold(9)ilookup5_nowait(9)ilookup5(9)ilookup(9)find_inode_nowait(9)find_inode_rcu(9)find_inode_by_ino_rcu(9)iput(9)iput_not_last(9)bmap(9)inode_update_time(9)generic_update_time(9)atime_needs_update(9)file_remove_privs(9)current_time(9)file_update_time(9)file_modified_flags(9)file_modified(9)kiocb_modified(9)inode_init_owner(9)inode_owner_or_capable(9)inode_dio_wait(9)timestamp_truncate(9)inode_set_ctime_current(9)inode_set_ctime_deleg(9)in_group_or_capable(9)mode_strip_sgid(9)dump_inode(9)
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
- 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