Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs-dcache_locking-vanilla-2.6.patch
1 Introduce lock-free versions of d_rehash and d_move.
2
3  fs/dcache.c            |   22 ++++++++++++++++++----
4  include/linux/dcache.h |    2 ++
5  2 files changed, 20 insertions(+), 4 deletions(-)
6
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.
13   */
14   
15 -void d_rehash(struct dentry * entry)
16 +void __d_rehash(struct dentry * entry)
17  {
18         struct hlist_head *list = d_hash(entry->d_parent, entry->d_name.hash);
19  
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);
26 +}
27 +
28 +EXPORT_SYMBOL(__d_rehash);
29
30 +void d_rehash(struct dentry * entry)
31 +{
32 +       spin_lock(&dcache_lock);
33 +       __d_rehash(entry);
34         spin_unlock(&dcache_lock);
35  }
36  
37 @@ -1200,12 +1207,11 @@
38   * dcache entries should not be moved in this way.
39   */
40  
41 -void d_move(struct dentry * dentry, struct dentry * target)
42 +void __d_move(struct dentry * dentry, struct dentry * target)
43  {
44         if (!dentry->d_inode)
45                 printk(KERN_WARNING "VFS: moving negative dcache entry\n");
46  
47 -       spin_lock(&dcache_lock);
48         write_seqlock(&rename_lock);
49         /*
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);
55 +}
56 +
57 +EXPORT_SYMBOL(__d_move);
58 +
59 +void d_move(struct dentry *dentry, struct dentry *target)
60 +{
61 +       spin_lock(&dcache_lock);
62 +       __d_move(dentry, target);
63         spin_unlock(&dcache_lock);
64  }
65  
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
70 @@ -227,6 +227,7 @@
71   * This adds the entry to the hash queues.
72   */
73  extern void d_rehash(struct dentry *);
74 +extern void __d_rehash(struct dentry *);
75  
76  /**
77   * d_add - add dentry to hash queues
78 @@ -245,6 +246,7 @@
79  
80  /* used for rename() and baskets */
81  extern void d_move(struct dentry *, struct dentry *);
82 +extern void __d_move(struct dentry *, struct dentry *);
83  
84  /* appendix may either be NULL or be used for transname suffixes */
85  extern struct dentry * d_lookup(struct dentry *, struct qstr *);