]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Linux 3.14 compat: assign inode->set_acl
authortuxoko <tuxoko@gmail.com>
Wed, 9 Nov 2016 18:37:17 +0000 (10:37 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 9 Nov 2016 18:37:17 +0000 (10:37 -0800)
Linux 3.14 introduces inode->set_acl(). Normally, acl modification will come
from setxattr, which will handle by the acl xattr_handler, and we already
handles that well. However, nfsd will directly calls inode->set_acl or
return error if it doesn't exists.

Reviewed-by: Tim Chase <tim@chase2k.com>
Reviewed-by: Massimo Maggi <me@massimo-maggi.eu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #5371
Closes #5375

config/kernel-acl.m4
config/kernel.m4
include/sys/zpl.h
module/zfs/zpl_inode.c
module/zfs/zpl_xattr.c

index 949583762709c090595adb0642174888d6d7d7e7..72510854a203a013bb6f37c1e8f62e88102415b3 100644 (file)
@@ -279,6 +279,31 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL], [
        ])
 ])
 
+dnl #
+dnl # 3.14 API change,
+dnl # Check if inode_operations contains the function set_acl
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL], [
+       AC_MSG_CHECKING([whether iops->set_acl() exists])
+       ZFS_LINUX_TRY_COMPILE([
+               #include <linux/fs.h>
+
+               int set_acl_fn(struct inode *inode, struct posix_acl *acl, int type)
+                   { return 0; }
+
+               static const struct inode_operations
+                   iops __attribute__ ((unused)) = {
+                       .set_acl = set_acl_fn,
+               };
+       ],[
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+])
+
 dnl #
 dnl # 4.7 API change,
 dnl # The kernel get_acl will now check cache before calling i_op->get_acl and
index 8e1f10ec3996b8f358be1122b9e1e8ad8a36d621..af5945140b99e2d7e5c7d7f912f28165c1cb5d64 100644 (file)
@@ -55,6 +55,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_SET_ACL
        ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE
        ZFS_AC_KERNEL_SHOW_OPTIONS
        ZFS_AC_KERNEL_FILE_INODE
index 386cf6d09af31c4ec6019b0c574e267911d22bde..174d40efa905c6f0cc24cc2a942341d51af1c3d5 100644 (file)
@@ -76,7 +76,7 @@ extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size);
 extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
     const struct qstr *qstr);
 #if defined(CONFIG_FS_POSIX_ACL)
-extern int zpl_set_acl(struct inode *ip, int type, struct posix_acl *acl);
+extern int zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type);
 extern struct posix_acl *zpl_get_acl(struct inode *ip, int type);
 #if !defined(HAVE_GET_ACL)
 #if defined(HAVE_CHECK_ACL_WITH_FLAGS)
index b1f9b1f4e6d808eee756f8a3064df2facfdd7971..e3c5748104a33165a137a71876200a051a9c0d1d 100644 (file)
@@ -716,6 +716,9 @@ const struct inode_operations zpl_inode_operations = {
        .fallocate      = zpl_fallocate,
 #endif /* HAVE_INODE_FALLOCATE */
 #if defined(CONFIG_FS_POSIX_ACL)
+#if defined(HAVE_SET_ACL)
+       .set_acl        = zpl_set_acl,
+#endif
 #if defined(HAVE_GET_ACL)
        .get_acl        = zpl_get_acl,
 #elif defined(HAVE_CHECK_ACL)
@@ -752,6 +755,9 @@ const struct inode_operations zpl_dir_inode_operations = {
 #endif
        .listxattr      = zpl_xattr_list,
 #if defined(CONFIG_FS_POSIX_ACL)
+#if defined(HAVE_SET_ACL)
+       .set_acl        = zpl_set_acl,
+#endif
 #if defined(HAVE_GET_ACL)
        .get_acl        = zpl_get_acl,
 #elif defined(HAVE_CHECK_ACL)
@@ -792,6 +798,9 @@ const struct inode_operations zpl_special_inode_operations = {
 #endif
        .listxattr      = zpl_xattr_list,
 #if defined(CONFIG_FS_POSIX_ACL)
+#if defined(HAVE_SET_ACL)
+       .set_acl        = zpl_set_acl,
+#endif
 #if defined(HAVE_GET_ACL)
        .get_acl        = zpl_get_acl,
 #elif defined(HAVE_CHECK_ACL)
index f3a04f733e50c5242666380b5a524dec15034b12..cec8708246c151f5fbc008a846e19bd02d458090 100644 (file)
@@ -936,7 +936,7 @@ xattr_handler_t zpl_xattr_security_handler = {
  */
 #ifdef CONFIG_FS_POSIX_ACL
 int
-zpl_set_acl(struct inode *ip, int type, struct posix_acl *acl)
+zpl_set_acl(struct inode *ip, struct posix_acl *acl, int type)
 {
        struct super_block *sb = ITOZSB(ip)->z_sb;
        char *name, *value = NULL;
@@ -1140,7 +1140,7 @@ zpl_init_acl(struct inode *ip, struct inode *dir)
                umode_t mode;
 
                if (S_ISDIR(ip->i_mode)) {
-                       error = zpl_set_acl(ip, ACL_TYPE_DEFAULT, acl);
+                       error = zpl_set_acl(ip, acl, ACL_TYPE_DEFAULT);
                        if (error)
                                goto out;
                }
@@ -1151,7 +1151,7 @@ zpl_init_acl(struct inode *ip, struct inode *dir)
                        ip->i_mode = mode;
                        zfs_mark_inode_dirty(ip);
                        if (error > 0)
-                               error = zpl_set_acl(ip, ACL_TYPE_ACCESS, acl);
+                               error = zpl_set_acl(ip, acl, ACL_TYPE_ACCESS);
                }
        }
 out:
@@ -1178,7 +1178,7 @@ zpl_chmod_acl(struct inode *ip)
 
        error = __posix_acl_chmod(&acl, GFP_KERNEL, ip->i_mode);
        if (!error)
-               error = zpl_set_acl(ip, ACL_TYPE_ACCESS, acl);
+               error = zpl_set_acl(ip, acl, ACL_TYPE_ACCESS);
 
        zpl_posix_acl_release(acl);
 
@@ -1308,7 +1308,7 @@ __zpl_xattr_acl_set_access(struct inode *ip, const char *name,
                acl = NULL;
        }
 
-       error = zpl_set_acl(ip, type, acl);
+       error = zpl_set_acl(ip, acl, type);
        zpl_posix_acl_release(acl);
 
        return (error);
@@ -1348,7 +1348,7 @@ __zpl_xattr_acl_set_default(struct inode *ip, const char *name,
                acl = NULL;
        }
 
-       error = zpl_set_acl(ip, type, acl);
+       error = zpl_set_acl(ip, acl, type);
        zpl_posix_acl_release(acl);
 
        return (error);