Index: linux-2.6/fs/dcache.c =================================================================== --- linux-2.6.orig/fs/dcache.c 2006-08-31 11:59:09.000000000 +0800 +++ linux-2.6/fs/dcache.c 2006-09-06 14:01:37.000000000 +0800 @@ -226,6 +226,13 @@ int d_invalidate(struct dentry * dentry) spin_unlock(&dcache_lock); return 0; } + + /* network invalidation by Lustre */ + if (dentry->d_flags & DCACHE_LUSTRE_INVALID) { + spin_unlock(&dcache_lock); + return 0; + } + /* * Check whether to do a partial shrink_dcache * to get rid of unused child entries. @@ -1242,17 +1249,26 @@ static void __d_rehash(struct dentry * e * Adds a dentry to the hash according to its name. */ -void d_rehash(struct dentry * entry) +void d_rehash_cond(struct dentry * entry, int lock) { struct hlist_head *list = d_hash(entry->d_parent, entry->d_name.hash); - spin_lock(&dcache_lock); + if (lock) + spin_lock(&dcache_lock); spin_lock(&entry->d_lock); __d_rehash(entry, list); spin_unlock(&entry->d_lock); - spin_unlock(&dcache_lock); + if (lock) + spin_unlock(&dcache_lock); } +EXPORT_SYMBOL(d_rehash_cond); + +void d_rehash(struct dentry * entry) +{ + d_rehash_cond(entry, 1); + } + #define do_switch(x,y) do { \ __typeof__ (x) __tmp = x; \ x = y; y = __tmp; } while (0) Index: linux-2.6/include/linux/dcache.h =================================================================== --- linux-2.6.orig/include/linux/dcache.h 2006-08-31 12:00:23.000000000 +0800 +++ linux-2.6/include/linux/dcache.h 2006-09-06 14:02:36.000000000 +0800 @@ -176,6 +176,7 @@ d_iput: no no no yes #define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */ #define DCACHE_UNHASHED 0x0010 +#define DCACHE_LUSTRE_INVALID 0x0040 /* Lustre invalidated */ #define DCACHE_INOTIFY_PARENT_WATCHED 0x0020 /* Parent inode is watched */ @@ -254,6 +255,7 @@ extern int have_submounts(struct dentry * This adds the entry to the hash queues. */ extern void d_rehash(struct dentry *); +extern void d_rehash_cond(struct dentry *, int lock); /** * d_add - add dentry to hash queues