Commit fdc85222 authored by Daniel Xu's avatar Daniel Xu Committed by Tejun Heo

kernfs: kvmalloc xattr value instead of kmalloc

xattr values have a 64k maximum size. This can result in an order 4
kmalloc request which can be difficult to fulfill. Since xattrs do not
need physically contiguous memory, we can switch to kvmalloc and not
have to worry about higher order allocations failing.
Signed-off-by: default avatarDaniel Xu <dxu@dxuuu.xyz>
Acked-by: default avatarChris Down <chris@chrisdown.name>
Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent e7b20d97
...@@ -817,7 +817,7 @@ struct simple_xattr *simple_xattr_alloc(const void *value, size_t size) ...@@ -817,7 +817,7 @@ struct simple_xattr *simple_xattr_alloc(const void *value, size_t size)
if (len < sizeof(*new_xattr)) if (len < sizeof(*new_xattr))
return NULL; return NULL;
new_xattr = kmalloc(len, GFP_KERNEL); new_xattr = kvmalloc(len, GFP_KERNEL);
if (!new_xattr) if (!new_xattr)
return NULL; return NULL;
...@@ -882,7 +882,7 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name, ...@@ -882,7 +882,7 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
new_xattr->name = kstrdup(name, GFP_KERNEL); new_xattr->name = kstrdup(name, GFP_KERNEL);
if (!new_xattr->name) { if (!new_xattr->name) {
kfree(new_xattr); kvfree(new_xattr);
return -ENOMEM; return -ENOMEM;
} }
} }
...@@ -912,7 +912,7 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name, ...@@ -912,7 +912,7 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
spin_unlock(&xattrs->lock); spin_unlock(&xattrs->lock);
if (xattr) { if (xattr) {
kfree(xattr->name); kfree(xattr->name);
kfree(xattr); kvfree(xattr);
} }
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment