summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/bcachefs/acl.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/fs/bcachefs/acl.c b/fs/bcachefs/acl.c
index 4016ab965972..d29bdafaea66 100644
--- a/fs/bcachefs/acl.c
+++ b/fs/bcachefs/acl.c
@@ -180,27 +180,16 @@ int bch2_set_acl(struct inode *vinode, struct posix_acl *acl, int type)
{
struct bch_inode_info *inode = to_bch_ei(vinode);
struct bch_fs *c = inode->v.i_sb->s_fs_info;
+ umode_t mode = inode->v.i_mode;
int name_index;
void *value = NULL;
size_t size = 0;
int ret;
if (type == ACL_TYPE_ACCESS && acl) {
- umode_t mode = inode->v.i_mode;
-
ret = posix_acl_update_mode(&inode->v, &mode, &acl);
if (ret)
return ret;
-
- mutex_lock(&inode->ei_update_lock);
- inode->v.i_mode = mode;
- inode->v.i_ctime = current_time(&inode->v);
-
- ret = bch2_write_inode(c, inode);
- mutex_unlock(&inode->ei_update_lock);
-
- if (ret)
- return ret;
}
switch (type) {
@@ -210,12 +199,8 @@ int bch2_set_acl(struct inode *vinode, struct posix_acl *acl, int type)
ret = posix_acl_equiv_mode(acl, &inode->v.i_mode);
if (ret < 0)
return ret;
- else {
- inode->v.i_ctime = current_time(&inode->v);
- mark_inode_dirty(&inode->v);
- if (ret == 0)
- acl = NULL;
- }
+ if (ret == 0)
+ acl = NULL;
}
break;
@@ -235,8 +220,20 @@ int bch2_set_acl(struct inode *vinode, struct posix_acl *acl, int type)
return (int)PTR_ERR(value);
}
- ret = bch2_xattr_set(c, inode, "", value, size, 0, name_index);
+ if (mode != inode->v.i_mode) {
+ mutex_lock(&inode->ei_update_lock);
+ inode->v.i_mode = mode;
+ inode->v.i_ctime = current_time(&inode->v);
+ ret = bch2_write_inode(c, inode);
+ mutex_unlock(&inode->ei_update_lock);
+
+ if (ret)
+ goto err;
+ }
+
+ ret = bch2_xattr_set(c, inode, "", value, size, 0, name_index);
+err:
kfree(value);
if (ret == -ERANGE)