From: Jeff Mahoney <jeffm@suse.com>
Subject: dcache: kABI fixes for lockref dentries
Patch-mainline: never
References: FATE#317271

struct dentry's d_count and d_lock are exactly replicated in struct lockref,
but in the opposite order. We can switch them and maintain kABI integrity.

Also, provide accessors for the old variables so modules still build
properly.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
 include/linux/dcache.h  |   15 ++++++++-------
 include/linux/lockref.h |    2 +-
 lib/Kconfig             |    4 +++-
 3 files changed, 12 insertions(+), 9 deletions(-)

--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -114,8 +114,6 @@ full_name_hash(const unsigned char *name
 # endif
 #endif
 
-#define d_lock	d_lockref.lock
-
 struct dentry {
 	/* RCU lookup touched fields */
 	unsigned int d_flags;		/* protected by d_lock */
@@ -127,8 +125,13 @@ struct dentry {
 					 * negative */
 	unsigned char d_iname[DNAME_INLINE_LEN];	/* small names */
 
+#ifndef __GENKSYMS__
 	/* Ref lookup also touches following */
 	struct lockref d_lockref;	/* per-dentry lock and refcount */
+#else
+	unsigned int d_count;
+	spinlock_t d_lock;
+#endif
 	const struct dentry_operations *d_op;
 	struct super_block *d_sb;	/* The root of the dentry tree */
 	unsigned long d_time;		/* used by d_revalidate */
@@ -146,6 +149,9 @@ struct dentry {
 	struct list_head d_alias;	/* inode alias list */
 };
 
+#define d_lock	d_lockref.lock
+#define d_count d_lockref.count
+
 /*
  * dentry->d_lock spinlock nesting subclasses:
  *
@@ -319,11 +325,6 @@ extern struct dentry *__d_lookup(struct
 extern struct dentry *__d_lookup_rcu(struct dentry *parent, struct qstr *name,
 				unsigned *seq, struct inode **inode);
 
-static inline unsigned d_count(const struct dentry *dentry)
-{
-	return dentry->d_lockref.count;
-}
-
 /* validate "insecure" dentry pointer */
 extern int d_validate(struct dentry *, struct dentry *);
 
--- a/include/linux/lockref.h
+++ b/include/linux/lockref.h
@@ -22,8 +22,8 @@ struct lockref {
 		aligned_u64 lock_count;
 #endif
 		struct {
-			spinlock_t lock;
 			unsigned int count;
+			spinlock_t lock;
 		};
 	};
 };
