diff --git a/config/kernel-setattr-prepare.m4 b/config/kernel-setattr-prepare.m4 new file mode 100644 index 000000000000..817118d1e617 --- /dev/null +++ b/config/kernel-setattr-prepare.m4 @@ -0,0 +1,17 @@ +dnl # +dnl # 4.9 API change, +dnl # inode_change_ok is changed to setattr_prepare and takes dentry +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SETATTR_PREPARE], [ + AC_MSG_CHECKING([whether setattr_prepare() exists]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + setattr_prepare(NULL, NULL); + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SETATTR_PREPARE, 1, [setattr_prepare() exists]) + ],[ + AC_MSG_RESULT(no) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 66e97c250bcc..1f5f66accb3e 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -105,6 +105,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST ZFS_AC_KERNEL_RENAME_WANTS_FLAGS ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR + ZFS_AC_KERNEL_SETATTR_PREPARE AS_IF([test "$LINUX_OBJ" != "$LINUX"], [ KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h index 8a64cabef1eb..c0973628085e 100644 --- a/include/linux/vfs_compat.h +++ b/include/linux/vfs_compat.h @@ -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 + * inode_change_ok is changed to setattr_prepare and takes dentry + */ +#ifndef HAVE_SETATTR_PREPARE +static inline int setattr_prepare(struct dentry *dentry, struct iattr *attr) +{ + return (inode_change_ok(dentry->d_inode, attr)); +} +#endif + #endif /* _ZFS_VFS_H */ diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c index f59f2df97b42..b8adda7a1b1b 100644 --- a/module/zfs/zpl_inode.c +++ b/module/zfs/zpl_inode.c @@ -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);