summaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_acl.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2013-09-02 20:53:00 +1000
committerBen Myers <bpm@sgi.com>2013-09-10 13:57:03 -0500
commitfdd3cceef46f2c18c618669cfae5c0f47d6982f9 (patch)
tree4f408c2bc2bc36bf5f4da36fd0e0f51fc4857964 /fs/xfs/xfs_acl.c
parent2dc164f2965b92a6efd2edb9e2813271741e96db (diff)
downloadlinux-fdd3cceef46f2c18c618669cfae5c0f47d6982f9.tar.bz2
xfs: factor all the kmalloc-or-vmalloc fallback allocations
We have quite a few places now where we do: x = kmem_zalloc(large size) if (!x) x = kmem_zalloc_large(large size) and do a similar dance when freeing the memory. kmem_free() already does the correct freeing dance, and kmem_zalloc_large() is only ever called in these constructs, so just factor it all into kmem_zalloc_large() and kmem_free(). Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_acl.c')
-rw-r--r--fs/xfs/xfs_acl.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 4ea73cc44259..0e2f37efedd0 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -152,12 +152,9 @@ xfs_get_acl(struct inode *inode, int type)
* go out to the disk.
*/
len = XFS_ACL_MAX_SIZE(ip->i_mount);
- xfs_acl = kmem_zalloc(len, KM_SLEEP | KM_MAYFAIL);
- if (!xfs_acl) {
- xfs_acl = kmem_zalloc_large(len);
- if (!xfs_acl)
- return ERR_PTR(-ENOMEM);
- }
+ xfs_acl = kmem_zalloc_large(len, KM_SLEEP);
+ if (!xfs_acl)
+ return ERR_PTR(-ENOMEM);
error = -xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl,
&len, ATTR_ROOT);
@@ -181,10 +178,7 @@ xfs_get_acl(struct inode *inode, int type)
out_update_cache:
set_cached_acl(inode, type, acl);
out:
- if (is_vmalloc_addr(xfs_acl))
- kmem_free_large(xfs_acl);
- else
- kfree(xfs_acl);
+ kmem_free(xfs_acl);
return acl;
}
@@ -215,12 +209,9 @@ xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
struct xfs_acl *xfs_acl;
int len = XFS_ACL_MAX_SIZE(ip->i_mount);
- xfs_acl = kmem_zalloc(len, KM_SLEEP | KM_MAYFAIL);
- if (!xfs_acl) {
- xfs_acl = kmem_zalloc_large(len);
- if (!xfs_acl)
- return -ENOMEM;
- }
+ xfs_acl = kmem_zalloc_large(len, KM_SLEEP);
+ if (!xfs_acl)
+ return -ENOMEM;
xfs_acl_to_disk(xfs_acl, acl);
@@ -231,10 +222,7 @@ xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
error = -xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl,
len, ATTR_ROOT);
- if (is_vmalloc_addr(xfs_acl))
- kmem_free_large(xfs_acl);
- else
- kfree(xfs_acl);
+ kmem_free(xfs_acl);
} else {
/*
* A NULL ACL argument means we want to remove the ACL.