]> granicus.if.org Git - zfs/commitdiff
Linux 4.9 compat: inode_change_ok() renamed setattr_prepare()
authorBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 18 Oct 2016 23:49:23 +0000 (23:49 +0000)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 20 Oct 2016 16:39:09 +0000 (09:39 -0700)
In torvalds/linux@31051c8 the inode_change_ok() function was
renamed setattr_prepare() and updated to take a dentry ratheri
than an inode.  Update the code to call the setattr_prepare()
and add a wrapper function which call inode_change_ok() for
older kernels.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Requires-spl: refs/pull/581/head

config/kernel-setattr-prepare.m4 [new file with mode: 0644]
config/kernel.m4
include/linux/vfs_compat.h
module/zfs/zpl_inode.c

diff --git a/config/kernel-setattr-prepare.m4 b/config/kernel-setattr-prepare.m4
new file mode 100644 (file)
index 0000000..32f7deb
--- /dev/null
@@ -0,0 +1,23 @@
+dnl #
+dnl # 4.9 API change
+dnl # The inode_change_ok() function has been renamed setattr_prepare()
+dnl # and updated to take a dentry rather than an inode.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_SETATTR_PREPARE],
+       [AC_MSG_CHECKING([whether setattr_prepare() is available])
+       ZFS_LINUX_TRY_COMPILE_SYMBOL([
+               #include <linux/fs.h>
+       ], [
+               struct dentry *dentry = NULL;
+               struct iattr *attr = NULL;
+               int error;
+
+               error = setattr_prepare(dentry, attr);
+       ], [setattr_prepare], [fs/attr.c], [
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_SETATTR_PREPARE, 1,
+                   [setattr_prepare() is available])
+       ], [
+               AC_MSG_RESULT(no)
+       ])
+])
index 66e97c250bcc40bdc4b2d1627cbabbf7ffd2c5d1..44a20f2135c6cd86f44c7d33c88b77138a19fb04 100644 (file)
@@ -74,6 +74,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
        ZFS_AC_KERNEL_ENCODE_FH_WITH_INODE
        ZFS_AC_KERNEL_COMMIT_METADATA
        ZFS_AC_KERNEL_CLEAR_INODE
+       ZFS_AC_KERNEL_SETATTR_PREPARE
        ZFS_AC_KERNEL_INSERT_INODE_LOCKED
        ZFS_AC_KERNEL_D_MAKE_ROOT
        ZFS_AC_KERNEL_D_OBTAIN_ALIAS
index 8a64cabef1eb143721ffb5c734eba30ce2e8391c..989c237a34e5c815cb59481e1b87ab1b4ba8ca1e 100644 (file)
@@ -444,4 +444,15 @@ static inline void zfs_gid_write(struct inode *ip, gid_t gid)
 #define        zpl_follow_up(path)                     follow_up(path)
 #endif
 
+/*
+ * 4.9 API change
+ */
+#ifndef HAVE_SETATTR_PREPARE
+static inline int
+setattr_prepare(struct dentry *dentry, struct iattr *ia)
+{
+       return (inode_change_ok(dentry->d_inode, ia));
+}
+#endif
+
 #endif /* _ZFS_VFS_H */
index f59f2df97b428fb2491e93a60adb569beb21f804..b8adda7a1b1b8cf7fa21f395fa1d605b78860911 100644 (file)
@@ -323,7 +323,7 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
        int error;
        fstrans_cookie_t cookie;
 
-       error = inode_change_ok(ip, ia);
+       error = setattr_prepare(dentry, ia);
        if (error)
                return (error);