]> git.pld-linux.org Git - packages/zfs.git/blame - setattr_prepare.patch
- inode_change_ok has been removed in 4.9 and 4.1.37
[packages/zfs.git] / setattr_prepare.patch
CommitLineData
bb670c20
JR
1From 3b0ba3ba99b8a3af0fb532bf264629436b1abd84 Mon Sep 17 00:00:00 2001
2From: Brian Behlendorf <behlendorf1@llnl.gov>
3Date: Tue, 18 Oct 2016 23:49:23 +0000
4Subject: [PATCH] Linux 4.9 compat: inode_change_ok() renamed setattr_prepare()
5
6In torvalds/linux@31051c8 the inode_change_ok() function was
7renamed setattr_prepare() and updated to take a dentry ratheri
8than an inode. Update the code to call the setattr_prepare()
9and add a wrapper function which call inode_change_ok() for
10older kernels.
11
12Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
13Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
14Requires-spl: refs/pull/581/head
15---
16 config/kernel-setattr-prepare.m4 | 23 +++++++++++++++++++++++
17 config/kernel.m4 | 1 +
18 include/linux/vfs_compat.h | 11 +++++++++++
19 module/zfs/zpl_inode.c | 2 +-
20 4 files changed, 36 insertions(+), 1 deletion(-)
21 create mode 100644 config/kernel-setattr-prepare.m4
22
23diff --git a/config/kernel-setattr-prepare.m4 b/config/kernel-setattr-prepare.m4
24new file mode 100644
25index 0000000..32f7deb
26--- /dev/null
27+++ b/config/kernel-setattr-prepare.m4
28@@ -0,0 +1,23 @@
29+dnl #
30+dnl # 4.9 API change
31+dnl # The inode_change_ok() function has been renamed setattr_prepare()
32+dnl # and updated to take a dentry rather than an inode.
33+dnl #
34+AC_DEFUN([ZFS_AC_KERNEL_SETATTR_PREPARE],
35+ [AC_MSG_CHECKING([whether setattr_prepare() is available])
36+ ZFS_LINUX_TRY_COMPILE_SYMBOL([
37+ #include <linux/fs.h>
38+ ], [
39+ struct dentry *dentry = NULL;
40+ struct iattr *attr = NULL;
41+ int error;
42+
43+ error = setattr_prepare(dentry, attr);
44+ ], [setattr_prepare], [fs/attr.c], [
45+ AC_MSG_RESULT(yes)
46+ AC_DEFINE(HAVE_SETATTR_PREPARE, 1,
47+ [setattr_prepare() is available])
48+ ], [
49+ AC_MSG_RESULT(no)
50+ ])
51+])
52diff --git a/config/kernel.m4 b/config/kernel.m4
53index 66e97c2..44a20f2 100644
54--- a/config/kernel.m4
55+++ b/config/kernel.m4
56@@ -74,6 +74,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
57 ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
58 ZFS_AC_KERNEL_COMMIT_METADATA
59 ZFS_AC_KERNEL_CLEAR_INODE
60+ ZFS_AC_KERNEL_SETATTR_PREPARE
61 ZFS_AC_KERNEL_INSERT_INODE_LOCKED
62 ZFS_AC_KERNEL_D_MAKE_ROOT
63 ZFS_AC_KERNEL_D_OBTAIN_ALIAS
64diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h
65index 8a64cab..989c237 100644
66--- a/include/linux/vfs_compat.h
67+++ b/include/linux/vfs_compat.h
68@@ -444,4 +444,15 @@ static inline void zfs_gid_write(struct inode *ip, gid_t gid)
69 #define zpl_follow_up(path) follow_up(path)
70 #endif
71
72+/*
73+ * 4.9 API change
74+ */
75+#ifndef HAVE_SETATTR_PREPARE
76+static inline int
77+setattr_prepare(struct dentry *dentry, struct iattr *ia)
78+{
79+ return (inode_change_ok(dentry->d_inode, ia));
80+}
81+#endif
82+
83 #endif /* _ZFS_VFS_H */
84diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
85index f59f2df9..b8adda7 100644
86--- a/module/zfs/zpl_inode.c
87+++ b/module/zfs/zpl_inode.c
88@@ -323,7 +323,7 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
89 int error;
90 fstrans_cookie_t cookie;
91
92- error = inode_change_ok(ip, ia);
93+ error = setattr_prepare(dentry, ia);
94 if (error)
95 return (error);
96
This page took 0.120754 seconds and 4 git commands to generate.