Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2439585pxp; Mon, 21 Mar 2022 20:30:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4JsslxeTjZ7iquVTcxH236k/3jkHtjmA9jlSQhunEMMF7pN5jyzjMaGiQDijdQsDDZvvx X-Received: by 2002:a05:6a00:148b:b0:4f7:2acc:7851 with SMTP id v11-20020a056a00148b00b004f72acc7851mr27683056pfu.43.1647919854211; Mon, 21 Mar 2022 20:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647919854; cv=none; d=google.com; s=arc-20160816; b=giCoADrhWF5DzXEc5+mNE5Am0rYuYHSVXBzZ9gSn5h5paE+7mp5its+JMeab2o0c8B ooGbBuFE888Gr4Kiu+25gtVd2TWWArMbKgT8Dg6+escbyaCqC0sbpf9q23GpCdFqNo6g C0Dn3sUdYaILyN+qIF6aKOad+ed64edqlKkFtFManpn1NkYhMZFAAx9XJco83FX5X+tY i79ZdRgpADubTpdQ6zYdDzKnLUQyOzUx1zZO/7w+hnEvjiARiXQCkaRoJ7hrp8eC0uuY MT+x0xaILrGNzu/7agjhclCmudAhBTmXTd1XaWJBz9rrpKjdlS1ubpYR/p7Bhdwhsi3N WTGQ== 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 :dkim-signature; bh=yeqpkufazlv3H4QiM/NsnV2p1QAaQCKNRTbQ+9BICNA=; b=a/KdsppaK1ncs7YxE1RljjIYy8o34q0KMQXxrsdWyDCJu4GEKNqhCl2yEi0da6VAza wYjD1FBkCUKFKP+g7iwXNRfmMp0TfI2LMFI/qtCWsi5/dIbK0igDI/SnbF8EKbco7uEt svbxjjMCCY2ySGCv22lqVdQZpBNdHH+SdjD61q2zdEM0gY7BljTEIuda6iw74baBifC9 dF0IGW6jQWEEPkTSKgEXmdU58uE55vRpd0GMk8EdNGtjRdSFb5eRR2X/lXz6BvcxDhoS gW9BywUgtZ9q6LvdbuzxvqwiwVshu8PX39p5/AhqvqtJ/gnEEzswfSaFKJWpj8fyt0N7 9+7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YicSGx3a; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k8-20020a170902ce0800b00153b2d165c4si13140173plg.460.2022.03.21.20.30.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 20:30:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YicSGx3a; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 37D762D1E4; Mon, 21 Mar 2022 20:00:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235718AbiCVDBt (ORCPT + 99 others); Mon, 21 Mar 2022 23:01:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235734AbiCVDBs (ORCPT ); Mon, 21 Mar 2022 23:01:48 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 304172016A3 for ; Mon, 21 Mar 2022 20:00:22 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id CAAD91F41054 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1647918021; bh=uuxMaXOl1WidwsQtHu97JSPFDBNZ+gJKbzzoXAH1l74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YicSGx3aq5KT9RaGCU57tX1lG1qisOCcdOn+aHLdWw0ARxlLTt7aOknlvEq7RGRs5 IQaqhb9FVBA/Tf4yzE6iAvu0lc9HJRJrG7p72yGYmlf0lE8mUYs7iSUJk+hjsjVHGa XuNzMyWjIYc0AmfIm8HD+lOhfV2fLWHABmgeXc+Sf49/laF4zHvSiNcMBPa5y377TO MIK234Ycro3TRMctnsrjZuHKBbrzYI8YJiQaxoZVXWgdpVZ40EHk+j0dh5tyutK8O/ k0DVyk1c/qQ5UZj9dhrU+RB09JTQuxuAGqVNvf3h2eeOx6LsDL+nj/mBwpJjuP91/U gkDRYU/qK9t9Q== From: Gabriel Krisman Bertazi To: tytso@mit.edu Cc: ebiggers@kernel.org, jaegeuk@kernel.org, linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH 2/5] ext4: Simplify the handling of chached insensitive names Date: Mon, 21 Mar 2022 23:00:01 -0400 Message-Id: <20220322030004.148560-3-krisman@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220322030004.148560-1-krisman@collabora.com> References: <20220322030004.148560-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no 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 Signed-off-by: Gabriel Krisman Bertazi --- 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 bcd3b9bf8069..46e729ce7b35 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2484,7 +2484,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 24ea3bb446d0..8976e5a28c73 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1382,28 +1382,29 @@ 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; if (!IS_CASEFOLDED(dir) || !dir->i_sb->s_encoding || (IS_ENCRYPTED(dir) && !fscrypt_has_encryption_key(dir))) { - cf_name->name = NULL; + name->cf_name.name = NULL; 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; @@ -1442,8 +1443,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 != @@ -1452,7 +1451,7 @@ static bool ext4_match(struct inode *parent, return false; } } - ret = ext4_ci_compare(parent, &cf, de->name, + ret = ext4_ci_compare(parent, &fname->cf_name, de->name, de->name_len, true); } else { ret = ext4_ci_compare(parent, fname->usr_fname, -- 2.35.1