]> git.pld-linux.org Git - packages/zfs.git/blob - linux-4.9.patch
- fix building with linux 4.9
[packages/zfs.git] / linux-4.9.patch
1 From b8d9e26440ade0edebfa98af8cb9371810c1aeaf Mon Sep 17 00:00:00 2001
2 From: Chunwei Chen <david.chen@osnexus.com>
3 Date: Wed, 19 Oct 2016 11:19:01 -0700
4 Subject: [PATCH] Linux 4.9 compat: iops->rename() wants flags
5
6 In Linux 4.9, torvalds/linux@2773bf0, iops->rename() and iops->rename2() are
7 merged together into iops->rename(), it now wants flags.
8
9 Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
10 ---
11  config/kernel-rename.m4 | 25 +++++++++++++++++++++++++
12  config/kernel.m4        |  1 +
13  module/zfs/zpl_ctldir.c | 23 ++++++++++++++++++++---
14  module/zfs/zpl_inode.c  | 21 +++++++++++++++++++--
15  4 files changed, 65 insertions(+), 5 deletions(-)
16  create mode 100644 config/kernel-rename.m4
17
18 diff --git a/config/kernel-rename.m4 b/config/kernel-rename.m4
19 new file mode 100644
20 index 0000000..9f894fb
21 --- /dev/null
22 +++ b/config/kernel-rename.m4
23 @@ -0,0 +1,25 @@
24 +dnl #
25 +dnl # 4.9 API change,
26 +dnl # iops->rename2() merged into iops->rename(), and iops->rename() now wants
27 +dnl # flags.
28 +dnl #
29 +AC_DEFUN([ZFS_AC_KERNEL_RENAME_WANTS_FLAGS], [
30 +       AC_MSG_CHECKING([whether iops->rename() wants flags])
31 +       ZFS_LINUX_TRY_COMPILE([
32 +               #include <linux/fs.h>
33 +               int rename_fn(struct inode *sip, struct dentry *sdp,
34 +                       struct inode *tip, struct dentry *tdp,
35 +                       unsigned int flags) { return 0; }
36 +
37 +               static const struct inode_operations
38 +                   iops __attribute__ ((unused)) = {
39 +                       .rename = rename_fn,
40 +               };
41 +       ],[
42 +       ],[
43 +               AC_MSG_RESULT(yes)
44 +               AC_DEFINE(HAVE_RENAME_WANTS_FLAGS, 1, [iops->rename() wants flags])
45 +       ],[
46 +               AC_MSG_RESULT(no)
47 +       ])
48 +])
49 diff --git a/config/kernel.m4 b/config/kernel.m4
50 index c53e611..3763525 100644
51 --- a/config/kernel.m4
52 +++ b/config/kernel.m4
53 @@ -103,6 +103,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
54         ZFS_AC_KERNEL_FOLLOW_DOWN_ONE
55         ZFS_AC_KERNEL_MAKE_REQUEST_FN
56         ZFS_AC_KERNEL_GENERIC_IO_ACCT
57 +       ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
58  
59         AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
60                 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
61 diff --git a/module/zfs/zpl_ctldir.c b/module/zfs/zpl_ctldir.c
62 index 7c4fcea..cdd6668 100644
63 --- a/module/zfs/zpl_ctldir.c
64 +++ b/module/zfs/zpl_ctldir.c
65 @@ -301,13 +301,17 @@ zpl_snapdir_readdir(struct file *filp, void *dirent, filldir_t filldir)
66  }
67  #endif /* HAVE_VFS_ITERATE */
68  
69 -int
70 -zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
71 -    struct inode *tdip, struct dentry *tdentry)
72 +static int
73 +zpl_snapdir_rename2(struct inode *sdip, struct dentry *sdentry,
74 +    struct inode *tdip, struct dentry *tdentry, unsigned int flags)
75  {
76         cred_t *cr = CRED();
77         int error;
78  
79 +       /* We probably don't want to support renameat2(2) in ctldir */
80 +       if (flags)
81 +               return (-EINVAL);
82 +
83         crhold(cr);
84         error = -zfsctl_snapdir_rename(sdip, dname(sdentry),
85             tdip, dname(tdentry), cr, 0);
86 @@ -317,6 +321,15 @@ zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
87         return (error);
88  }
89  
90 +#ifndef HAVE_RENAME_WANTS_FLAGS
91 +static int
92 +zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
93 +    struct inode *tdip, struct dentry *tdentry)
94 +{
95 +       return (zpl_snapdir_rename2(sdip, sdentry, tdip, tdentry, 0));
96 +}
97 +#endif
98 +
99  static int
100  zpl_snapdir_rmdir(struct inode *dip, struct dentry *dentry)
101  {
102 @@ -405,7 +418,11 @@ const struct file_operations zpl_fops_snapdir = {
103  const struct inode_operations zpl_ops_snapdir = {
104         .lookup         = zpl_snapdir_lookup,
105         .getattr        = zpl_snapdir_getattr,
106 +#ifdef HAVE_RENAME_WANTS_FLAGS
107 +       .rename         = zpl_snapdir_rename2,
108 +#else
109         .rename         = zpl_snapdir_rename,
110 +#endif
111         .rmdir          = zpl_snapdir_rmdir,
112         .mkdir          = zpl_snapdir_mkdir,
113  };
114 diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
115 index d26193f..113885e 100644
116 --- a/module/zfs/zpl_inode.c
117 +++ b/module/zfs/zpl_inode.c
118 @@ -356,13 +356,17 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
119  }
120  
121  static int
122 -zpl_rename(struct inode *sdip, struct dentry *sdentry,
123 -    struct inode *tdip, struct dentry *tdentry)
124 +zpl_rename2(struct inode *sdip, struct dentry *sdentry,
125 +    struct inode *tdip, struct dentry *tdentry, unsigned int flags)
126  {
127         cred_t *cr = CRED();
128         int error;
129         fstrans_cookie_t cookie;
130  
131 +       /* We don't have renameat2(2) support */
132 +       if (flags)
133 +               return (-EINVAL);
134 +
135         crhold(cr);
136         cookie = spl_fstrans_mark();
137         error = -zfs_rename(sdip, dname(sdentry), tdip, dname(tdentry), cr, 0);
138 @@ -373,6 +377,15 @@ zpl_rename(struct inode *sdip, struct dentry *sdentry,
139         return (error);
140  }
141  
142 +#ifndef HAVE_RENAME_WANTS_FLAGS
143 +static int
144 +zpl_rename(struct inode *sdip, struct dentry *sdentry,
145 +    struct inode *tdip, struct dentry *tdentry)
146 +{
147 +       return (zpl_rename2(sdip, sdentry, tdip, tdentry, 0));
148 +}
149 +#endif
150 +
151  static int
152  zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
153  {
154 @@ -662,7 +662,11 @@
155         .mkdir          = zpl_mkdir,
156         .rmdir          = zpl_rmdir,
157         .mknod          = zpl_mknod,
158 +#ifdef HAVE_RENAME_WANTS_FLAGS
159 +       .rename         = zpl_rename2,
160 +#else
161         .rename         = zpl_rename,
162 +#endif
163         .setattr        = zpl_setattr,
164         .getattr        = zpl_getattr,
165  #ifdef HAVE_GENERIC_SETXATTR
166 @@ -681,7 +694,11 @@ const struct inode_operations zpl_dir_inode_operations = {
167         .mkdir          = zpl_mkdir,
168         .rmdir          = zpl_rmdir,
169         .mknod          = zpl_mknod,
170 +#ifdef HAVE_RENAME_WANTS_FLAGS
171 +       .rename         = zpl_rename2,
172 +#else
173         .rename         = zpl_rename,
174 +#endif
175         .setattr        = zpl_setattr,
176         .getattr        = zpl_getattr,
177         .setxattr       = generic_setxattr,
178 From 0fedeedd309eca62d15fffd8bd811e2b12660e21 Mon Sep 17 00:00:00 2001
179 From: Chunwei Chen <david.chen@osnexus.com>
180 Date: Wed, 19 Oct 2016 11:19:17 -0700
181 Subject: [PATCH] Linux 4.9 compat: remove iops->{set,get,remove}xattr
182
183 In Linux 4.9, torvalds/linux@fd50eca, iops->{set,get,remove}xattr and
184 generic_{set,get,remove}xattr are removed. xattr operations will directly
185 go through sb->s_xattr.
186
187 Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
188 ---
189  config/kernel-xattr-handler.m4 | 25 +++++++++++++++++++++++++
190  config/kernel.m4               |  1 +
191  module/zfs/zpl_inode.c         |  8 ++++++++
192  3 files changed, 34 insertions(+)
193
194 diff --git a/config/kernel-xattr-handler.m4 b/config/kernel-xattr-handler.m4
195 index ce18eaf..300cb0b 100644
196 --- a/config/kernel-xattr-handler.m4
197 +++ b/config/kernel-xattr-handler.m4
198 @@ -58,6 +58,31 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_NAME], [
199  ])
200  
201  dnl #
202 +dnl # 4.9 API change,
203 +dnl # iops->{set,get,remove}xattr and generic_{set,get,remove}xattr are
204 +dnl # removed. xattr operations will directly go through sb->s_xattr.
205 +dnl #
206 +AC_DEFUN([ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR], [
207 +       AC_MSG_CHECKING([whether generic_setxattr() exists])
208 +       ZFS_LINUX_TRY_COMPILE([
209 +               #include <linux/fs.h>
210 +               #include <linux/xattr.h>
211 +
212 +               static const struct inode_operations
213 +                   iops __attribute__ ((unused)) = {
214 +                       .setxattr = generic_setxattr
215 +               };
216 +       ],[
217 +       ],[
218 +               AC_MSG_RESULT(yes)
219 +               AC_DEFINE(HAVE_GENERIC_SETXATTR, 1,
220 +                   [generic_setxattr() exists])
221 +       ],[
222 +               AC_MSG_RESULT(no)
223 +       ])
224 +])
225 +
226 +dnl #
227  dnl # Supported xattr handler get() interfaces checked newest to oldest.
228  dnl #
229  AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET], [
230 diff --git a/config/kernel.m4 b/config/kernel.m4
231 index 3763525..66e97c2 100644
232 --- a/config/kernel.m4
233 +++ b/config/kernel.m4
234 @@ -104,6 +104,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
235         ZFS_AC_KERNEL_MAKE_REQUEST_FN
236         ZFS_AC_KERNEL_GENERIC_IO_ACCT
237         ZFS_AC_KERNEL_RENAME_WANTS_FLAGS
238 +       ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR
239  
240         AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
241                 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
242 diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
243 index 113885e..f59f2df9 100644
244 --- a/module/zfs/zpl_inode.c
245 +++ b/module/zfs/zpl_inode.c
246 @@ -664,9 +664,11 @@ zpl_revalidate(struct dentry *dentry, unsigned int flags)
247  const struct inode_operations zpl_inode_operations = {
248         .setattr        = zpl_setattr,
249         .getattr        = zpl_getattr,
250 +#ifdef HAVE_GENERIC_SETXATTR
251         .setxattr       = generic_setxattr,
252         .getxattr       = generic_getxattr,
253         .removexattr    = generic_removexattr,
254 +#endif
255         .listxattr      = zpl_xattr_list,
256  #ifdef HAVE_INODE_TRUNCATE_RANGE
257         .truncate_range = zpl_truncate_range,
258 @@ -701,9 +703,11 @@ const struct inode_operations zpl_dir_inode_operations = {
259  #endif
260         .setattr        = zpl_setattr,
261         .getattr        = zpl_getattr,
262 +#ifdef HAVE_GENERIC_SETXATTR
263         .setxattr       = generic_setxattr,
264         .getxattr       = generic_getxattr,
265         .removexattr    = generic_removexattr,
266 +#endif
267         .listxattr      = zpl_xattr_list,
268  #if defined(CONFIG_FS_POSIX_ACL)
269  #if defined(HAVE_GET_ACL)
270 @@ -728,18 +732,22 @@ const struct inode_operations zpl_symlink_inode_operations = {
271  #endif
272         .setattr        = zpl_setattr,
273         .getattr        = zpl_getattr,
274 +#ifdef HAVE_GENERIC_SETXATTR
275         .setxattr       = generic_setxattr,
276         .getxattr       = generic_getxattr,
277         .removexattr    = generic_removexattr,
278 +#endif
279         .listxattr      = zpl_xattr_list,
280  };
281  
282  const struct inode_operations zpl_special_inode_operations = {
283         .setattr        = zpl_setattr,
284         .getattr        = zpl_getattr,
285 +#ifdef HAVE_GENERIC_SETXATTR
286         .setxattr       = generic_setxattr,
287         .getxattr       = generic_getxattr,
288         .removexattr    = generic_removexattr,
289 +#endif
290         .listxattr      = zpl_xattr_list,
291  #if defined(CONFIG_FS_POSIX_ACL)
292  #if defined(HAVE_GET_ACL)
293 From 7ca25051b6470e8471b4ed454d8c66ff21338de3 Mon Sep 17 00:00:00 2001
294 From: DeHackEd <DeHackEd@users.noreply.github.com>
295 Date: Tue, 15 Nov 2016 12:20:46 -0500
296 Subject: [PATCH] Kernel 4.9 compat: file_operations->aio_fsync removal
297
298 Linux kernel commit 723c038475b78 removed this field.
299
300 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
301 Signed-off-by: DHE <git@dehacked.net>
302 Closes #5393
303 ---
304  config/kernel-aio-fsync.m4 | 21 +++++++++++++++++++++
305  config/kernel.m4           |  1 +
306  module/zfs/zpl_file.c      | 11 +++++++++++
307  3 files changed, 33 insertions(+)
308  create mode 100644 config/kernel-aio-fsync.m4
309
310 diff --git a/config/kernel-aio-fsync.m4 b/config/kernel-aio-fsync.m4
311 new file mode 100644
312 index 0000000..41b7a98a
313 --- /dev/null
314 +++ b/config/kernel-aio-fsync.m4
315 @@ -0,0 +1,21 @@
316 +dnl #
317 +dnl # Linux 4.9-rc5+ ABI, removal of the .aio_fsync field
318 +dnl #
319 +AC_DEFUN([ZFS_AC_KERNEL_AIO_FSYNC], [
320 +       AC_MSG_CHECKING([whether fops->aio_fsync() exists])
321 +       ZFS_LINUX_TRY_COMPILE([
322 +               #include <linux/fs.h>
323 +
324 +               static const struct file_operations
325 +                   fops __attribute__ ((unused)) = {
326 +                       .aio_fsync = NULL,
327 +               };
328 +       ],[
329 +       ],[
330 +               AC_MSG_RESULT(yes)
331 +               AC_DEFINE(HAVE_FILE_AIO_FSYNC, 1, [fops->aio_fsync() exists])
332 +       ],[
333 +               AC_MSG_RESULT(no)
334 +       ])
335 +])
336 +
337 diff --git a/config/kernel.m4 b/config/kernel.m4
338 index af59451..b66631a 100644
339 --- a/config/kernel.m4
340 +++ b/config/kernel.m4
341 @@ -66,6 +66,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
342         ZFS_AC_KERNEL_NR_CACHED_OBJECTS
343         ZFS_AC_KERNEL_FREE_CACHED_OBJECTS
344         ZFS_AC_KERNEL_FALLOCATE
345 +       ZFS_AC_KERNEL_AIO_FSYNC
346         ZFS_AC_KERNEL_MKDIR_UMODE_T
347         ZFS_AC_KERNEL_LOOKUP_NAMEIDATA
348         ZFS_AC_KERNEL_CREATE_NAMEIDATA
349 diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c
350 index 2c84d70..a225220 100644
351 --- a/module/zfs/zpl_file.c
352 +++ b/module/zfs/zpl_file.c
353 @@ -130,12 +130,15 @@ zpl_fsync(struct file *filp, struct dentry *dentry, int datasync)
354         return (error);
355  }
356  
357 +#ifdef HAVE_FILE_AIO_FSYNC
358  static int
359  zpl_aio_fsync(struct kiocb *kiocb, int datasync)
360  {
361         struct file *filp = kiocb->ki_filp;
362         return (zpl_fsync(filp, filp->f_path.dentry, datasync));
363  }
364 +#endif
365 +
366  #elif defined(HAVE_FSYNC_WITHOUT_DENTRY)
367  /*
368   * Linux 2.6.35 - 3.0 API,
369 @@ -161,11 +164,14 @@ zpl_fsync(struct file *filp, int datasync)
370         return (error);
371  }
372  
373 +#ifdef HAVE_FILE_AIO_FSYNC
374  static int
375  zpl_aio_fsync(struct kiocb *kiocb, int datasync)
376  {
377         return (zpl_fsync(kiocb->ki_filp, datasync));
378  }
379 +#endif
380 +
381  #elif defined(HAVE_FSYNC_RANGE)
382  /*
383   * Linux 3.1 - 3.x API,
384 @@ -196,11 +202,14 @@ zpl_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
385         return (error);
386  }
387  
388 +#ifdef HAVE_FILE_AIO_FSYNC
389  static int
390  zpl_aio_fsync(struct kiocb *kiocb, int datasync)
391  {
392         return (zpl_fsync(kiocb->ki_filp, kiocb->ki_pos, -1, datasync));
393  }
394 +#endif
395 +
396  #else
397  #error "Unsupported fops->fsync() implementation"
398  #endif
399 @@ -838,7 +847,9 @@ const struct file_operations zpl_file_operations = {
400  #endif
401         .mmap           = zpl_mmap,
402         .fsync          = zpl_fsync,
403 +#ifdef HAVE_FILE_AIO_FSYNC
404         .aio_fsync      = zpl_aio_fsync,
405 +#endif
406  #ifdef HAVE_FILE_FALLOCATE
407         .fallocate      = zpl_fallocate,
408  #endif /* HAVE_FILE_FALLOCATE */
This page took 0.651423 seconds and 3 git commands to generate.