Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / vfs-dcache_locking-vanilla-2.6.10-fc3.patch
diff --git a/lustre/kernel_patches/patches/vfs-dcache_locking-vanilla-2.6.10-fc3.patch b/lustre/kernel_patches/patches/vfs-dcache_locking-vanilla-2.6.10-fc3.patch
new file mode 100644 (file)
index 0000000..16ae126
--- /dev/null
@@ -0,0 +1,113 @@
+Introduce lock-free versions of d_rehash and d_move.
+
+ fs/dcache.c            |   22 ++++++++++++++++++----
+ include/linux/dcache.h |    2 ++
+ 2 files changed, 20 insertions(+), 4 deletions(-)
+
+Index: linux-2.6.10/fs/dcache.c
+===================================================================
+--- linux-2.6.10.orig/fs/dcache.c      2005-03-31 15:35:26.000000000 +0800
++++ linux-2.6.10/fs/dcache.c   2005-03-31 19:16:50.807244880 +0800
+@@ -1116,29 +1116,23 @@
+       spin_unlock(&dcache_lock);
+ }
+-static void __d_rehash(struct dentry * entry, struct hlist_head *list)
++void __d_rehash(struct dentry * entry)
+ {
+-
+-      entry->d_flags &= ~DCACHE_UNHASHED;
+-      hlist_add_head_rcu(&entry->d_hash, list);
++      struct hlist_head *list = d_hash(entry->d_parent, entry->d_name.hash);
++  
++      spin_lock(&entry->d_lock);
++      entry->d_flags &= ~DCACHE_UNHASHED;
++      hlist_add_head_rcu(&entry->d_hash, list);
++      spin_unlock(&entry->d_lock);
+ }
+-
+-/**
+- * d_rehash   - add an entry back to the hash
+- * @entry: dentry to add to the hash
+- *
+- * Adds a dentry to the hash according to its name.
+- */
+  
++EXPORT_SYMBOL(__d_rehash);
++  
+ void d_rehash(struct dentry * entry)
+ {
+-      struct hlist_head *list = d_hash(entry->d_parent, entry->d_name.hash);
+-
+-      spin_lock(&dcache_lock);
+-      spin_lock(&entry->d_lock);
+-      __d_rehash(entry, list);
+-      spin_unlock(&entry->d_lock);
+-      spin_unlock(&dcache_lock);
++      spin_lock(&dcache_lock);
++      __d_rehash(entry);
++      spin_unlock(&dcache_lock);
+ }
+ #define do_switch(x,y) do { \
+@@ -1213,14 +1207,13 @@
+  * dcache entries should not be moved in this way.
+  */
+-void d_move(struct dentry * dentry, struct dentry * target)
++void __d_move(struct dentry * dentry, struct dentry * target)
+ {
+       struct hlist_head *list;
+       if (!dentry->d_inode)
+               printk(KERN_WARNING "VFS: moving negative dcache entry\n");
+-      spin_lock(&dcache_lock);
+       write_seqlock(&rename_lock);
+       /*
+        * XXXX: do we really need to take target->d_lock?
+@@ -1241,7 +1234,8 @@
+ already_unhashed:
+       list = d_hash(target->d_parent, target->d_name.hash);
+-      __d_rehash(dentry, list);
++      dentry->d_flags &= ~DCACHE_UNHASHED;
++      hlist_add_head_rcu(&dentry->d_hash, list);
+       /* Unhash the target: dput() will then get rid of it */
+       __d_drop(target);
+@@ -1280,6 +1274,14 @@
+       spin_unlock(&target->d_lock);
+       spin_unlock(&dentry->d_lock);
+       write_sequnlock(&rename_lock);
++}
++
++EXPORT_SYMBOL(__d_move);
++
++void d_move(struct dentry *dentry, struct dentry *target)
++{
++      spin_lock(&dcache_lock);
++      __d_move(dentry, target);
+       spin_unlock(&dcache_lock);
+ }
+Index: linux-2.6.10/include/linux/dcache.h
+===================================================================
+--- linux-2.6.10.orig/include/linux/dcache.h   2005-03-31 15:35:26.000000000 +0800
++++ linux-2.6.10/include/linux/dcache.h        2005-03-31 19:15:49.684536944 +0800
+@@ -228,6 +228,7 @@
+  * This adds the entry to the hash queues.
+  */
+ extern void d_rehash(struct dentry *);
++extern void __d_rehash(struct dentry *);
+ /**
+  * d_add - add dentry to hash queues
+@@ -246,6 +247,7 @@
+ /* used for rename() and baskets */
+ extern void d_move(struct dentry *, struct dentry *);
++extern void __d_move(struct dentry *, struct dentry *);
+ /* appendix may either be NULL or be used for transname suffixes */
+ extern struct dentry * d_lookup(struct dentry *, struct qstr *);