diff mbox series

[v3,2/4] ext4: allocate extended attribute value in vmalloc area

Message ID 20221208023233.1231330-3-yebin@huaweicloud.com
State Accepted
Headers show
Series Fix two issue about ext4 extended attribute | expand

Commit Message

Ye Bin Dec. 8, 2022, 2:32 a.m. UTC
From: Ye Bin <yebin10@huawei.com>

Now, extended attribute value maximum length is 64K. The memory requested
here does not need continuous physical addresses, so it is appropriate to
use kvmalloc to request memory. At the same time, it can also cope with
the situation that the extended attribute will become longer in the future.

Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
 fs/ext4/xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Theodore Ts'o Dec. 9, 2022, 5:35 a.m. UTC | #1
On Thu, Dec 08, 2022 at 10:32:31AM +0800, Ye Bin wrote:
> From: Ye Bin <yebin10@huawei.com>
> 
> Now, extended attribute value maximum length is 64K. The memory requested
> here does not need continuous physical addresses, so it is appropriate to
> use kvmalloc to request memory. At the same time, it can also cope with
> the situation that the extended attribute will become longer in the future.
> 
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> Reviewed-by: Jan Kara <jack@suse.cz>

Applied, thanks.

					- Ted
diff mbox series

Patch

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 718ef3987f94..23cfefc6d262 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -2556,7 +2556,7 @@  static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
 
 	is = kzalloc(sizeof(struct ext4_xattr_ibody_find), GFP_NOFS);
 	bs = kzalloc(sizeof(struct ext4_xattr_block_find), GFP_NOFS);
-	buffer = kmalloc(value_size, GFP_NOFS);
+	buffer = kvmalloc(value_size, GFP_NOFS);
 	b_entry_name = kmalloc(entry->e_name_len + 1, GFP_NOFS);
 	if (!is || !bs || !buffer || !b_entry_name) {
 		error = -ENOMEM;
@@ -2608,7 +2608,7 @@  static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
 	error = 0;
 out:
 	kfree(b_entry_name);
-	kfree(buffer);
+	kvfree(buffer);
 	if (is)
 		brelse(is->iloc.bh);
 	if (bs)