Lustre VFS patches for 2.6
PATCH 1/9 Lustre VFS patches for 2.6
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(-)
fs/dcache.c +18 -4
@@ -1115,16 +1115,23 @@* Adds a dentry to the hash according to its name. */ -void d_rehash (struct dentry * entry) +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); entry->d_flags &= ~DCACHE_UNHASHED ;spin_unlock (&entry->d_lock); entry->d_bucket = list;hlist_add_head_rcu (&entry->d_hash, list); +} + +EXPORT_SYMBOL (__d_rehash); + +void d_rehash (struct dentry * entry) +{ +spin_lock (&dcache_lock); +__d_rehash (entry);spin_unlock (&dcache_lock); }
@@ -1200,12 +1207,11 @@* 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) {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?
@@ -1257,6 +1263,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); }
include/linux/dcache.h +2 -0
@@ -227,6 +227,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
@@ -245,6 +246,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 *);