From patchwork Wed Feb 7 06:43:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 13548181 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94063C4828F for ; Wed, 7 Feb 2024 07:03:25 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rXbxr-0007M3-7Z; Wed, 07 Feb 2024 07:03:24 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rXbxq-0007Lx-0z for linux-f2fs-devel@lists.sourceforge.net; Wed, 07 Feb 2024 07:03:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=bLj6BkOOj6QP6flSGLrMwh8Bhh9dmUPrqQK2TTtbiVo=; b=iktKZYO2v8fcaRQIwYbptRP8Iw Wdt7+WTxbNgvbHQT2ac1XouU7I3wLU9Uy6ww0q5pgNpUPjh9jI92VkDsFjqlBKnEVo4sdaAKH2NMy BPBK5BiNa9EhsjM7qOILsMdeDHQ3mCynm8/e/Cx+ERcVnfKPi/XpbVXQFMhkkzQA0gC4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=bLj6BkOOj6QP6flSGLrMwh8Bhh9dmUPrqQK2TTtbiVo=; b=AcjfLnUqkbB/CHvPNgHa4PB+yC qragnRt/gjBFrkw2gSz2d4xg9CGxxcwSId0oz6QI5a4Jb+wTCJY+15AvKVal9uhV5YwARVlq5BTOG ZZoWGsR5EkrpmjKXBcgkX2ZZkTLWzPm5/s1dCWZ2PDKQ2bFjB5wlkwkTHL6370S0DU4c=; Received: from madrid.collaboradmins.com ([46.235.227.194]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rXbxm-0002tG-C2 for linux-f2fs-devel@lists.sourceforge.net; Wed, 07 Feb 2024 07:03:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1707288219; bh=sYUTU/89PFPnPBoR5kfzfYqhAM5p15Bl509BAaBxeuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0ZmrO1VOAw4pQq6H3dURVbvt4b44qK+PfK7EAijDa333nF+w4d74QKrKuW9ghoOu/ hybkEXhLvEHWYjDYA+eQoUbIfdTzZ30hVANGUPWMqMKsPnLCiPn02LqZUcN6NPPs0G C4GyOxU93O2t6Owgy7BZ9RDjUXl+kUkln0nNylk4huut4D5JdUzE5e65RewB8SgU4a l2MHw2UgavU9C+SQPZL3VGlHL9fTLRXHze2Vzg/qMXjH1jf6SpWbW7BJDWhVKabt3K nuUoPeE6uezQcmlsIRsWhqbEajMqe5KyzapK1OXEwoUeURxnsYwMuSL1m8LeGEakKr ytD2PlqBybZ9A== Received: from eugen-station.. (cola.collaboradmins.com [195.201.22.229]) (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: ehristev) by madrid.collaboradmins.com (Postfix) with ESMTPSA id BC20E3781F7D; Wed, 7 Feb 2024 06:43:36 +0000 (UTC) To: tytso@mit.edu, jaegeuk@kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Wed, 7 Feb 2024 08:43:01 +0200 Message-Id: <20240207064302.221060-2-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240207064302.221060-1-eugen.hristev@collabora.com> References: <20240207064302.221060-1-eugen.hristev@collabora.com> MIME-Version: 1.0 X-Headers-End: 1rXbxm-0002tG-C2 Subject: [f2fs-dev] [RESEND PATCH v9 1/2] ext4: Simplify the handling of cached insensitive names X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Eugen Hristev via Linux-f2fs-devel From: Eugen Hristev Reply-To: Eugen Hristev Cc: Eric Biggers , linux-kernel@vger.kernel.org, eugen.hristev@collabora.com, adilger.kernel@dilger.ca, kernel@collabora.com, Gabriel Krisman Bertazi Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Gabriel Krisman Bertazi Keeping it as qstr avoids the unnecessary conversion in ext4_match Reviewed-by: Eric Biggers Signed-off-by: Gabriel Krisman Bertazi [eugen.hristev@collabora.com: port to 6.8-rc3] Signed-off-by: Eugen Hristev --- 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 023571f8dd1b..932bae88b4a7 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2508,7 +2508,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 05b647e6bc19..e554c5a62ba9 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1445,7 +1445,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; @@ -1455,18 +1456,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; @@ -1503,8 +1504,6 @@ static bool ext4_match(struct inode *parent, if (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 != @@ -1513,8 +1512,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);