From 232fc23c6ea4f35e8cbfd47f7ebfb3c25617fe16 Mon Sep 17 00:00:00 2001 From: Coleman Kane Date: Tue, 24 Jan 2023 14:20:50 -0500 Subject: [PATCH] linux 6.2 compat: zpl_set_acl arg2 is now struct dentry Linux 6.2 changes the second argument of the set_acl operation to be a "struct dentry *" rather than a "struct inode *". The inode* parameter is still available as dentry->d_inode, so adjust the call to the _impl function call to dereference and pass that pointer to it. Also document that the get_acl -> get_inode_acl member name change from commit 884a693 was an API change also introduced in Linux 6.2. Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Reviewed-by: Richard Yao Signed-off-by: Coleman Kane Closes #14415 --- config/kernel-acl.m4 | 31 ++++++++++++++++++++++++++++--- include/os/linux/zfs/sys/zpl.h | 3 +++ module/os/linux/zfs/zpl_xattr.c | 7 +++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/config/kernel-acl.m4 b/config/kernel-acl.m4 index 238742901f..6e92da97d0 100644 --- a/config/kernel-acl.m4 +++ b/config/kernel-acl.m4 @@ -165,6 +165,9 @@ dnl # dnl # 5.15 API change, dnl # Added the bool rcu argument to get_acl for rcu path walk. dnl # +dnl # 6.2 API change, +dnl # get_acl() was renamed to get_inode_acl() +dnl # AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_GET_ACL], [ ZFS_LINUX_TEST_SRC([inode_operations_get_acl], [ #include @@ -230,7 +233,22 @@ dnl # dnl # 5.12 API change, dnl # set_acl() added a user_namespace* parameter first dnl # +dnl # 6.2 API change, +dnl # set_acl() second paramter changed to a struct dentry * +dnl # AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_SET_ACL], [ + ZFS_LINUX_TEST_SRC([inode_operations_set_acl_userns_dentry], [ + #include + + int set_acl_fn(struct user_namespace *userns, + struct dentry *dent, struct posix_acl *acl, + int type) { return 0; } + + static const struct inode_operations + iops __attribute__ ((unused)) = { + .set_acl = set_acl_fn, + }; + ],[]) ZFS_LINUX_TEST_SRC([inode_operations_set_acl_userns], [ #include @@ -263,11 +281,18 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL], [ AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists]) AC_DEFINE(HAVE_SET_ACL_USERNS, 1, [iops->set_acl() takes 4 args]) ],[ - ZFS_LINUX_TEST_RESULT([inode_operations_set_acl], [ + ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_userns_dentry], [ AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists, takes 3 args]) + AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists]) + AC_DEFINE(HAVE_SET_ACL_USERNS_DENTRY_ARG2, 1, + [iops->set_acl() takes 4 args, arg2 is struct dentry *]) ],[ - AC_MSG_RESULT(no) + ZFS_LINUX_TEST_RESULT([inode_operations_set_acl], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists, takes 3 args]) + ],[ + ZFS_LINUX_REQUIRE_API([i_op->set_acl()], [3.14]) + ]) ]) ]) ]) diff --git a/include/os/linux/zfs/sys/zpl.h b/include/os/linux/zfs/sys/zpl.h index a3e71eca71..ac9815d4ee 100644 --- a/include/os/linux/zfs/sys/zpl.h +++ b/include/os/linux/zfs/sys/zpl.h @@ -67,6 +67,9 @@ extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip, #if defined(HAVE_SET_ACL_USERNS) extern int zpl_set_acl(struct user_namespace *userns, struct inode *ip, struct posix_acl *acl, int type); +#elif defined(HAVE_SET_ACL_USERNS_DENTRY_ARG2) +extern int zpl_set_acl(struct user_namespace *userns, struct dentry *dentry, + struct posix_acl *acl, int type); #else extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type); #endif /* HAVE_SET_ACL_USERNS */ diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index 24a2d8dcf6..364cd34c16 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1004,11 +1004,18 @@ int #ifdef HAVE_SET_ACL_USERNS zpl_set_acl(struct user_namespace *userns, struct inode *ip, struct posix_acl *acl, int type) +#elif defined(HAVE_SET_ACL_USERNS_DENTRY_ARG2) +zpl_set_acl(struct user_namespace *userns, struct dentry *dentry, + struct posix_acl *acl, int type) #else zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type) #endif /* HAVE_SET_ACL_USERNS */ { +#ifdef HAVE_SET_ACL_USERNS_DENTRY_ARG2 + return (zpl_set_acl_impl(d_inode(dentry), acl, type)); +#else return (zpl_set_acl_impl(ip, acl, type)); +#endif /* HAVE_SET_ACL_USERNS_DENTRY_ARG2 */ } #endif /* HAVE_SET_ACL */