xfs: only allocate the buffer size actually needed in __xfs_set_acl
authorChristoph Hellwig <hch@lst.de>
Thu, 27 Feb 2020 01:30:44 +0000 (17:30 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 3 Mar 2020 04:55:55 +0000 (20:55 -0800)
No need to allocate the max size if we can just allocate the easily
known actual ACL size.

Suggested-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_acl.c

index 950ae1e7dae65e5b2d1065ae611071de262f8ba8..d4c687b5cd067822a8fb81a99d6d1f8586d56e57 100644 (file)
@@ -191,16 +191,11 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
        args.namelen = strlen(args.name);
 
        if (acl) {
-               args.valuelen = XFS_ACL_MAX_SIZE(ip->i_mount);
+               args.valuelen = XFS_ACL_SIZE(acl->a_count);
                args.value = kmem_zalloc_large(args.valuelen, 0);
                if (!args.value)
                        return -ENOMEM;
-
                xfs_acl_to_disk(args.value, acl);
-
-               /* subtract away the unused acl entries */
-               args.valuelen -= sizeof(struct xfs_acl_entry) *
-                        (XFS_ACL_MAX_ENTRIES(ip->i_mount) - acl->a_count);
        }
 
        error = xfs_attr_set(&args);