1D_LOOKUP(9) The Linux VFS D_LOOKUP(9)
2
3
4
6 d_lookup - search for a dentry
7
9 struct dentry * d_lookup(struct dentry * parent, struct qstr * name);
10
12 parent
13 parent dentry
14
15 name
16 qstr of name we wish to find
17
19 Searches the children of the parent dentry for the name in question. If
20 the dentry is found its reference count is incremented and the dentry
21 is returned. The caller must use dput to free the entry when it has
22 finished using it. NULL is returned on failure.
23
24 __d_lookup is dcache_lock free. The hash list is protected using RCU.
25 Memory barriers are used while updating and doing lockless traversal.
26 To avoid races with d_move while rename is happening, d_lock is used.
27
28 Overflows in memcmp, while d_move, are avoided by keeping the length
29 and name pointer in one structure pointed by d_qstr.
30
31 rcu_read_lock and rcu_read_unlock are used to disable preemption while
32 lookup is going on.
33
34 The dentry unused LRU is not updated even if lookup finds the required
35 dentry in there. It is updated in places such as prune_dcache,
36 shrink_dcache_sb, select_parent and __dget_locked. This laziness saves
37 lookup from dcache_lock acquisition.
38
39 d_lookup is protected against the concurrent renames in some unrelated
40 directory using the seqlockt_t rename_lock.
41
43Kernel Hackers Manual 2.6. November 2011 D_LOOKUP(9)