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
6 In Linux 4.9, torvalds/linux@2773bf0, iops->rename() and iops->rename2() are
7 merged together into iops->rename(), it now wants flags.
9 Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
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
18 diff --git a/config/kernel-rename.m4 b/config/kernel-rename.m4
20 index 0000000..9f894fb
22 +++ b/config/kernel-rename.m4
25 +dnl # 4.9 API change,
26 +dnl # iops->rename2() merged into iops->rename(), and iops->rename() now wants
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; }
37 + static const struct inode_operations
38 + iops __attribute__ ((unused)) = {
39 + .rename = rename_fn,
44 + AC_DEFINE(HAVE_RENAME_WANTS_FLAGS, 1, [iops->rename() wants flags])
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
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)
67 #endif /* HAVE_VFS_ITERATE */
70 -zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
71 - struct inode *tdip, struct dentry *tdentry)
73 +zpl_snapdir_rename2(struct inode *sdip, struct dentry *sdentry,
74 + struct inode *tdip, struct dentry *tdentry, unsigned int flags)
79 + /* We probably don't want to support renameat2(2) in ctldir */
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,
90 +#ifndef HAVE_RENAME_WANTS_FLAGS
92 +zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
93 + struct inode *tdip, struct dentry *tdentry)
95 + return (zpl_snapdir_rename2(sdip, sdentry, tdip, tdentry, 0));
100 zpl_snapdir_rmdir(struct inode *dip, struct dentry *dentry)
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,
109 .rename = zpl_snapdir_rename,
111 .rmdir = zpl_snapdir_rmdir,
112 .mkdir = zpl_snapdir_mkdir,
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)
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)
129 fstrans_cookie_t cookie;
131 + /* We don't have renameat2(2) support */
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,
142 +#ifndef HAVE_RENAME_WANTS_FLAGS
144 +zpl_rename(struct inode *sdip, struct dentry *sdentry,
145 + struct inode *tdip, struct dentry *tdentry)
147 + return (zpl_rename2(sdip, sdentry, tdip, tdentry, 0));
152 zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
158 +#ifdef HAVE_RENAME_WANTS_FLAGS
159 + .rename = zpl_rename2,
161 .rename = zpl_rename,
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 = {
170 +#ifdef HAVE_RENAME_WANTS_FLAGS
171 + .rename = zpl_rename2,
173 .rename = zpl_rename,
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
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.
187 Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
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(+)
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], [
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.
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>
212 + static const struct inode_operations
213 + iops __attribute__ ((unused)) = {
214 + .setxattr = generic_setxattr
219 + AC_DEFINE(HAVE_GENERIC_SETXATTR, 1,
220 + [generic_setxattr() exists])
227 dnl # Supported xattr handler get() interfaces checked newest to oldest.
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
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,
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 = {
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,
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 = {
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,
279 .listxattr = zpl_xattr_list,
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,
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
298 Linux kernel commit 723c038475b78 removed this field.
300 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
301 Signed-off-by: DHE <git@dehacked.net>
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
310 diff --git a/config/kernel-aio-fsync.m4 b/config/kernel-aio-fsync.m4
312 index 0000000..41b7a98a
314 +++ b/config/kernel-aio-fsync.m4
317 +dnl # Linux 4.9-rc5+ ABI, removal of the .aio_fsync field
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>
324 + static const struct file_operations
325 + fops __attribute__ ((unused)) = {
331 + AC_DEFINE(HAVE_FILE_AIO_FSYNC, 1, [fops->aio_fsync() exists])
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)
357 +#ifdef HAVE_FILE_AIO_FSYNC
359 zpl_aio_fsync(struct kiocb *kiocb, int datasync)
361 struct file *filp = kiocb->ki_filp;
362 return (zpl_fsync(filp, filp->f_path.dentry, datasync));
366 #elif defined(HAVE_FSYNC_WITHOUT_DENTRY)
368 * Linux 2.6.35 - 3.0 API,
369 @@ -161,11 +164,14 @@ zpl_fsync(struct file *filp, int datasync)
373 +#ifdef HAVE_FILE_AIO_FSYNC
375 zpl_aio_fsync(struct kiocb *kiocb, int datasync)
377 return (zpl_fsync(kiocb->ki_filp, datasync));
381 #elif defined(HAVE_FSYNC_RANGE)
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)
388 +#ifdef HAVE_FILE_AIO_FSYNC
390 zpl_aio_fsync(struct kiocb *kiocb, int datasync)
392 return (zpl_fsync(kiocb->ki_filp, kiocb->ki_pos, -1, datasync));
397 #error "Unsupported fops->fsync() implementation"
399 @@ -838,7 +847,9 @@ const struct file_operations zpl_file_operations = {
403 +#ifdef HAVE_FILE_AIO_FSYNC
404 .aio_fsync = zpl_aio_fsync,
406 #ifdef HAVE_FILE_FALLOCATE
407 .fallocate = zpl_fallocate,
408 #endif /* HAVE_FILE_FALLOCATE */