dget(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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:


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