Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux 4.9 compat #5301

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions config/kernel-rename.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
dnl #
dnl # 4.9 API change
dnl # The iops->rename() callback has been replaced by iops->rename2()
dnl # which was introduced in an earlier kernel release.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_RENAME_WITH_FLAGS], [
AC_MSG_CHECKING([whether iops->rename() wants flags])
ZFS_LINUX_TRY_COMPILE([
#include <linux/fs.h>

int rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags) { return (0); }

static const struct inode_operations
iops __attribute__ ((unused)) = {
.rename = rename,
};
],[
],[
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_RENAME_WITH_FLAGS, 1,
[iops->rename() wants flags])
],[
AC_MSG_RESULT([no])
])
])
23 changes: 23 additions & 0 deletions config/kernel-setattr-prepare.m4
Original file line number Diff line number Diff line change
@@ -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)
])
])
27 changes: 27 additions & 0 deletions config/kernel-xattr-handler.m4
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,30 @@ AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_FROM_XATTR_USERNS], [
])
])

dnl #
dnl # 4.9 API change,
dnl # All filesystems which support xattrs are required to have registered
dnl # them with sb->s_xattr. The old getxattr, setxattr, removexattr and
dnl # assoicated helper functions have been removed. This was done all in
dnl # one commit upstream so if one has been removed they all should be.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_XATTR], [
AC_MSG_CHECKING([whether iops->*xattr() exist])
ZFS_LINUX_TRY_COMPILE([
#include <linux/fs.h>
#include <linux/xattr.h>

static const struct inode_operations
iops __attribute__ ((unused)) = {
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
.removexattr = generic_removexattr,
};
],[
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_INODE_XATTR, 1, [iops->*xattr() exist])
],[
AC_MSG_RESULT(no)
])
])
3 changes: 3 additions & 0 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL
ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL_WITH_FLAGS
ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL
ZFS_AC_KERNEL_INODE_OPERATIONS_XATTR
ZFS_AC_KERNE_GET_ACL_HANDLE_CACHE
ZFS_AC_KERNEL_SHOW_OPTIONS
ZFS_AC_KERNEL_FILE_INODE
Expand All @@ -69,11 +70,13 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL_CREATE_NAMEIDATA
ZFS_AC_KERNEL_GET_LINK
ZFS_AC_KERNEL_PUT_LINK
ZFS_AC_KERNEL_RENAME_WITH_FLAGS
ZFS_AC_KERNEL_TRUNCATE_RANGE
ZFS_AC_KERNEL_AUTOMOUNT
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
Expand Down
11 changes: 11 additions & 0 deletions include/linux/vfs_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
13 changes: 13 additions & 0 deletions module/zfs/zpl_ctldir.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,24 @@ zpl_snapdir_readdir(struct file *filp, void *dirent, filldir_t filldir)
}
#endif /* HAVE_VFS_ITERATE */

#if defined(HAVE_RENAME_WITH_FLAGS)
int
zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
struct inode *tdip, struct dentry *tdentry, unsigned int flags)
#else
int
zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
struct inode *tdip, struct dentry *tdentry)
#endif
{
cred_t *cr = CRED();
int error;

#if defined(HAVE_RENAME_WITH_FLAGS)
if (flags)
return (-EINVAL);
#endif

crhold(cr);
error = -zfsctl_snapdir_rename(sdip, dname(sdentry),
tdip, dname(tdentry), cr, 0);
Expand All @@ -317,6 +328,8 @@ zpl_snapdir_rename(struct inode *sdip, struct dentry *sdentry,
return (error);
}



static int
zpl_snapdir_rmdir(struct inode *dip, struct dentry *dentry)
{
Expand Down
21 changes: 20 additions & 1 deletion module/zfs/zpl_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -355,14 +355,25 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
return (error);
}

#if defined(HAVE_RENAME_WITH_FLAGS)
static int
zpl_rename(struct inode *sdip, struct dentry *sdentry,
struct inode *tdip, struct dentry *tdentry, unsigned int flags)
#else
static int
zpl_rename(struct inode *sdip, struct dentry *sdentry,
struct inode *tdip, struct dentry *tdentry)
#endif
{
cred_t *cr = CRED();
int error;
fstrans_cookie_t cookie;

#if defined(HAVE_RENAME_WITH_FLAGS)
if (flags)
return (-EINVAL);
#endif

crhold(cr);
cookie = spl_fstrans_mark();
error = -zfs_rename(sdip, dname(sdentry), tdip, dname(tdentry), cr, 0);
Expand Down Expand Up @@ -659,9 +670,11 @@ const struct inode_operations zpl_inode_operations = {
.rename = zpl_rename,
.setattr = zpl_setattr,
.getattr = zpl_getattr,
#ifdef HAVE_INODE_XATTR
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
.removexattr = generic_removexattr,
#endif /* HAVE_INODE_XATTR */
.listxattr = zpl_xattr_list,
#ifdef HAVE_INODE_TRUNCATE_RANGE
.truncate_range = zpl_truncate_range,
Expand Down Expand Up @@ -692,9 +705,11 @@ const struct inode_operations zpl_dir_inode_operations = {
.rename = zpl_rename,
.setattr = zpl_setattr,
.getattr = zpl_getattr,
#ifdef HAVE_INODE_XATTR
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
.removexattr = generic_removexattr,
#endif /* HAVE_INODE_XATTR */
.listxattr = zpl_xattr_list,
#if defined(CONFIG_FS_POSIX_ACL)
#if defined(HAVE_GET_ACL)
Expand All @@ -719,18 +734,22 @@ const struct inode_operations zpl_symlink_inode_operations = {
#endif
.setattr = zpl_setattr,
.getattr = zpl_getattr,
#ifdef HAVE_INODE_XATTR
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
.removexattr = generic_removexattr,
#endif /* HAVE_INODE_XATTR */
.listxattr = zpl_xattr_list,
};

const struct inode_operations zpl_special_inode_operations = {
.setattr = zpl_setattr,
.getattr = zpl_getattr,
#ifdef HAVE_INODE_XATTR
.setxattr = generic_setxattr,
.getxattr = generic_getxattr,
.removexattr = generic_removexattr,
#endif /* HAVE_INODE_XATTR */
.listxattr = zpl_xattr_list,
#if defined(CONFIG_FS_POSIX_ACL)
#if defined(HAVE_GET_ACL)
Expand Down