1 Introduce lock-free versions of d_rehash and d_move.
3 fs/dcache.c | 22 ++++++++++++++++++----
4 include/linux/dcache.h | 2 ++
5 2 files changed, 20 insertions(+), 4 deletions(-)
7 Index: linux-2.6.10/fs/dcache.c
8 ===================================================================
9 --- linux-2.6.10.orig/fs/dcache.c 2005-03-31 15:35:26.000000000 +0800
10 +++ linux-2.6.10/fs/dcache.c 2005-03-31 19:16:50.807244880 +0800
11 @@ -1116,29 +1116,23 @@
12 spin_unlock(&dcache_lock);
15 -static void __d_rehash(struct dentry * entry, struct hlist_head *list)
16 +void __d_rehash(struct dentry * entry)
19 - entry->d_flags &= ~DCACHE_UNHASHED;
20 - hlist_add_head_rcu(&entry->d_hash, list);
21 + struct hlist_head *list = d_hash(entry->d_parent, entry->d_name.hash);
23 + spin_lock(&entry->d_lock);
24 + entry->d_flags &= ~DCACHE_UNHASHED;
25 + hlist_add_head_rcu(&entry->d_hash, list);
26 + spin_unlock(&entry->d_lock);
30 - * d_rehash - add an entry back to the hash
31 - * @entry: dentry to add to the hash
33 - * Adds a dentry to the hash according to its name.
36 +EXPORT_SYMBOL(__d_rehash);
38 void d_rehash(struct dentry * entry)
40 - struct hlist_head *list = d_hash(entry->d_parent, entry->d_name.hash);
42 - spin_lock(&dcache_lock);
43 - spin_lock(&entry->d_lock);
44 - __d_rehash(entry, list);
45 - spin_unlock(&entry->d_lock);
46 - spin_unlock(&dcache_lock);
47 + spin_lock(&dcache_lock);
49 + spin_unlock(&dcache_lock);
52 #define do_switch(x,y) do { \
53 @@ -1213,14 +1207,13 @@
54 * dcache entries should not be moved in this way.
57 -void d_move(struct dentry * dentry, struct dentry * target)
58 +void __d_move(struct dentry * dentry, struct dentry * target)
60 struct hlist_head *list;
63 printk(KERN_WARNING "VFS: moving negative dcache entry\n");
65 - spin_lock(&dcache_lock);
66 write_seqlock(&rename_lock);
68 * XXXX: do we really need to take target->d_lock?
72 list = d_hash(target->d_parent, target->d_name.hash);
73 - __d_rehash(dentry, list);
74 + dentry->d_flags &= ~DCACHE_UNHASHED;
75 + hlist_add_head_rcu(&dentry->d_hash, list);
77 /* Unhash the target: dput() will then get rid of it */
79 @@ -1280,6 +1274,14 @@
80 spin_unlock(&target->d_lock);
81 spin_unlock(&dentry->d_lock);
82 write_sequnlock(&rename_lock);
85 +EXPORT_SYMBOL(__d_move);
87 +void d_move(struct dentry *dentry, struct dentry *target)
89 + spin_lock(&dcache_lock);
90 + __d_move(dentry, target);
91 spin_unlock(&dcache_lock);
94 Index: linux-2.6.10/include/linux/dcache.h
95 ===================================================================
96 --- linux-2.6.10.orig/include/linux/dcache.h 2005-03-31 15:35:26.000000000 +0800
97 +++ linux-2.6.10/include/linux/dcache.h 2005-03-31 19:15:49.684536944 +0800
99 * This adds the entry to the hash queues.
101 extern void d_rehash(struct dentry *);
102 +extern void __d_rehash(struct dentry *);
105 * d_add - add dentry to hash queues
108 /* used for rename() and baskets */
109 extern void d_move(struct dentry *, struct dentry *);
110 +extern void __d_move(struct dentry *, struct dentry *);
112 /* appendix may either be NULL or be used for transname suffixes */
113 extern struct dentry * d_lookup(struct dentry *, struct qstr *);