From patchwork Fri Apr 28 18:55:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Sun X-Patchwork-Id: 1775087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=zs4+=at=vger.kernel.org=linux-ext4-owner@ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=RfCR/uce; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q7MHd35zCz23tZ for ; Sat, 29 Apr 2023 04:55:25 +1000 (AEST) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Q7MHc62tRz4x84 for ; Sat, 29 Apr 2023 04:55:24 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Q7MHc5rbjz4xND; Sat, 29 Apr 2023 04:55:24 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=RfCR/uce; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Q7MHc5ldKz4x84 for ; Sat, 29 Apr 2023 04:55:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbjD1SzX (ORCPT ); Fri, 28 Apr 2023 14:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjD1SzX (ORCPT ); Fri, 28 Apr 2023 14:55:23 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 198D01704 for ; Fri, 28 Apr 2023 11:55:22 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-64115eef620so14727577b3a.1 for ; Fri, 28 Apr 2023 11:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682708121; x=1685300121; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iwsTvGgs6Jnry5ozjxa7cP0CMboK4dVFe5rReCvfmfM=; b=RfCR/uceS9hrW9SYT6keNlzqL5o0P1XOxIR+fXb+ymIkMTXp6fOPxbp3seHmjrktBD hU478p8fKdgso+XHDXlNR1x04x5nx+FrR6wdCy0X9blCg7x32vAQ/sttj3XJbwso45Nh Y+ut4Gz/vMh5jD2Rf/0MAnYiyi5Ycfj2sVBjDQ8EJ8ZWQCDSCjyq9qGkljuOFdafRFd6 g9xPoiOAPNQy5jF/bhi/PRutvJo/X2FdG7MWwAstbwyD3cigLh5/E6XxMOrVqAgbAxZ7 i8Grssidq94bQvF/rE91uSPLtNNXq1zhpcawBNV0lBEmcngnL2JyRj4fSXM9fEA4DIln Cqeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682708121; x=1685300121; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iwsTvGgs6Jnry5ozjxa7cP0CMboK4dVFe5rReCvfmfM=; b=MMPZJF3ouf6j5vuIlTutp+kp0z+uinLIkpGtof5lhAfOCUcDJt0mvoaBlAkoSeTTM6 yfNBd8z2M3Zwd0TxC1AFD9V8NJgHVk6J53EdDfCMIloewdOflJxxHS5OIL76SoEIH7ZC IN5LpX+tDBO8R8WXR8TUK/qloaN7LV2QNRJVvLQr9+iWS5Ctv0RsGJLUv5q0OZnG3TA2 Aw+8govvIiVaAld4rMoGRZKjHP+WX0rknBfZzFO+eZIerTp7NytNDH/DBz4h4mHNP0DF DKYDpMAuS/V4Oy6Jdi9Pf39ZWVDtbzyw6xWke3Vg5NknOzEg4fhlke1bci0ugcuCxwGF WQNw== X-Gm-Message-State: AC+VfDx009avh/xd708knBYOEVjZrlU4MupsICYlZ+9H5aGmkglwZEAo vUCasEpHeWCiF6FQD/19v0q4F8T/F6U= X-Google-Smtp-Source: ACHHUZ7+j51MK1U3/b4ucSUEumY9VqwAGXXV61cfupifq07N2peaLLwCCBzzBvRZekVVgiNbZuFjjw== X-Received: by 2002:a05:6a00:1688:b0:63b:6279:1039 with SMTP id k8-20020a056a00168800b0063b62791039mr7279977pfc.0.1682708120802; Fri, 28 Apr 2023 11:55:20 -0700 (PDT) Received: from localhost ([101.224.161.147]) by smtp.gmail.com with ESMTPSA id l18-20020a62be12000000b0063b7b811ce8sm15407387pff.205.2023.04.28.11.55.19 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Apr 2023 11:55:20 -0700 (PDT) From: JunChao Sun To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, JunChao Sun Subject: [PATCH] ext4: Optimize memory usage in xattr Date: Fri, 28 Apr 2023 11:55:17 -0700 Message-Id: <20230428185517.1201-1-sunjunchao2870@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org Currently struct ext4_attr_info->in_inode use int, but the value is only 0 or 1, so replace int with bool. Signed-off-by: JunChao Sun Reviewed-by: Jan Kara --- fs/ext4/xattr.c | 8 ++++---- fs/ext4/xattr.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 767454d..d57408c 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1639,7 +1639,7 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_entry *last, *next; struct ext4_xattr_entry *here = s->here; size_t min_offs = s->end - s->base, name_len = strlen(i->name); - int in_inode = i->in_inode; + bool in_inode = i->in_inode; struct inode *old_ea_inode = NULL; struct inode *new_ea_inode = NULL; size_t old_size, new_size; @@ -2354,7 +2354,7 @@ static struct buffer_head *ext4_xattr_get_block(struct inode *inode) .name = name, .value = value, .value_len = value_len, - .in_inode = 0, + .in_inode = false, }; struct ext4_xattr_ibody_find is = { .s = { .not_found = -ENODATA, }, @@ -2441,7 +2441,7 @@ static struct buffer_head *ext4_xattr_get_block(struct inode *inode) if (ext4_has_feature_ea_inode(inode->i_sb) && (EXT4_XATTR_SIZE(i.value_len) > EXT4_XATTR_MIN_LARGE_EA_SIZE(inode->i_sb->s_blocksize))) - i.in_inode = 1; + i.in_inode = true; retry_inode: error = ext4_xattr_ibody_set(handle, inode, &i, &is); if (!error && !bs.s.not_found) { @@ -2467,7 +2467,7 @@ static struct buffer_head *ext4_xattr_get_block(struct inode *inode) */ if (ext4_has_feature_ea_inode(inode->i_sb) && i.value_len && !i.in_inode) { - i.in_inode = 1; + i.in_inode = true; goto retry_inode; } } diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h index 824faf0..355d373 100644 --- a/fs/ext4/xattr.h +++ b/fs/ext4/xattr.h @@ -113,7 +113,7 @@ struct ext4_xattr_info { const void *value; size_t value_len; int name_index; - int in_inode; + bool in_inode; }; struct ext4_xattr_search {