From patchwork Tue Feb 20 08:52:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 203485 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp270962dyc; Tue, 20 Feb 2024 00:56:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUtsSoBal4K4mg8qYxrOEtFbBGVfaOgfEU4W0y1hIis5y8/HqzacbBzKwpochHm6XkNUgltVDeIkkc3AktJr5pZPU6VgQ== X-Google-Smtp-Source: AGHT+IFR5osFnghg5tH1s1J6+AArQKaKI0N5tv31B7Ga0XuIoSJ0OFnjI8wVrWySSSDtJq9bXObb X-Received: by 2002:ac8:5cd2:0:b0:42d:d5c7:a992 with SMTP id s18-20020ac85cd2000000b0042dd5c7a992mr16409972qta.21.1708419361443; Tue, 20 Feb 2024 00:56:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708419361; cv=pass; d=google.com; s=arc-20160816; b=t/LcPHrxaGr3ire0EFXcFeC6ZSV8srClMZDi1ICPNu8vheI5nZ1AeJsA2p8Cno87Tg XTfYfg+gPgP5YyDMriQ/hGHLVsB75L2S7sEmQS/y01TNI9E3A2rRWC0rNacZpm5LaKs/ LlqoqaFbUnolmhow9MBwqgvmvQPbTFE/0DTCnsNHvOaUzcefoV4zfWxM2Bza0xMX5SKM AIiVz95Lhef3HhC5641mnBzOmmnnf1pEVB9MYtuaZo81s3FoahgQ3w8eQFOHzquV5D3V TjfDIOEqcyOyZltY/YXD+jU6l8L4Z8QYVZp4riE+/EUvHUE40G1NSFLVwZi7aLexPZXQ /2Nw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bLj6BkOOj6QP6flSGLrMwh8Bhh9dmUPrqQK2TTtbiVo=; fh=YX4HbHS7wMJfdu6Xp+2MgHIyDiEardnLcvtWgzaTy/w=; b=AEFY03UPKCSj3EHxTWsrNnC5P9Q/woCUZZonMzJ1bhJnmiwtFGdADJo3HR+KhQAr9y nTRaCZTzCPCLsSunHJtG9EXroNC3yRM+fGiqNgoGdDhbLRpGy+FM6rM00SsxbmqAcjHO YgoX+5FsUxMoxTdkLz0rFaPUR3/Ew/7rXVFm+7MltItsHXsu39gwmg0OEucO/+9LIW8r oQzWE2duvVFI4gPRcRjcIkUmaihv77n75sLgJaE67BWTkOjcA13FBTMdn4qHK8xsTiFc MU+ryw1KEMykPkWFcfFmbkL0FrUSHEGMSScuFvkhk6pmQ6pZt39htyJEQoGfrW7iyDg4 Wo2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HmHkQv2g; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-72612-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72612-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l12-20020ac848cc000000b0042c56f2bc74si7862817qtr.94.2024.02.20.00.56.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 00:56:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72612-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=HmHkQv2g; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-72612-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72612-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3757F1C2118D for ; Tue, 20 Feb 2024 08:56:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 606B063512; Tue, 20 Feb 2024 08:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="HmHkQv2g" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52FA05FEF2; Tue, 20 Feb 2024 08:52:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708419174; cv=none; b=FI4oCTR+tNqiHhNkNYh2XAqzLZb6MZLaGIZQsboH8YrNq4yYCmDa8LFtc+cwm/d0x+c+3/tN6DCb6sBA/fxViXWpOKX0DmO67CgU5ESh0Rn7bgeXjP+SUKAceiK1z/O8kRlUhukF7MH5iBM62ZR082lqCxwVepnAxb+fhBqSpcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708419174; c=relaxed/simple; bh=sYUTU/89PFPnPBoR5kfzfYqhAM5p15Bl509BAaBxeuk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XVccB9hZDOpOjtNwU1YBRsb/uhgG+Ih/GJB8PdI8LALT/45Inyjdy8sIZGpAbLeIFrRPoY5+9cnAeykuVzR1Ew2+Hkue1/vQG61CALmfxJpWJKISVJdvVJGIaIaHJZKpeM+LcuI3KQe5zMwmKVfx//93xzOApz/s5vbcZKXkyro= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=HmHkQv2g; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1708419171; bh=sYUTU/89PFPnPBoR5kfzfYqhAM5p15Bl509BAaBxeuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HmHkQv2gvTC+PaeihquAQjwDTxxp5HHL0cRccXUySqz6MGmUVlKD7eOE+UF6ItG8P w5YFmrd4YmuOplsQQl4fChrAY3UtXEOzM4UephzZJYyhU4Ura1m8lTcVyEVWI4+/bS ftz1H3ZsBUm4ZWgh6Km+j2FC9DRrCyRuLtso8A5eg0wmZFioQEdF2F9F7YSx7/a3yy Nh8f9eHI5RUK1TRuuj6ArszNWh7XwLzV20lXEHIjkuy/bHe3d7vT2X9wfmUv88+T7e DHiucMpsoUSfrsevokZqH2vNaH22UlAjcHTpXkY8PPo0Zim6UGJoyyb/Ts4mHsErOh dfJXpj2SwKtYA== 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 D88183782081; Tue, 20 Feb 2024 08:52:47 +0000 (UTC) From: Eugen Hristev 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 Cc: linux-kernel@vger.kernel.org, kernel@collabora.com, eugen.hristev@collabora.com, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, krisman@suse.de, Gabriel Krisman Bertazi , Eric Biggers Subject: [PATCH v12 1/8] ext4: Simplify the handling of cached insensitive names Date: Tue, 20 Feb 2024 10:52:28 +0200 Message-Id: <20240220085235.71132-2-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220085235.71132-1-eugen.hristev@collabora.com> References: <20240220085235.71132-1-eugen.hristev@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791407540288982083 X-GMAIL-MSGID: 1791407540288982083 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);