From patchwork Thu May 19 01:40:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1633033 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=UJpJCzCv; dkim-atps=neutral Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L3Xd25QwVz9vFL for ; Thu, 19 May 2022 11:41:10 +1000 (AEST) Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4L3Xd12rhwz4xVP for ; Thu, 19 May 2022 11:41:09 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4L3Xd12pJGz4xbC; Thu, 19 May 2022 11:41:09 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org 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=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=UJpJCzCv; 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 4L3Xd03TCzz4xVP for ; Thu, 19 May 2022 11:41:08 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229601AbiESBlH (ORCPT ); Wed, 18 May 2022 21:41:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229589AbiESBlF (ORCPT ); Wed, 18 May 2022 21:41:05 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7A8312A82 for ; Wed, 18 May 2022 18:41:04 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 3D1BF1F4542F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1652924463; bh=VFIxEIWt6o/B0gqn09S6ezHtaQkwGSBs7ym4N8kFX2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UJpJCzCvrRcCQppUfSQn6L2Zi2WA5UCJZEU38RN1KetFo8DhhY+LAkLE5xR1ZhQgb +2FuTmIJz0BHK0UFgdqbYc4MAxiitDdItbGgmiZbrkwn4MIv+/qYYGzeoDV/xjiVxw QYYBRGztRXXb6LXzJOscZ6A8Z1MaFQlveBJH2oxzF8mb+RlkxiAOqatiO5MTJz66dF 0zUUapQx56gEV2n5H32KFREBCkAwS0lSpTWQ8BDeIkFWA5W5SFSSfydUiQ1qgHz7WE 7BoaTWF1SvKt8fZPyjxaQcc2N89bCZM1qfkvW68as/xsY6PQOLkLhQelSE+FXPR+YI Scop/rEy4viDw== From: Gabriel Krisman Bertazi To: tytso@mit.edu, adilger.kernel@dilger.ca, jaegeuk@kernel.org, ebiggers@kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi , kernel@collabora.com, Eric Biggers Subject: [PATCH v6 1/8] ext4: Simplify the handling of cached insensitive names Date: Wed, 18 May 2022 21:40:37 -0400 Message-Id: <20220519014044.508099-2-krisman@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220519014044.508099-1-krisman@collabora.com> References: <20220519014044.508099-1-krisman@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 Keeping it as qstr avoids the unnecessary conversion in ext4_match Reviewed-by: Eric Biggers Signed-off-by: Gabriel Krisman Bertazi --- Changes since v1: - Simplify hunk (eric) --- fs/ext4/ext4.h | 2 +- fs/ext4/namei.c | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index a743b1e3b89e..93a28fcb2e22 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2490,7 +2490,7 @@ struct ext4_filename { struct fscrypt_str crypto_buf; #endif #if IS_ENABLED(CONFIG_UNICODE) - struct fscrypt_str cf_name; + struct qstr cf_name; #endif }; diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 767b4bfe39c3..206fcf8fdc16 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1373,7 +1373,8 @@ static int ext4_ci_compare(const struct inode *parent, const struct qstr *name, int ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, struct ext4_filename *name) { - struct fscrypt_str *cf_name = &name->cf_name; + struct qstr *cf_name = &name->cf_name; + unsigned char *buf; struct dx_hash_info *hinfo = &name->hinfo; int len; @@ -1383,18 +1384,18 @@ int ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, return 0; } - cf_name->name = kmalloc(EXT4_NAME_LEN, GFP_NOFS); - if (!cf_name->name) + buf = kmalloc(EXT4_NAME_LEN, GFP_NOFS); + if (!buf) return -ENOMEM; - len = utf8_casefold(dir->i_sb->s_encoding, - iname, cf_name->name, - EXT4_NAME_LEN); + len = utf8_casefold(dir->i_sb->s_encoding, iname, buf, EXT4_NAME_LEN); if (len <= 0) { - kfree(cf_name->name); - cf_name->name = NULL; + kfree(buf); + buf = NULL; } + cf_name->name = buf; cf_name->len = (unsigned) len; + if (!IS_ENCRYPTED(dir)) return 0; @@ -1432,8 +1433,6 @@ static bool ext4_match(struct inode *parent, if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent) && (!IS_ENCRYPTED(parent) || fscrypt_has_encryption_key(parent))) { if (fname->cf_name.name) { - struct qstr cf = {.name = fname->cf_name.name, - .len = fname->cf_name.len}; if (IS_ENCRYPTED(parent)) { if (fname->hinfo.hash != EXT4_DIRENT_HASH(de) || fname->hinfo.minor_hash != @@ -1442,8 +1441,8 @@ static bool ext4_match(struct inode *parent, return false; } } - return !ext4_ci_compare(parent, &cf, de->name, - de->name_len, true); + return !ext4_ci_compare(parent, &fname->cf_name, + de->name, de->name_len, true); } return !ext4_ci_compare(parent, fname->usr_fname, de->name, de->name_len, false);