generic_acl: no need to clone acl just to push it to set_cached_acl()
[firefly-linux-kernel-4.4.55.git] / fs / generic_acl.c
index 8f26d1a5891226acc324798ed84bdeb27950145c..134782116a62a751fd68094b05542faf53519eec 100644 (file)
@@ -134,14 +134,8 @@ generic_acl_init(struct inode *inode, struct inode *dir)
        if (acl) {
                struct posix_acl *clone;
 
-               if (S_ISDIR(inode->i_mode)) {
-                       clone = posix_acl_clone(acl, GFP_KERNEL);
-                       error = -ENOMEM;
-                       if (!clone)
-                               goto cleanup;
-                       set_cached_acl(inode, ACL_TYPE_DEFAULT, clone);
-                       posix_acl_release(clone);
-               }
+               if (S_ISDIR(inode->i_mode))
+                       set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
                clone = posix_acl_clone(acl, GFP_KERNEL);
                error = -ENOMEM;
                if (!clone)
@@ -170,40 +164,32 @@ cleanup:
 int
 generic_acl_chmod(struct inode *inode)
 {
-       struct posix_acl *acl, *clone;
+       struct posix_acl *acl;
        int error = 0;
 
        if (S_ISLNK(inode->i_mode))
                return -EOPNOTSUPP;
        acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
        if (acl) {
-               clone = posix_acl_clone(acl, GFP_KERNEL);
+               error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+               if (error)
+                       return error;
+               set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
                posix_acl_release(acl);
-               if (!clone)
-                       return -ENOMEM;
-               error = posix_acl_chmod_masq(clone, inode->i_mode);
-               if (!error)
-                       set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
-               posix_acl_release(clone);
        }
        return error;
 }
 
 int
-generic_check_acl(struct inode *inode, int mask, unsigned int flags)
+generic_check_acl(struct inode *inode, int mask)
 {
-       if (flags & IPERM_FLAG_RCU) {
-               if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
-                       return -ECHILD;
-       } else {
-               struct posix_acl *acl;
-
-               acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
-               if (acl) {
-                       int error = posix_acl_permission(inode, acl, mask);
-                       posix_acl_release(acl);
-                       return error;
-               }
+       struct posix_acl *acl;
+
+       acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
+       if (acl) {
+               int error = posix_acl_permission(inode, acl, mask);
+               posix_acl_release(acl);
+               return error;
        }
        return -EAGAIN;
 }