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: linus-2.6.7-bk5/fs/dcache.c
8 ===================================================================
9 --- linus-2.6.7-bk5.orig/fs/dcache.c 2004-06-24 10:39:11.232154728 +0300
10 +++ linus-2.6.7-bk5/fs/dcache.c 2004-06-24 10:56:01.043640048 +0300
11 @@ -1115,16 +1115,23 @@
12 * Adds a dentry to the hash according to its name.
15 -void d_rehash(struct dentry * entry)
16 +void __d_rehash(struct dentry * entry)
18 struct hlist_head *list = d_hash(entry->d_parent, entry->d_name.hash);
20 - spin_lock(&dcache_lock);
21 spin_lock(&entry->d_lock);
22 entry->d_flags &= ~DCACHE_UNHASHED;
23 spin_unlock(&entry->d_lock);
24 entry->d_bucket = list;
25 hlist_add_head_rcu(&entry->d_hash, list);
28 +EXPORT_SYMBOL(__d_rehash);
30 +void d_rehash(struct dentry * entry)
32 + spin_lock(&dcache_lock);
34 spin_unlock(&dcache_lock);
37 @@ -1200,12 +1207,11 @@
38 * dcache entries should not be moved in this way.
41 -void d_move(struct dentry * dentry, struct dentry * target)
42 +void __d_move(struct dentry * dentry, struct dentry * target)
45 printk(KERN_WARNING "VFS: moving negative dcache entry\n");
47 - spin_lock(&dcache_lock);
48 write_seqlock(&rename_lock);
50 * XXXX: do we really need to take target->d_lock?
51 @@ -1257,6 +1263,14 @@
52 spin_unlock(&target->d_lock);
53 spin_unlock(&dentry->d_lock);
54 write_sequnlock(&rename_lock);
57 +EXPORT_SYMBOL(__d_move);
59 +void d_move(struct dentry *dentry, struct dentry *target)
61 + spin_lock(&dcache_lock);
62 + __d_move(dentry, target);
63 spin_unlock(&dcache_lock);
66 Index: linus-2.6.7-bk5/include/linux/dcache.h
67 ===================================================================
68 --- linus-2.6.7-bk5.orig/include/linux/dcache.h 2004-06-24 10:39:29.534372368 +0300
69 +++ linus-2.6.7-bk5/include/linux/dcache.h 2004-06-24 10:53:10.319594048 +0300
71 * This adds the entry to the hash queues.
73 extern void d_rehash(struct dentry *);
74 +extern void __d_rehash(struct dentry *);
77 * d_add - add dentry to hash queues
80 /* used for rename() and baskets */
81 extern void d_move(struct dentry *, struct dentry *);
82 +extern void __d_move(struct dentry *, struct dentry *);
84 /* appendix may either be NULL or be used for transname suffixes */
85 extern struct dentry * d_lookup(struct dentry *, struct qstr *);