dget(9)
π dget (kernel API manual, bestie edition)
okay so this is dget from the Kernel API Manual β section 9, the kernel-space girlies. we're talking dentries. buckle up π
β¨ NAME β¨
dget β get a reference to a dentry. literally just. grab a ref. that's the whole job π«Ά
β¨ SYNOPSIS β¨
struct dentry * dget (struct dentry *dentry );
β¨ ARGUMENTS β¨
dentryβ the dentry you want a reference to. that's it. that's the argument π
β¨ DESCRIPTION β¨
ok so picture this: you hand it a dentry, or a NULL pointer, and it bumps the reference count if appropriate and hands the dentry right back to you. that's the vibe. β¨
the important part, bestie, is a dentry will not be destroyed while it has references. periodt. that's the whole safety guarantee.
conversely β and this is the part where you gotta pay attention π β a dentry with no references can disappear for any number of reasons, starting with memory pressure. like, it's just gone. no warning. no text. nothing.
so in other words: this primitive is used to clone an existing reference. if you're using it on something with a zero refcount? that's a bug. not a quirky little oopsie. a bug. π
β¨ NOTE β¨
it will spin if dentry->d_lock is held. π
from the deadlock-avoidance point of view, it's equivalent to spin_lock / increment refcount / spin_unlock. which means calling it under dentry->d_lock is always a bug. and so is calling it under ->d_lock on any of its descendents. yes, any of them. i don't make the rules, the kernel does π§
β¨ SEE ALSO β¨
Kernel file ./include/linux/dcache.h, plus the whole friend group:
dget_dlock(9)d_unhashed(9)d_really_is_negative(9)d_really_is_positive(9)d_inode(9)d_inode_rcu(9)d_backing_inode(9)d_real(9)d_real_inode(9)
and that's the page, bestie πΈ this one lives at ./include/linux and it's dated October 2026, filed under dget(9) in the Kernel API Manual. go clone some references 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