From patchwork Thu Dec 8 02:32:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 31110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp516181wrr; Wed, 7 Dec 2022 18:13:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf516qrQK4SczjApuoVza5ZPRSVm+kPKTCnno1Z7G5pLw9zk38nwgc8b8VOJtaOd3KCpeC5M X-Received: by 2002:a63:117:0:b0:476:f43d:913e with SMTP id 23-20020a630117000000b00476f43d913emr66503486pgb.386.1670465605802; Wed, 07 Dec 2022 18:13:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670465605; cv=none; d=google.com; s=arc-20160816; b=f/JnWSmzmyt9srb97ikW4Rze/YOcEFTfsiGvQ/ibncNhXp6XaReC4LXEc7Hb/SiNIM xCRZXyc8fRER3PT+GXZ7KY3Zp9dbgr/DrIHizOZ16i5CXdKq01OkIRNi0EV/HOSWgy5Y fHxVXf8Lzl2ZLqGF+kF/Ywt3/AWXqasrGOvrSwIeTs943n9D80qvbN9ng5PjDJa9Pvrz rlcaoO7d7lnEB05G9+8KmvgGd3FD/5kwBHvfey8QOP3ZOTFLeLvM2Wkfap754x/C36nA wMYkPnW/i0K7UzMGrNcoyOIWkOuSJlDY4TVp5izJEcqVdq2ulYKGua0R9IGOpAuVu/xq m3wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WS0VEdUYxxgm1DR1qDpUSG/hGYIeTCdM+l+kJt5a6SU=; b=Z/RG0Osxl9sjmOGQTOuIFAwvOJxq5plZ6BPMgZtWlTx+VcCr2nBycT0m25uEktEoPH jceitmordvcP4iLbFuTZ4twCLzzuFb+COuaSkZvlHdrSwX31zfQBx5W87C0cHQmkcwx/ k7yhDJwP6RZ40IfLg05bcL5FfBXYhjUeFePwqTAe6AYHW/LIaO7knSbPDv8bVZkOj+AB U33238Ri5+0gXh1mruT4XdcmnMCe498boKpkERyewMyLU/BZVuyACyBGvH2iAw64eAvz o1lw1kqmJEVJZVf1nlQ0qLoF5WCmbsN0/0fxBVPD6PmN0AGitWONLZ3Y5ku2ggGZhRIs SOkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a170903028400b00189734b4f02si21593352plr.69.2022.12.07.18.13.12; Wed, 07 Dec 2022 18:13:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbiLHCL4 (ORCPT + 99 others); Wed, 7 Dec 2022 21:11:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbiLHCLp (ORCPT ); Wed, 7 Dec 2022 21:11:45 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EEAC92FCD; Wed, 7 Dec 2022 18:11:44 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4NSHhV6vk3z4f3lGs; Thu, 8 Dec 2022 10:11:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgB3m9jbR5Fjj5BiBw--.22193S6; Thu, 08 Dec 2022 10:11:41 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin Subject: [PATCH v3 2/4] ext4: allocate extended attribute value in vmalloc area Date: Thu, 8 Dec 2022 10:32:31 +0800 Message-Id: <20221208023233.1231330-3-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221208023233.1231330-1-yebin@huaweicloud.com> References: <20221208023233.1231330-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgB3m9jbR5Fjj5BiBw--.22193S6 X-Coremail-Antispam: 1UD129KBjvJXoW7ArWfur4kXF4kZFWrtF1xuFg_yoW8Gr1Upa 9xKa40kr13Xry7uFWIkr48Z342g3ZrGr47uay3Xw40vFy5Xwn2gFyayFWYvF15ZFWftr1v qF1Dtr18Zw43t3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxU2_MaUUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751610143053203287?= X-GMAIL-MSGID: =?utf-8?q?1751610143053203287?= From: Ye Bin 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 Reviewed-by: Jan Kara --- fs/ext4/xattr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)