]>
Commit | Line | Data |
---|---|---|
bb670c20 JR |
1 | From 3b0ba3ba99b8a3af0fb532bf264629436b1abd84 Mon Sep 17 00:00:00 2001 |
2 | From: Brian Behlendorf <behlendorf1@llnl.gov> | |
3 | Date: Tue, 18 Oct 2016 23:49:23 +0000 | |
4 | Subject: [PATCH] Linux 4.9 compat: inode_change_ok() renamed setattr_prepare() | |
5 | ||
6 | In torvalds/linux@31051c8 the inode_change_ok() function was | |
7 | renamed setattr_prepare() and updated to take a dentry ratheri | |
8 | than an inode. Update the code to call the setattr_prepare() | |
9 | and add a wrapper function which call inode_change_ok() for | |
10 | older kernels. | |
11 | ||
12 | Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> | |
13 | Signed-off-by: Chunwei Chen <david.chen@osnexus.com> | |
14 | Requires-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 | ||
23 | diff --git a/config/kernel-setattr-prepare.m4 b/config/kernel-setattr-prepare.m4 | |
24 | new file mode 100644 | |
25 | index 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 | +]) | |
52 | diff --git a/config/kernel.m4 b/config/kernel.m4 | |
53 | index 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 | |
64 | diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h | |
65 | index 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 */ | |
84 | diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c | |
85 | index 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 |