Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / fs / reiserfs / xattr_acl.c
index 1d4f4c7..81b8c07 100644 (file)
@@ -250,15 +250,9 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
        return acl;
 }
 
-/*
- * Inode operation set_posix_acl().
- *
- * inode->i_mutex: down
- * BKL held [before 2.5.x]
- */
 static int
-reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
-                int type, struct posix_acl *acl)
+__reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
+                  int type, struct posix_acl *acl)
 {
        char *name;
        void *value = NULL;
@@ -271,11 +265,6 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
        switch (type) {
        case ACL_TYPE_ACCESS:
                name = POSIX_ACL_XATTR_ACCESS;
-               if (acl) {
-                       error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
-                       if (error)
-                               return error;
-               }
                break;
        case ACL_TYPE_DEFAULT:
                name = POSIX_ACL_XATTR_DEFAULT;
@@ -316,6 +305,31 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
        return error;
 }
 
+/*
+ * Inode operation set_posix_acl().
+ *
+ * inode->i_mutex: down
+ */
+static int
+reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
+                int type, struct posix_acl *acl)
+{
+       int error;
+       int update_mode = 0;
+       umode_t mode = inode->i_mode;
+
+       if (type == ACL_TYPE_ACCESS && acl) {
+               error = posix_acl_update_mode(inode, &mode, &acl);
+               if (error)
+                       return error;
+               update_mode = 1;
+       }
+       error = __reiserfs_set_acl(th, inode, type, acl);
+       if (!error && update_mode)
+               inode->i_mode = mode;
+       return error;
+}
+
 /* dir->i_mutex: locked,
  * inode is new and not released into the wild yet */
 int
@@ -350,8 +364,8 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
        if (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,
-                                              acl);
+                       err = __reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT,
+                                                acl);
                        if (err)
                                goto cleanup;
                }
@@ -364,7 +378,7 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
 
                /* If we need an ACL.. */
                if (err > 0)
-                       err = reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, acl);
+                       err = __reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, acl);
              cleanup:
                posix_acl_release(acl);
        } else {