aboutsummaryrefslogtreecommitdiff
blob: 6873a226a70e12f043b968ded8487ee99393919b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
From 18cfd561fae3b2eac663b51f8e5147b59c711af7 Mon Sep 17 00:00:00 2001
From: James Simmons <uja.ornl@gmail.com>
Date: Wed, 11 Dec 2013 10:29:41 -0500
Subject: [PATCH 03/18] LU-3974 llite: dentry d_compare changes in 3.11

In the linux 3.11 kernel the d_compare function has
removed passing in any struct inode arguments. This
patch provides support to handle this case.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: I363057e4d0a119ad43a9907ec26e7e0079f7c305
---
 lustre/autoconf/lustre-core.m4 | 19 +++++++++++++++++++
 lustre/llite/dcache.c          | 27 +++++++++++----------------
 lustre/llite/llite_internal.h  |  7 -------
 3 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index f47bc5f..7f9bb45 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -1287,6 +1287,24 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
+# 3.11 dentry_operations.d_compare() taken 5 arguments.
+#
+AC_DEFUN([LC_D_COMPARE_5ARGS],
+[AC_MSG_CHECKING([if d_compare taken 5 arguments])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/dcache.h>
+],[
+	((struct dentry_operations*)0)->d_compare(NULL,NULL,0,NULL,NULL);
+],[
+	AC_DEFINE(HAVE_D_COMPARE_5ARGS, 1,
+		[d_compare need 5 arguments])
+	AC_MSG_RESULT([yes])
+],[
+	AC_MSG_RESULT([no])
+])
+])
+
+#
 # 3.11 need to access d_count to get dentry reference count
 #
 AC_DEFUN([LC_HAVE_DCOUNT],
@@ -1405,6 +1423,7 @@ AC_DEFUN([LC_PROG_LINUX],
 	 LC_BLKDEV_RELEASE_RETURN_INT
 
 	 # 3.11
+	 LC_D_COMPARE_5ARGS
 	 LC_HAVE_DCOUNT
 
 	 #
diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c
index 6fca4cb..8a8c100 100644
--- a/lustre/llite/dcache.c
+++ b/lustre/llite/dcache.c
@@ -89,11 +89,19 @@ static void ll_release(struct dentry *de)
 int ll_dcompare(const struct dentry *parent, const struct inode *pinode,
 		const struct dentry *dentry, const struct inode *inode,
 		unsigned int len, const char *str, const struct qstr *name)
+#elif defined(HAVE_D_COMPARE_5ARGS)
+int ll_dcompare(const struct dentry *parent, const struct dentry *dentry,
+		unsigned int len, const char *str, const struct qstr *name)
 #else
 int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name)
 #endif
 {
-#ifdef HAVE_D_COMPARE_7ARGS
+#if !defined(HAVE_D_COMPARE_7ARGS) && !defined(HAVE_D_COMPARE_5ARGS)
+	/* XXX: (ugh !) d_name must be in-dentry structure */
+	struct dentry *dentry = container_of(d_name, struct dentry, d_name);
+	unsigned int len = d_name->len;
+	const char *str = d_name->name;
+#endif
 	ENTRY;
 
 	if (len != name->len)
@@ -101,19 +109,6 @@ int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name)
 
 	if (memcmp(str, name->name, len))
 		RETURN(1);
-#else
-	struct dentry *dentry;
-	ENTRY;
-
-	if (d_name->len != name->len)
-		RETURN(1);
-
-	if (memcmp(d_name->name, name->name, name->len))
-		RETURN(1);
-
-	/* XXX: d_name must be in-dentry structure */
-	dentry = container_of(d_name, struct dentry, d_name); /* ugh */
-#endif
 
 	CDEBUG(D_DENTRY, "found name %.*s(%p) flags %#x refc %d\n",
 	       name->len, name->name, dentry, dentry->d_flags,
@@ -124,9 +119,9 @@ int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name)
 		RETURN(0);
 
 	if (d_lustre_invalid(dentry))
-                RETURN(1);
+		RETURN(1);
 
-        RETURN(0);
+	RETURN(0);
 }
 
 static inline int return_if_equal(struct ldlm_lock *lock, void *data)
diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h
index daeac51..9da81ca 100644
--- a/lustre/llite/llite_internal.h
+++ b/lustre/llite/llite_internal.h
@@ -857,13 +857,6 @@ void ll_intent_release(struct lookup_intent *);
 void ll_invalidate_aliases(struct inode *);
 void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft);
 void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry);
-#ifdef HAVE_D_COMPARE_7ARGS
-int ll_dcompare(const struct dentry *parent, const struct inode *pinode,
-		const struct dentry *dentry, const struct inode *inode,
-		unsigned int len, const char *str, const struct qstr *d_name);
-#else
-int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name);
-#endif
 int ll_revalidate_it_finish(struct ptlrpc_request *request,
                             struct lookup_intent *it, struct dentry *de);
 
-- 
1.8.5.1