From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 1/2] xfs: fix memory allocation failures with ACLs
Date: Mon, 2 Sep 2013 20:52:59 +1000 [thread overview]
Message-ID: <1378119180-31380-2-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1378119180-31380-1-git-send-email-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
Ever since increasing the number of supported ACLs from 25 to as
many as can fit in an xattr, there have been reports of order 4
memory allocations failing in the ACL code. Fix it in the same way
we've fixed all the xattr read/write code that has the same problem.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
fs/xfs/xfs_acl.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 6951896..4ea73cc 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -152,9 +152,12 @@ xfs_get_acl(struct inode *inode, int type)
* go out to the disk.
*/
len = XFS_ACL_MAX_SIZE(ip->i_mount);
- xfs_acl = kzalloc(len, GFP_KERNEL);
- if (!xfs_acl)
- return ERR_PTR(-ENOMEM);
+ 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);
+ }
error = -xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl,
&len, ATTR_ROOT);
@@ -175,10 +178,13 @@ xfs_get_acl(struct inode *inode, int type)
if (IS_ERR(acl))
goto out;
- out_update_cache:
+out_update_cache:
set_cached_acl(inode, type, acl);
- out:
- kfree(xfs_acl);
+out:
+ if (is_vmalloc_addr(xfs_acl))
+ kmem_free_large(xfs_acl);
+ else
+ kfree(xfs_acl);
return acl;
}
@@ -209,9 +215,12 @@ 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 = kzalloc(len, GFP_KERNEL);
- if (!xfs_acl)
- return -ENOMEM;
+ 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_to_disk(xfs_acl, acl);
@@ -222,7 +231,10 @@ 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);
- kfree(xfs_acl);
+ if (is_vmalloc_addr(xfs_acl))
+ kmem_free_large(xfs_acl);
+ else
+ kfree(xfs_acl);
} else {
/*
* A NULL ACL argument means we want to remove the ACL.
--
1.8.3.2
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2013-09-02 10:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-02 10:52 [PATCH 0/2] xfs: fix some new memory allocation failures Dave Chinner
2013-09-02 10:52 ` Dave Chinner [this message]
2013-09-06 19:59 ` [PATCH 1/2] xfs: fix memory allocation failures with ACLs Mark Tinguely
2013-09-02 10:53 ` [PATCH 2/2] xfs: factor all the kmalloc-or-vmalloc fallback allocations Dave Chinner
2013-09-06 20:37 ` Mark Tinguely
2013-09-02 17:03 ` [PATCH 0/2] xfs: fix some new memory allocation failures Mark Tinguely
2013-09-02 22:20 ` Dave Chinner
2013-09-03 13:07 ` Mark Tinguely
2013-09-03 20:04 ` Dave Chinner
2013-09-03 20:46 ` Mark Tinguely
2013-09-03 21:16 ` Dave Chinner
2013-09-03 22:38 ` Mark Tinguely
2013-09-10 22:40 ` Ben Myers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1378119180-31380-2-git-send-email-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox