Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp302488lqs; Tue, 5 Mar 2024 02:27:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWfhg28MMDIWDPUs4yn8WDiwZLaEvw/aWUOsV63VqpkEhrvYhXaB2oHNYPY6O2bhpxWHlxPsppxW16lDuLF/kTCNAwDrGhSKI1SOp/KnA== X-Google-Smtp-Source: AGHT+IF5XoHfDwNTCYZoyxmwue9krUH2imGJ6IOVDKmPPcbrZok86weVE+ppA8OnWnEdzgJNNHv5 X-Received: by 2002:a17:902:ce92:b0:1dc:9e62:75c2 with SMTP id f18-20020a170902ce9200b001dc9e6275c2mr1641278plg.57.1709634444477; Tue, 05 Mar 2024 02:27:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709634444; cv=pass; d=google.com; s=arc-20160816; b=R2S7A8hEYFRK0+iryAtd0a/YEF4n6Yxb63NEQds3FVJvgLb72VaYUT7Ib0xm3cGegi ltAVKRxhGBdb8KLg8W0XO5VsnSqmlgvrhgujBxKnFygjWNH+l3tD8bqhbU/O2wwosO+V N0B0VBWz+FyenckBDx4NGShBrNN7J4254Bt88dTnbrkjZYfm9xQLec8wde7dUXccml+m eijEplTqScf+FC3aMargQNU/PsWJoGvGIXMofy0MdrDqeITssznFOtnPBS3zqtA72F4T ozga63mIQ4c4c+Y8hfE9ieaykSk7Y61w7z0tfTXruW6m0tZJSNW9/BVeXOVx5LUz8kor 7DCg== 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=R3cIGmOcQua7i5K79FiO1zV2wm4mTvFVdTHMTpLThhs=; fh=zf0NNkRrVzzNLxoWnmq9qpFBuYVKEQmjRPQIjT6JsCY=; b=zXMBSsufFl6ifvJc/S2/RUbGROBx4MbvZ3CG67I3fnEXp9WO7A7axGc5tdD6GExwT7 gB8XsC5SsPPU0OIpj/Dihc0wus7qByRkwn/GhQk1Z3hEkRb0rjAIKMq2e5EqxNkDb/oS Hr4sb79JWCHRc7F/yO7pYIOjnl0naOHytYbQOpjak6I6Rjs7+j2muOD0ocnsHotBsVpK WuglGRvoFINOkE24IAPSm0cGotlMHXk+jGF8mgoKzVUvB8dVtFw1xJDLRJgo097nt+NW WHGIIpvU2Bf0ON7D2x1HYewQLHQKV0ZnsMDtlbAMzexAFguF9Lpcj5Aw6HI+uiB5Rd2C cXxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=tKzO9aAm; 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-ext4+bounces-1509-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1509-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z12-20020a170902d54c00b001db98ad6ec2si10013452plf.609.2024.03.05.02.27.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 02:27:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1509-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=tKzO9aAm; 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-ext4+bounces-1509-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1509-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BE762282700 for ; Tue, 5 Mar 2024 10:27:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0874A62A08; Tue, 5 Mar 2024 10:16:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="tKzO9aAm" X-Original-To: linux-ext4@vger.kernel.org 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 0811F62800; Tue, 5 Mar 2024 10:16:28 +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=1709633790; cv=none; b=TF5zs+EXphZ5H/MkJnDR8zwxmETUE6fYsnmKMmXLeN2xSCz76jeMVFYRmNmFAwrMXbo4jkbsSQietqlvzPM1eX0RZIXAWnNvg67r6pPpm2vBRVBj+1dS4fLoTnuO+aHKdzJ7sOdiBV8PZz54guujSex3WXAZt0ZUW2T1Qb/iz1Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709633790; c=relaxed/simple; bh=sSDn7Wfq2OSR5HgXKxsXhUQl5lGRaJDd9ojoG3UQPDU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CR2ZSMX8J2nUB/8d59Y+/nEOb4PYV2Gp5+7oJye/Q6lF9dKCnb2vy4lWQHAl18BJzx/tz0TA1qL614ask8PdZVoan7Kb0OkntyUB2P7LnrPA8/HJ2tMU2gBtKpxrS/kaUY/u+Qmk5hQarbZZl5O1x5HlmlUGIZ9FhP/xayJAzDc= 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=tKzO9aAm; 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=1709633787; bh=sSDn7Wfq2OSR5HgXKxsXhUQl5lGRaJDd9ojoG3UQPDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tKzO9aAmXe2W8tesxXyykVy9Qy2TKHRAkUKJrKobX/qj2SsZdFprznId3QVi7DcfS 8FDM3h2rDuSJxGzwMiLxIwN6TA28a1gxLbOJSqZTTbdxAqNtJY69JBQJ/L2qe12BVS TqJde6Knx7QDURNcI9i0Cw6MI7JGpRZTo+f43xV4wqMyTNfduwqVNz2tgR8cjba+NN x1U4+hNuIaZlJaEPiNURhvFB0sQlVIEM4WyBVRyxVC8um6OcNoeWwh+IwnB14aSR8t V6gLfZXSABn8iyhB2WSd1MknZS5X8HliXYgCd047At6HuN7AZOy+4NqPTO/2fdmGQt nHoNGrFYp/vnw== Received: from eugen-station.domain.com (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 01DF33780F7F; Tue, 5 Mar 2024 10:16:23 +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 Subject: [PATCH v13 1/9] ext4: Simplify the handling of cached insensitive names Date: Tue, 5 Mar 2024 12:16:00 +0200 Message-Id: <20240305101608.67943-2-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305101608.67943-1-eugen.hristev@collabora.com> References: <20240305101608.67943-1-eugen.hristev@collabora.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.34.1