Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs/ntfs3: update mode in xattr when ACL can be reduced to mode

If a file's ACL can be reduced to standard mode bits, update mode
accordingly, persist the change, and update the cached ACL. This keeps
mode and ACL consistent and avoids redundant xattrs.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>

+14 -4
+14 -4
fs/ntfs3/xattr.c
··· 654 654 err = ntfs_set_ea(inode, name, name_len, value, size, flags, 0, NULL); 655 655 if (err == -ENODATA && !size) 656 656 err = 0; /* Removing non existed xattr. */ 657 - if (!err) { 658 - set_cached_acl(inode, type, acl); 657 + if (err) 658 + goto out; 659 + 660 + if (inode->i_mode != mode) { 661 + umode_t old_mode = inode->i_mode; 659 662 inode->i_mode = mode; 660 - inode_set_ctime_current(inode); 661 - mark_inode_dirty(inode); 663 + err = ntfs_save_wsl_perm(inode, NULL); 664 + if (err) { 665 + inode->i_mode = old_mode; 666 + goto out; 667 + } 668 + inode->i_mode = mode; 662 669 } 670 + set_cached_acl(inode, type, acl); 671 + inode_set_ctime_current(inode); 672 + mark_inode_dirty(inode); 663 673 664 674 out: 665 675 kfree(value);