Skip to content

Commit

Permalink
fs/ntfs3: Do not change mode if ntfs_set_ea failed
Browse files Browse the repository at this point in the history
ntfs_set_ea can fail with NOSPC, so we don't need to
change mode in this situation.
Fixes xfstest generic/449
Fixes: be71b5c ("fs/ntfs3: Add attrib operations")

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
  • Loading branch information
Konstantin Komarov committed Aug 3, 2022
1 parent 604a9d2 commit 460bbf2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions fs/ntfs3/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,28 +547,23 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
{
const char *name;
size_t size, name_len;
void *value = NULL;
int err = 0;
void *value;
int err;
int flags;
umode_t mode;

if (S_ISLNK(inode->i_mode))
return -EOPNOTSUPP;

mode = inode->i_mode;
switch (type) {
case ACL_TYPE_ACCESS:
/* Do not change i_mode if we are in init_acl */
if (acl && !init_acl) {
umode_t mode;

err = posix_acl_update_mode(mnt_userns, inode, &mode,
&acl);
if (err)
goto out;

if (inode->i_mode != mode) {
inode->i_mode = mode;
mark_inode_dirty(inode);
}
}
name = XATTR_NAME_POSIX_ACL_ACCESS;
name_len = sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1;
Expand Down Expand Up @@ -604,8 +599,13 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0);
if (err == -ENODATA && !size)
err = 0; /* Removing non existed xattr. */
if (!err)
if (!err) {
set_cached_acl(inode, type, acl);
if (inode->i_mode != mode) {
inode->i_mode = mode;
mark_inode_dirty(inode);
}
}

out:
kfree(value);
Expand Down

0 comments on commit 460bbf2

Please sign in to comment.