Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs-dcache_locking-vanilla-2.6.10-fc3.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: 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);
13  }
14  
15 -static void __d_rehash(struct dentry * entry, struct hlist_head *list)
16 +void __d_rehash(struct dentry * entry)
17  {
18 -
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);
22 +  
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);
27  }
28 -
29 -/**
30 - * d_rehash    - add an entry back to the hash
31 - * @entry: dentry to add to the hash
32 - *
33 - * Adds a dentry to the hash according to its name.
34 - */
35   
36 +EXPORT_SYMBOL(__d_rehash);
37 +  
38  void d_rehash(struct dentry * entry)
39  {
40 -       struct hlist_head *list = d_hash(entry->d_parent, entry->d_name.hash);
41 -
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);
48 +       __d_rehash(entry);
49 +       spin_unlock(&dcache_lock);
50  }
51  
52  #define do_switch(x,y) do { \
53 @@ -1213,14 +1207,13 @@
54   * dcache entries should not be moved in this way.
55   */
56  
57 -void d_move(struct dentry * dentry, struct dentry * target)
58 +void __d_move(struct dentry * dentry, struct dentry * target)
59  {
60         struct hlist_head *list;
61  
62         if (!dentry->d_inode)
63                 printk(KERN_WARNING "VFS: moving negative dcache entry\n");
64  
65 -       spin_lock(&dcache_lock);
66         write_seqlock(&rename_lock);
67         /*
68          * XXXX: do we really need to take target->d_lock?
69 @@ -1241,7 +1234,8 @@
70  
71  already_unhashed:
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);
76  
77         /* Unhash the target: dput() will then get rid of it */
78         __d_drop(target);
79 @@ -1280,6 +1274,14 @@
80         spin_unlock(&target->d_lock);
81         spin_unlock(&dentry->d_lock);
82         write_sequnlock(&rename_lock);
83 +}
84 +
85 +EXPORT_SYMBOL(__d_move);
86 +
87 +void d_move(struct dentry *dentry, struct dentry *target)
88 +{
89 +       spin_lock(&dcache_lock);
90 +       __d_move(dentry, target);
91         spin_unlock(&dcache_lock);
92  }
93  
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
98 @@ -228,6 +228,7 @@
99   * This adds the entry to the hash queues.
100   */
101  extern void d_rehash(struct dentry *);
102 +extern void __d_rehash(struct dentry *);
103  
104  /**
105   * d_add - add dentry to hash queues
106 @@ -246,6 +247,7 @@
107  
108  /* used for rename() and baskets */
109  extern void d_move(struct dentry *, struct dentry *);
110 +extern void __d_move(struct dentry *, struct dentry *);
111  
112  /* appendix may either be NULL or be used for transname suffixes */
113  extern struct dentry * d_lookup(struct dentry *, struct qstr *);