dentry_kill(9)
π 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 π
- Kernel file:
./fs/dcache.c d_drop(9)__move_to_shrink_list(9)d_find_any_alias(9)d_find_alias(9)prune_dcache_sb(9)shrink_dcache_sb(9)enum d_walk_ret(9)d_walk(9)path_has_submounts(9)shrink_dcache_tree(9)d_invalidate(9)__d_alloc(9)d_alloc(9)d_alloc_pseudo(9)d_instantiate(9)d_obtain_alias(9)d_obtain_root(9)d_add_ci(9)d_same_name(9)__d_lookup_rcu(9)d_lookup(9)__d_lookup(9)d_hash_and_lookup(9)d_delete(9)d_rehash(9)d_add(9)d_ancestor(9)d_splice_alias(9)is_subdir(9)
mwah π that's the tea from ./fs, dated October 2026 β dentry_kill(9) out, 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