From patchwork Tue Apr 2 15:48:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 13614333 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 D942FCD1284 for ; Tue, 2 Apr 2024 15:49:06 +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 1rrgNk-0003GG-4X; Tue, 02 Apr 2024 15:49:04 +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 1rrgNh-0003G1-QQ for linux-f2fs-devel@lists.sourceforge.net; Tue, 02 Apr 2024 15:49:02 +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=R3cIGmOcQua7i5K79FiO1zV2wm4mTvFVdTHMTpLThhs=; b=iOsvAovFLD5++28306AE0bp3cr Oq5yMfbSdfzcoXlUhWKnpkpQTf6oaNLLy17XlC7LWzTVrgU+g9T0NHJDNvTv+vTHbtamuYtujXWUF bfkSrry/iIGQxZ3sLj2S7oT/fykIHW2ytcfHcT+zHCtzx0BDVqXs05ldtSCUEBPuW+IA=; 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=R3cIGmOcQua7i5K79FiO1zV2wm4mTvFVdTHMTpLThhs=; b=BHDrk6XfwSdugjJXSRcUZ4m7/a lhkMUVGJZPGMeI3LY+JDzQ6/G1eeuj6Lsa8aLzymFlEZZlPG/y3Z21fCgFFDfK5utVqPNVNW0PtNk qqrZcit1s+prEHWMmc5x+XmjTk07yWytT4MPKQSieAPILcr5BkAEFkU9JgJLPiOIqDjc=; 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 1rrgNg-00042h-Lo for linux-f2fs-devel@lists.sourceforge.net; Tue, 02 Apr 2024 15:49:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1712072929; bh=sSDn7Wfq2OSR5HgXKxsXhUQl5lGRaJDd9ojoG3UQPDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R66Uge/NPaDTQQVV6v/smY69qevL3iH2SQ7ev9hQi2A26T7/ExvCPdntT4NB8dGup 9g5SROHt481maxAr9BOxwZvOIfw07sjUY4u0+ZVOl69TMMKyoVQVfQ5H6GYjs3Mhxe KHhOQmTHM8M2zoRXlIvEhzCVQ+4eh3APV/mfQSO9C0talmbs/DxK3kV5DRddbWsQDc +ACZGzKLZGikoUOGXDDrRzLJ8kb6SqUX3mHEFsDBrHQjtQI4v1/wY5yrQ6UufK3cgg AouR6dBy+Xv+JPp0sA4uM2q9BwIkgfP5Z6vqcTYRj/FeXVYHLnwKig1JrEP0bcWuhi mF04B9/CquE4A== 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 BA79D37811D4; Tue, 2 Apr 2024 15:48:48 +0000 (UTC) To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, jaegeuk@kernel.org, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org Date: Tue, 2 Apr 2024 18:48:34 +0300 Message-Id: <20240402154842.508032-2-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402154842.508032-1-eugen.hristev@collabora.com> References: <20240402154842.508032-1-eugen.hristev@collabora.com> MIME-Version: 1.0 X-Headers-End: 1rrgNg-00042h-Lo Subject: [f2fs-dev] [PATCH v15 1/9] 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: krisman@suse.de, brauner@kernel.org, jack@suse.cz, linux-kernel@vger.kernel.org, eugen.hristev@collabora.com, viro@zeniv.linux.org.uk, 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 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 a5d784872303..4061d11b9763 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2506,7 +2506,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 5e4f65c14dfb..b96983a4c185 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);