]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/orangefs/acl.c
Merge branch 'for-4.14-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
[linux.git] / fs / orangefs / acl.c
index 7a3754488312c650b3003f5cb23a06bb17a53aeb..9108ef433e6d7b09721360a4dc3c1e7f4f2caf3b 100644 (file)
@@ -35,7 +35,7 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
         * I don't do that for now.
         */
        value = kmalloc(ORANGEFS_MAX_XATTR_VALUELEN, GFP_KERNEL);
-       if (value == NULL)
+       if (!value)
                return ERR_PTR(-ENOMEM);
 
        gossip_debug(GOSSIP_ACL_DEBUG,
@@ -61,9 +61,9 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
        return acl;
 }
 
-int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+static int __orangefs_set_acl(struct inode *inode, struct posix_acl *acl,
+                             int type)
 {
-       struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
        int error = 0;
        void *value = NULL;
        size_t size = 0;
@@ -72,22 +72,6 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
        switch (type) {
        case ACL_TYPE_ACCESS:
                name = XATTR_NAME_POSIX_ACL_ACCESS;
-               if (acl) {
-                       umode_t mode;
-
-                       error = posix_acl_update_mode(inode, &mode, &acl);
-                       if (error) {
-                               gossip_err("%s: posix_acl_update_mode err: %d\n",
-                                          __func__,
-                                          error);
-                               return error;
-                       }
-
-                       if (inode->i_mode != mode)
-                               SetModeFlag(orangefs_inode);
-                       inode->i_mode = mode;
-                       mark_inode_dirty_sync(inode);
-               }
                break;
        case ACL_TYPE_DEFAULT:
                name = XATTR_NAME_POSIX_ACL_DEFAULT;
@@ -132,6 +116,42 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
        return error;
 }
 
+int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+{
+       int error;
+       struct iattr iattr;
+       int rc;
+
+       if (type == ACL_TYPE_ACCESS && acl) {
+               /*
+                * posix_acl_update_mode checks to see if the permissions
+                * described by the ACL can be encoded into the
+                * object's mode. If so, it sets "acl" to NULL
+                * and "mode" to the new desired value. It is up to
+                * us to propagate the new mode back to the server...
+                */
+               error = posix_acl_update_mode(inode, &iattr.ia_mode, &acl);
+               if (error) {
+                       gossip_err("%s: posix_acl_update_mode err: %d\n",
+                                  __func__,
+                                  error);
+                       return error;
+               }
+
+               if (acl) {
+                       rc = __orangefs_set_acl(inode, acl, type);
+               } else {
+                       iattr.ia_valid = ATTR_MODE;
+                       rc = orangefs_inode_setattr(inode, &iattr);
+               }
+
+               return rc;
+
+       } else {
+               return -EINVAL;
+       }
+}
+
 int orangefs_init_acl(struct inode *inode, struct inode *dir)
 {
        struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
@@ -146,13 +166,14 @@ int orangefs_init_acl(struct inode *inode, struct inode *dir)
                return error;
 
        if (default_acl) {
-               error = orangefs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
+               error = __orangefs_set_acl(inode, default_acl,
+                                          ACL_TYPE_DEFAULT);
                posix_acl_release(default_acl);
        }
 
        if (acl) {
                if (!error)
-                       error = orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS);
+                       error = __orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS);
                posix_acl_release(acl);
        }