From: Jeff Mahoney <jeffm@suse.com>
Subject: dcache: Add DCACHE_LUSTRE_INVALID flag for Lustre to handle its own
	invalidation
References: FATE#314679 bnc#802764
Patch-mainline: Never

Lustre wants to keep dentries hashed so it can perform its own revalidation.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 fs/dcache.c            |   10 ++++++++++
 include/linux/dcache.h |    1 +
 include/linux/magic.h  |    2 ++
 3 files changed, 13 insertions(+)

--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -36,6 +36,7 @@
 #include <linux/bit_spinlock.h>
 #include <linux/rculist_bl.h>
 #include <linux/prefetch.h>
+#include <linux/magic.h>
 #include "internal.h"
 #include "pnode.h"
 
@@ -541,6 +542,15 @@ int d_invalidate(struct dentry * dentry)
 		spin_unlock(&dentry->d_lock);
 		return 0;
 	}
+
+	/* network invalidation by Lustre */
+	if (dentry->d_flags & DCACHE_LUSTRE_INVALID &&
+	    (dentry->d_sb->s_magic == LUSTRE_SUPER_MAGIC ||
+	     dentry->d_sb->s_magic == LUSTRE_CLIENT_SUPER_MAGIC)) {
+		spin_unlock(&dentry->d_lock);
+		return 0;
+	}
+
 	/*
 	 * Check whether to do a partial shrink_dcache
 	 * to get rid of unused child entries.
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -230,6 +230,7 @@ struct dentry_operations {
 	(DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT)
 
 #define DCACHE_DENTRY_KILLED	0x100000
+#define DCACHE_LUSTRE_INVALID	0x200000  /* Lustre invalidated */
 
 extern seqlock_t rename_lock;
 
--- a/include/linux/magic.h
+++ b/include/linux/magic.h
@@ -62,4 +62,6 @@
 #define SOCKFS_MAGIC		0x534F434B
 #define V9FS_MAGIC		0x01021997
 
+#define LUSTRE_CLIENT_SUPER_MAGIC		0x0BD00BD0
+#define LUSTRE_SUPER_MAGIC	0x0BD00BD1
 #endif /* __LINUX_MAGIC_H__ */
