dentry_kill(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– dentry_kill(9) β€” Kernel API Manual πŸ’–

✨ NAME ✨

dentry_kill β€” evict a dentry πŸ’…βœ¨

🌸 SYNOPSIS 🌸

struct dentry * dentry_kill (struct dentry *dentry );

πŸŽ€ ARGUMENTS πŸŽ€

  • dentry β€” the dentry that's getting evicted, bestie πŸ’–

πŸ’« DESCRIPTION πŸ’«

Ok so literally every dentry eviction goes through this function β€” it's the main character of eviction szn. The reference handed to us does not count toward the refcount, because the caller either already decremented it or never held one at all. Also: dentry->d_lock is held by the caller and is dropped by dentry_kill(dentry) itself. Slay.

We've got a guarantee that nobody called dentry_free(dentry) before the start of the RCU read-side critical area we're sitting in. That's the vibe check we passed.

Caller must not access dentry after the call β€” like, not even a little. no peeking πŸ‘€

If evicting dentry drops the last reference to its parent, we return the reference to parent back to the caller. When that happens, it's guaranteed to meet the requirements for a dentry_kill argument β€” its ->d_lock is held, and nobody had passed it to dentry_free before its ->d_lock was acquired. If not, you get NULL back. No cap.

If dentry is idle and stays idle after we've assembled the full locking environment for eviction (details in lock_for_kill), we mark it doomed (see lockref_mark_dead) and move on to detaching it from any filesystem objects. If that's not the case, we drop ->d_lock and return NULL. πŸ’€

Once dentry is detached from the filesystem objects, we finish detaching it from the dentry tree. The parent, if there is one, gets locked and its refcount is decremented; dentry is carefully removed from the tree (details in dentry_unlist) and marked killed (DCACHE_DENTRY_KILLED is set in ->d_flags). At that point it's just an inert chunk of memory β€” only reachable through RCU references and maybe a shrink list. If it's not on any shrink lists, we call dentry_free, which schedules the actual memory freeing. Othewise, freeing is left to the owner of the shrink list in question. periodt.

🌈 SEE ALSO 🌈

mwah πŸ’‹ that's the tea from ./fs, dated October 2026 β€” dentry_kill(9) out, bestie! 🫢✨

πŸ“¦ where this page comes from