Skip to content

Commit 460bbf2

Browse files
fs/ntfs3: Do not change mode if ntfs_set_ea failed
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 <[email protected]>
1 parent 604a9d2 commit 460bbf2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

fs/ntfs3/xattr.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,28 +547,23 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
547547
{
548548
const char *name;
549549
size_t size, name_len;
550-
void *value = NULL;
551-
int err = 0;
550+
void *value;
551+
int err;
552552
int flags;
553+
umode_t mode;
553554

554555
if (S_ISLNK(inode->i_mode))
555556
return -EOPNOTSUPP;
556557

558+
mode = inode->i_mode;
557559
switch (type) {
558560
case ACL_TYPE_ACCESS:
559561
/* Do not change i_mode if we are in init_acl */
560562
if (acl && !init_acl) {
561-
umode_t mode;
562-
563563
err = posix_acl_update_mode(mnt_userns, inode, &mode,
564564
&acl);
565565
if (err)
566566
goto out;
567-
568-
if (inode->i_mode != mode) {
569-
inode->i_mode = mode;
570-
mark_inode_dirty(inode);
571-
}
572567
}
573568
name = XATTR_NAME_POSIX_ACL_ACCESS;
574569
name_len = sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1;
@@ -604,8 +599,13 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
604599
err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0);
605600
if (err == -ENODATA && !size)
606601
err = 0; /* Removing non existed xattr. */
607-
if (!err)
602+
if (!err) {
608603
set_cached_acl(inode, type, acl);
604+
if (inode->i_mode != mode) {
605+
inode->i_mode = mode;
606+
mark_inode_dirty(inode);
607+
}
608+
}
609609

610610
out:
611611
kfree(value);

0 commit comments

Comments
 (0)