summaryrefslogtreecommitdiff
path: root/fs/orangefs/acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/orangefs/acl.c')
-rw-r--r--fs/orangefs/acl.c84
1 files changed, 38 insertions, 46 deletions
diff --git a/fs/orangefs/acl.c b/fs/orangefs/acl.c
index 7a3754488312..5aefb705bcc8 100644
--- a/fs/orangefs/acl.c
+++ b/fs/orangefs/acl.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* (C) 2001 Clemson University and The University of Chicago
*
@@ -8,14 +9,16 @@
#include "orangefs-kernel.h"
#include "orangefs-bufmap.h"
#include <linux/posix_acl_xattr.h>
-#include <linux/fs_struct.h>
-struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
+struct posix_acl *orangefs_get_acl(struct inode *inode, int type, bool rcu)
{
struct posix_acl *acl;
int ret;
char *key = NULL, *value = NULL;
+ if (rcu)
+ return ERR_PTR(-ECHILD);
+
switch (type) {
case ACL_TYPE_ACCESS:
key = XATTR_NAME_POSIX_ACL_ACCESS;
@@ -35,7 +38,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 +64,8 @@ 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)
+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 +74,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,36 +118,42 @@ out:
return error;
}
-int orangefs_init_acl(struct inode *inode, struct inode *dir)
+int orangefs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+ struct posix_acl *acl, int type)
{
- struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
- struct posix_acl *default_acl, *acl;
- umode_t mode = inode->i_mode;
- int error = 0;
-
- ClearModeFlag(orangefs_inode);
+ int error;
+ struct iattr iattr;
+ int rc;
+ struct inode *inode = d_inode(dentry);
+
+ memset(&iattr, 0, sizeof iattr);
+
+ 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(&nop_mnt_idmap, inode,
+ &iattr.ia_mode, &acl);
+ if (error) {
+ gossip_err("%s: posix_acl_update_mode err: %d\n",
+ __func__,
+ error);
+ return error;
+ }
- error = posix_acl_create(dir, &mode, &default_acl, &acl);
- if (error)
- return error;
+ if (inode->i_mode != iattr.ia_mode)
+ iattr.ia_valid = ATTR_MODE;
- if (default_acl) {
- 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);
- posix_acl_release(acl);
- }
+ rc = __orangefs_set_acl(inode, acl, type);
- /* If mode of the inode was changed, then do a forcible ->setattr */
- if (mode != inode->i_mode) {
- SetModeFlag(orangefs_inode);
- inode->i_mode = mode;
- orangefs_flush_inode(inode);
- }
+ if (!rc && (iattr.ia_valid == ATTR_MODE))
+ rc = __orangefs_setattr_mode(dentry, &iattr);
- return error;
+ return rc;
}