Merge branch 'slab/urgent' into slab/next
[pandora-kernel.git] / fs / reiserfs / xattr_acl.c
index 3dc38f1..6da0396 100644 (file)
@@ -272,12 +272,10 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
        case ACL_TYPE_ACCESS:
                name = POSIX_ACL_XATTR_ACCESS;
                if (acl) {
-                       mode_t mode = inode->i_mode;
-                       error = posix_acl_equiv_mode(acl, &mode);
+                       error = posix_acl_equiv_mode(acl, &inode->i_mode);
                        if (error < 0)
                                return error;
                        else {
-                               inode->i_mode = mode;
                                if (error == 0)
                                        acl = NULL;
                        }
@@ -354,10 +352,6 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
                return PTR_ERR(acl);
 
        if (acl) {
-               struct posix_acl *acl_copy;
-               mode_t mode = inode->i_mode;
-               int need_acl;
-
                /* Copy the default ACL to the default ACL of a new directory */
                if (S_ISDIR(inode->i_mode)) {
                        err = reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT,
@@ -368,29 +362,13 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
 
                /* Now we reconcile the new ACL and the mode,
                   potentially modifying both */
-               acl_copy = posix_acl_clone(acl, GFP_NOFS);
-               if (!acl_copy) {
-                       err = -ENOMEM;
-                       goto cleanup;
-               }
-
-               need_acl = posix_acl_create_masq(acl_copy, &mode);
-               if (need_acl >= 0) {
-                       if (mode != inode->i_mode) {
-                               inode->i_mode = mode;
-                       }
+               err = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
+               if (err < 0)
+                       return err;
 
-                       /* If we need an ACL.. */
-                       if (need_acl > 0) {
-                               err = reiserfs_set_acl(th, inode,
-                                                      ACL_TYPE_ACCESS,
-                                                      acl_copy);
-                               if (err)
-                                       goto cleanup_copy;
-                       }
-               }
-             cleanup_copy:
-               posix_acl_release(acl_copy);
+               /* If we need an ACL.. */
+               if (err > 0)
+                       err = reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, acl);
              cleanup:
                posix_acl_release(acl);
        } else {
@@ -445,7 +423,10 @@ int reiserfs_cache_default_acl(struct inode *inode)
 
 int reiserfs_acl_chmod(struct inode *inode)
 {
-       struct posix_acl *acl, *clone;
+       struct reiserfs_transaction_handle th;
+       struct posix_acl *acl;
+       size_t size;
+       int depth;
        int error;
 
        if (S_ISLNK(inode->i_mode))
@@ -463,30 +444,22 @@ int reiserfs_acl_chmod(struct inode *inode)
                return 0;
        if (IS_ERR(acl))
                return PTR_ERR(acl);
-       clone = posix_acl_clone(acl, GFP_NOFS);
-       posix_acl_release(acl);
-       if (!clone)
-               return -ENOMEM;
-       error = posix_acl_chmod_masq(clone, inode->i_mode);
+       error = posix_acl_chmod(&acl, GFP_NOFS, inode->i_mode);
+       if (error)
+               return error;
+
+       size = reiserfs_xattr_nblocks(inode, reiserfs_acl_size(acl->a_count));
+       depth = reiserfs_write_lock_once(inode->i_sb);
+       error = journal_begin(&th, inode->i_sb, size * 2);
        if (!error) {
-               struct reiserfs_transaction_handle th;
-               size_t size = reiserfs_xattr_nblocks(inode,
-                                            reiserfs_acl_size(clone->a_count));
-               int depth;
-
-               depth = reiserfs_write_lock_once(inode->i_sb);
-               error = journal_begin(&th, inode->i_sb, size * 2);
-               if (!error) {
-                       int error2;
-                       error = reiserfs_set_acl(&th, inode, ACL_TYPE_ACCESS,
-                                                clone);
-                       error2 = journal_end(&th, inode->i_sb, size * 2);
-                       if (error2)
-                               error = error2;
-               }
-               reiserfs_write_unlock_once(inode->i_sb, depth);
+               int error2;
+               error = reiserfs_set_acl(&th, inode, ACL_TYPE_ACCESS, acl);
+               error2 = journal_end(&th, inode->i_sb, size * 2);
+               if (error2)
+                       error = error2;
        }
-       posix_acl_release(clone);
+       reiserfs_write_unlock_once(inode->i_sb, depth);
+       posix_acl_release(acl);
        return error;
 }