summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2026-04-11 23:17:19 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2026-06-05 07:34:55 +0300
commit4af0cdb5765ad15f4175bc94ca20b8deb2c7ebde (patch)
tree1d71da3243b8ae6b8df1a5a37e9eb80eed7ac26f
parentd197a9a6d44f23944d9096c5d955a7b1f75b0c89 (diff)
downloadlinux-4af0cdb5765ad15f4175bc94ca20b8deb2c7ebde.tar.xz
document dentry_kill()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/dcache.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 3887d8b5f81a..cf4bd6c37d04 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -752,6 +752,44 @@ static bool lock_for_kill(struct dentry *dentry)
return false;
}
+/**
+ * dentry_kill - evict a dentry
+ * @dentry: dentry to be evicted
+ *
+ * All dentry evictions are done by this function. The reference we are
+ * passed does not contribute to the refcount; the caller had either
+ * already decremented the refcount or it had never held one in the
+ * first place. @dentry->d_lock is held by the caller and dropped
+ * by dentry_kill(@dentry).
+ *
+ * We are guaranteed that nobody had called dentry_free(@dentry)
+ * prior to the beginning of RCU read-side critical area we are in.
+ *
+ * Caller must not access @dentry after the call.
+ *
+ * If eviction of @dentry drops the last reference to its parent,
+ * the reference to parent is returned to caller. In that case
+ * it is guaranteed to satisfy the requirements for dentry_kill()
+ * argument - its ->d_lock is held and we are guaranteed that nobody
+ * had passed it to dentry_free() prior to acquisition of its ->d_lock.
+ * Otherwise %NULL is returned.
+ *
+ * If @dentry is idle and remains such after we assemble the full
+ * locking environment for eviction (see lock_for_kill() for details)
+ * we mark it doomed (->d_lockref.count < 0) and proceed to detaching
+ * it from any filesystem objects. Otherwise we drop ->d_lock and
+ * return %NULL.
+ *
+ * Once @dentry is detached from the filesystem objects, we complete
+ * detaching it from dentry tree. The parent, if any, gets locked
+ * and its refcount is decremented; dentry is carefully removed from
+ * the tree (see dentry_unlist() for details) and marked killed
+ * (%DCACHE_DENTRY_KILLED set in ->d_flags). At that point it's just
+ * an inert chunk of memory, accessible only via RCU references
+ * and possibly via a shrink list. If it is not on any shrink lists,
+ * we call dentry_free(), which schedules actual freeing of memory.
+ * Othewise freeing is left to the owner of the shrink list in question.
+ */
static struct dentry *dentry_kill(struct dentry *dentry)
{
struct dentry *parent = NULL;