Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7251555rwn; Tue, 13 Sep 2022 17:05:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR6DpvOsY2tSbLD8pD1KxdLixFlYOmPyI1qLDBB1DfrAw/2RJCZ53TWZ9F/uBOsIytMh9R7r X-Received: by 2002:a17:907:1623:b0:773:3633:b406 with SMTP id hb35-20020a170907162300b007733633b406mr21232923ejc.444.1663113900062; Tue, 13 Sep 2022 17:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663113900; cv=none; d=google.com; s=arc-20160816; b=IylDHVEmn3cMpMEntTEN75diAeLkKNO15yVejiefGoInSGMj5Q1Kyv3Ka10b35n2Tt OC/MMKH+9UnqNyxcgrpZ5sQMH0kJLK2HuJe4reOFrsUxXUgnsHYX3cYoQ/Vp5UgoEUkj H7SbtkmCoK9efcE1E18NqUaWaboyDiAyWIha2j7lKKY8oqho4aw4qMElW/gbCKJ8h6Da Qjba5NE0ClBhavTN/3/hB5tChJaJpVrYlSj7UcY11AZDkZ0R4/o+TesGbd2pUBCghHae nWx6NkICOZ/vet63r1eUft13ccJC3Hoe8Oce3DATaZSitvOdP/vi22Ts5ifnHEbgR49k 2XXQ== 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=WN1MVYblJJtt2Jw6bEwScxP1wBJkEi33gbgDw95Hv5g=; b=KePnKj/Al2R3Kz6ga1cA7YS2RSfR9YxkhS2hhhh0QD3zA0a/CHfZYrsbh12LkxnkDw h9ecGKVU8g4McjnkFmtoAEY8y7kk9BWaV9Xdaw2l5rj0w5bhAeGPQqrOurzZxRQuEtBR 0AarqZmwJAjllQY+t6SBGUpU4cU8xJOruu3O9hXakOHbo9aOWh/AkueRVU5u7k1hHnnJ UhC/kZR9E444T5DzRxj9O/u2trYhQPZJcLIxpovO4XLFsUuPDFB8AEYb2Oh6BooHJ319 zz1fY410xE17IVENwRIfGqB/uK842sl4uhEGYNI499g00dEhHvlGmRZbb7FppXD2G6CC 8E3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Xkxp3dGo; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o9-20020a170906974900b0073d045866b3si2961120ejy.225.2022.09.13.17.04.35; Tue, 13 Sep 2022 17:05:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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; dkim=pass header.i=@collabora.com header.s=mail header.b=Xkxp3dGo; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229459AbiIMXmH (ORCPT + 99 others); Tue, 13 Sep 2022 19:42:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbiIMXmG (ORCPT ); Tue, 13 Sep 2022 19:42:06 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01A013F33A for ; Tue, 13 Sep 2022 16:42:05 -0700 (PDT) Received: from localhost (modemcable141.102-20-96.mc.videotron.ca [96.20.102.141]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: krisman) by madras.collabora.co.uk (Postfix) with ESMTPSA id 80A556602006; Wed, 14 Sep 2022 00:42:03 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1663112523; bh=jf9T5L6PRNHlcb48D47of+kLT0Zw6OxWvEXKI5LNRlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xkxp3dGo9fciEHhCGMCoZWDcyp99eh0tfAgS0N4L2t2H+wCg5sMo693fivSMDKnDk 5CGMgcfarak2vCLnLvD/DElWKQAM++HCu0yOx1Xzaa6ZsSoEB94YGxGdDx4Ujd+dak jbJ6hW+vfLG+S79UP3k4C0eqLiAESxmQ+XBjllztEbmTdJtvorvitLJskVK0z6V7I5 uda8Dx5Bm/vzNdSEQuBJgF8D9hc3dVxqV7qZKRrCd8VkhL6mM6JViEpo7oSNnqKzF8 43EXmSZFD4reZQ9md0aAtYpkEIfEVxaM/2ZbXNvj1HBnqajguETnOb3bOXoKTcT9D9 X0OASbnNGyBfw== 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 v9 1/8] ext4: Simplify the handling of cached insensitive names Date: Tue, 13 Sep 2022 19:41:43 -0400 Message-Id: <20220913234150.513075-2-krisman@collabora.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913234150.513075-1-krisman@collabora.com> References: <20220913234150.513075-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_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 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 9bca5565547b..9717b9832425 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2497,7 +2497,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 3a31b662f661..089ea8b42a1e 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1419,7 +1419,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; @@ -1429,18 +1430,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; @@ -1478,8 +1479,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 != @@ -1488,8 +1487,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); -- 2.37.3