aboutsummaryrefslogtreecommitdiff
blob: f6d02d91bf4772345a5ea4adc4438ab8c0866829 (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
From c54e22039b459aa7da4d7874e3e15d9e4354fd2e Mon Sep 17 00:00:00 2001
From: Liu Xuezhao <xuezhao.liu@emc.com>
Date: Thu, 19 Jul 2012 17:43:16 +0800
Subject: [PATCH 07/13] LU-1337 vfs: 3.3 changes
 super_operations/inode_operations

1. Kernel 3.3 switchs super_operations to use dentry as parameter
   (kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4).
   Add LC_SUPEROPS_USE_DENTRY/HAVE_SUPEROPS_USE_DENTRY to check it.
2. Kernel 3.3 switchs inode_operations to use umode_t as parameter
   (kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35).
   Add LC_INODEOPS_USE_UMODE_T/HAVE_INODEOPS_USE_UMODE_T to check it.

Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
Change-Id: I7564506cf4365c8da113a81058f68b9ef8b092a4
---
 lustre/autoconf/lustre-core.m4         | 57 ++++++++++++++++++++++++++++++++++
 lustre/include/linux/lustre_compat25.h |  6 ++++
 lustre/llite/llite_internal.h          |  4 +++
 lustre/llite/llite_lib.c               | 13 ++++++--
 lustre/llite/namei.c                   | 13 +++++---
 5 files changed, 87 insertions(+), 6 deletions(-)

diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index 17bd744..99f6ec6 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -1938,6 +1938,61 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
+# 3.3 switchs super_operations to use dentry as parameter (but not vfsmount)
+# see kernel commit 34c80b1d93e6e20ca9dea0baf583a5b5510d92d4
+#
+AC_DEFUN([LC_SUPEROPS_USE_DENTRY],
+[AC_MSG_CHECKING([if super_operations use dentry as parameter])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+	#include <linux/fs.h>
+	int show_options(struct seq_file *seq, struct dentry *root){
+		return 0;
+	}
+],[
+	struct super_operations ops;
+	ops.show_options = show_options;
+],[
+	AC_DEFINE(HAVE_SUPEROPS_USE_DENTRY, 1,
+		  [super_operations use dentry as parameter])
+	AC_MSG_RESULT([yes])
+],[
+	AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+#
+# 3.3 switchs inode_operations to use umode_t as parameter (but not int)
+# see kernel commit 1a67aafb5f72a436ca044293309fa7e6351d6a35
+#
+AC_DEFUN([LC_INODEOPS_USE_UMODE_T],
+[AC_MSG_CHECKING([if inode_operations use umode_t as parameter])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+	#include <linux/fs.h>
+	#include <linux/types.h>
+	int my_mknod(struct inode *dir, struct dentry *dchild,
+		     umode_t mode, dev_t dev)
+	{
+		return 0;
+	}
+],[
+	struct inode_operations ops;
+	ops.mknod = my_mknod;
+],[
+	AC_DEFINE(HAVE_INODEOPS_USE_UMODE_T, 1,
+		  [inode_operations use umode_t as parameter])
+	AC_MSG_RESULT([yes])
+],[
+	AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -2093,6 +2148,8 @@ AC_DEFUN([LC_PROG_LINUX],
 	 # 3.3
 	 LC_HAVE_MIGRATE_HEADER
 	 LC_MIGRATEPAGE_4ARGS
+	 LC_SUPEROPS_USE_DENTRY
+	 LC_INODEOPS_USE_UMODE_T
 
          #
          if test x$enable_server = xyes ; then
diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
index 9cf5b1b..87f611b 100644
--- a/lustre/include/linux/lustre_compat25.h
+++ b/lustre/include/linux/lustre_compat25.h
@@ -797,5 +797,11 @@ static inline void set_nlink(struct inode *inode, unsigned int nlink)
 }
 #endif
 
+#ifdef HAVE_INODEOPS_USE_UMODE_T
+# define ll_umode_t	umode_t
+#else
+# define ll_umode_t	int
+#endif
+
 #endif /* __KERNEL__ */
 #endif /* _COMPAT25_H */
diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h
index 8222dca..13ecdd6 100644
--- a/lustre/llite/llite_internal.h
+++ b/lustre/llite/llite_internal.h
@@ -824,7 +824,11 @@ void ll_umount_begin(struct vfsmount *vfsmnt, int flags);
 void ll_umount_begin(struct super_block *sb);
 #endif
 int ll_remount_fs(struct super_block *sb, int *flags, char *data);
+#ifdef HAVE_SUPEROPS_USE_DENTRY
+int ll_show_options(struct seq_file *seq, struct dentry *dentry);
+#else
 int ll_show_options(struct seq_file *seq, struct vfsmount *vfs);
+#endif
 int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req,
                   struct super_block *);
 void lustre_dump_dentry(struct dentry *, int recur);
diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c
index 350c4a7..ab3fe64 100644
--- a/lustre/llite/llite_lib.c
+++ b/lustre/llite/llite_lib.c
@@ -2310,12 +2310,21 @@ void ll_finish_md_op_data(struct md_op_data *op_data)
         OBD_FREE_PTR(op_data);
 }
 
+#ifdef HAVE_SUPEROPS_USE_DENTRY
+int ll_show_options(struct seq_file *seq, struct dentry *dentry)
+#else
 int ll_show_options(struct seq_file *seq, struct vfsmount *vfs)
+#endif
 {
         struct ll_sb_info *sbi;
 
-        LASSERT((seq != NULL) && (vfs != NULL));
-        sbi = ll_s2sbi(vfs->mnt_sb);
+#ifdef HAVE_SUPEROPS_USE_DENTRY
+	LASSERT((seq != NULL) && (dentry != NULL));
+	sbi = ll_s2sbi(dentry->d_sb);
+#else
+	LASSERT((seq != NULL) && (vfs != NULL));
+	sbi = ll_s2sbi(vfs->mnt_sb);
+#endif
 
         if (sbi->ll_flags & LL_SBI_NOLCK)
                 seq_puts(seq, ",nolock");
diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c
index 036674f..a439e2f 100644
--- a/lustre/llite/namei.c
+++ b/lustre/llite/namei.c
@@ -815,7 +815,7 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode,
 }
 
 static int ll_create_nd(struct inode *dir, struct dentry *dentry,
-                        int mode, struct nameidata *nd)
+			ll_umode_t mode, struct nameidata *nd)
 {
         struct lookup_intent *it = ll_d2d(dentry)->lld_it;
         int rc;
@@ -1128,8 +1128,8 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent,
         RETURN(err);
 }
 
-static int ll_mknod(struct inode *dir, struct dentry *dchild, int mode,
-                    ll_dev_t rdev)
+static int ll_mknod(struct inode *dir, struct dentry *dchild,
+		    ll_umode_t mode, ll_dev_t rdev)
 {
         return ll_mknod_generic(dir, &dchild->d_name, mode,
                                 old_encode_dev(rdev), dchild);
@@ -1139,25 +1139,30 @@ static int ll_unlink(struct inode * dir, struct dentry *dentry)
 {
         return ll_unlink_generic(dir, NULL, dentry, &dentry->d_name);
 }
-static int ll_mkdir(struct inode *dir, struct dentry *dentry, int mode)
+
+static int ll_mkdir(struct inode *dir, struct dentry *dentry, ll_umode_t mode)
 {
         return ll_mkdir_generic(dir, &dentry->d_name, mode, dentry);
 }
+
 static int ll_rmdir(struct inode *dir, struct dentry *dentry)
 {
         return ll_rmdir_generic(dir, NULL, dentry, &dentry->d_name);
 }
+
 static int ll_symlink(struct inode *dir, struct dentry *dentry,
                       const char *oldname)
 {
         return ll_symlink_generic(dir, &dentry->d_name, oldname, dentry);
 }
+
 static int ll_link(struct dentry *old_dentry, struct inode *dir,
                    struct dentry *new_dentry)
 {
         return ll_link_generic(old_dentry->d_inode, dir, &new_dentry->d_name,
                                new_dentry);
 }
+
 static int ll_rename(struct inode *old_dir, struct dentry *old_dentry,
                      struct inode *new_dir, struct dentry *new_dentry)
 {
-- 
1.7.12