From b586ea5d937be36eb23df4277275927ce7c2be7c Mon Sep 17 00:00:00 2001 From: Coleman Kane Date: Mon, 26 Dec 2022 22:04:34 -0500 Subject: [PATCH] linux 6.2 compat: get_acl() got moved to get_inode_acl() in 6.2 Linux 6.2 renamed the get_acl() operation to get_inode_acl() in the inode_operations struct. This should fix Issue #14323. Reviewed-by: Richard Yao Reviewed-by: Brian Behlendorf Reviewed-by: Tony Hutter Signed-off-by: Coleman Kane Closes #14323 Closes #14331 --- config/kernel-acl.m4 | 19 ++++++++++++++++++- include/os/linux/zfs/sys/zpl.h | 2 +- module/os/linux/zfs/zpl_inode.c | 12 ++++++++++++ module/os/linux/zfs/zpl_xattr.c | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/config/kernel-acl.m4 b/config/kernel-acl.m4 index a155b59d00..238742901f 100644 --- a/config/kernel-acl.m4 +++ b/config/kernel-acl.m4 @@ -189,6 +189,18 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_GET_ACL], [ .get_acl = get_acl_fn, }; ],[]) + + ZFS_LINUX_TEST_SRC([inode_operations_get_inode_acl], [ + #include + + struct posix_acl *get_inode_acl_fn(struct inode *inode, int type, + bool rcu) { return NULL; } + + static const struct inode_operations + iops __attribute__ ((unused)) = { + .get_inode_acl = get_inode_acl_fn, + }; + ],[]) ]) AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL], [ @@ -201,7 +213,12 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_GET_ACL_RCU, 1, [iops->get_acl() takes rcu]) ],[ - ZFS_LINUX_TEST_ERROR([iops->get_acl()]) + ZFS_LINUX_TEST_RESULT([inode_operations_get_inode_acl], [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_GET_INODE_ACL, 1, [has iops->get_inode_acl()]) + ],[ + ZFS_LINUX_TEST_ERROR([iops->get_acl() or iops->get_inode_acl()]) + ]) ]) ]) ]) diff --git a/include/os/linux/zfs/sys/zpl.h b/include/os/linux/zfs/sys/zpl.h index 5f929dc32a..a3e71eca71 100644 --- a/include/os/linux/zfs/sys/zpl.h +++ b/include/os/linux/zfs/sys/zpl.h @@ -71,7 +71,7 @@ extern int zpl_set_acl(struct user_namespace *userns, struct inode *ip, extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type); #endif /* HAVE_SET_ACL_USERNS */ #endif /* HAVE_SET_ACL */ -#if defined(HAVE_GET_ACL_RCU) +#if defined(HAVE_GET_ACL_RCU) || defined(HAVE_GET_INODE_ACL) extern struct posix_acl *zpl_get_acl(struct inode *ip, int type, bool rcu); #elif defined(HAVE_GET_ACL) extern struct posix_acl *zpl_get_acl(struct inode *ip, int type); diff --git a/module/os/linux/zfs/zpl_inode.c b/module/os/linux/zfs/zpl_inode.c index fece7886e1..dd634f70eb 100644 --- a/module/os/linux/zfs/zpl_inode.c +++ b/module/os/linux/zfs/zpl_inode.c @@ -726,7 +726,11 @@ const struct inode_operations zpl_inode_operations = { #if defined(HAVE_SET_ACL) .set_acl = zpl_set_acl, #endif /* HAVE_SET_ACL */ +#if defined(HAVE_GET_INODE_ACL) + .get_inode_acl = zpl_get_acl, +#else .get_acl = zpl_get_acl, +#endif /* HAVE_GET_INODE_ACL */ #endif /* CONFIG_FS_POSIX_ACL */ }; @@ -759,7 +763,11 @@ const struct inode_operations zpl_dir_inode_operations = { #if defined(HAVE_SET_ACL) .set_acl = zpl_set_acl, #endif /* HAVE_SET_ACL */ +#if defined(HAVE_GET_INODE_ACL) + .get_inode_acl = zpl_get_acl, +#else .get_acl = zpl_get_acl, +#endif /* HAVE_GET_INODE_ACL */ #endif /* CONFIG_FS_POSIX_ACL */ }; @@ -798,6 +806,10 @@ const struct inode_operations zpl_special_inode_operations = { #if defined(HAVE_SET_ACL) .set_acl = zpl_set_acl, #endif /* HAVE_SET_ACL */ +#if defined(HAVE_GET_INODE_ACL) + .get_inode_acl = zpl_get_acl, +#else .get_acl = zpl_get_acl, +#endif /* HAVE_GET_INODE_ACL */ #endif /* CONFIG_FS_POSIX_ACL */ }; diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c index 9d758d2d0e..24a2d8dcf6 100644 --- a/module/os/linux/zfs/zpl_xattr.c +++ b/module/os/linux/zfs/zpl_xattr.c @@ -1067,7 +1067,7 @@ zpl_get_acl_impl(struct inode *ip, int type) return (acl); } -#if defined(HAVE_GET_ACL_RCU) +#if defined(HAVE_GET_ACL_RCU) || defined(HAVE_GET_INODE_ACL) struct posix_acl * zpl_get_acl(struct inode *ip, int type, bool rcu) {