From patchwork Wed May 29 08:26: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: 13678346 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 E2E41169361; Wed, 29 May 2024 08:26:48 +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=1716971210; cv=none; b=MzX7OKR0zr/puSiIHtL/BMz6/mM0EgRYrDgraf5WGDjjDQ8Y8dPGmU2EJEQ+JCbX5djdsMaTcnYPM8NUE5ekmMAgZnCets7JuAuCw/R50rLr25q04beeDkTYTSnuc7QFwC1Il6iV1/PG9xSZ+C+iZ4GO5c75LTc3BNL4WXoHQ7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716971210; c=relaxed/simple; bh=XtEHiBrDSf4ce/QizppJREOQW0pGgY68GGnjXcbrJYU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=prHevxM7ekVVG5VilTqXL9+4zBsPyHxuNOJGiB90ZfreucBtunt+7uDigPiMkbdNlwZm4c7gexAH/5YI1E6UYb6JLSnAft/2TXqS+jIe89BaXJPFWuRRaFIZPsIE+Rdkfkh6dby2JaDlIy3Om2m8Pzbt0ZK6i58tvKyvh529+Os= 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=ArOnAU32; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="ArOnAU32" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1716971207; bh=XtEHiBrDSf4ce/QizppJREOQW0pGgY68GGnjXcbrJYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ArOnAU32mMottzp7rniIRu16e495Au4etLtmbR9DQ+P/PORsXD07cmsx9rWkIpFO4 JEk1k/JJ1+Yve8OhBgM20n6tSJusvrC35ZZ9HCk/aPX62ayDYc0NhhSe9Kpdpm/oCn 56n0ofZGZIqn9GWjkrRs8odHMpOfaZH0KNZnMneLav7O2T0mjTGRdf+UTLtNJv8Qxl 2jof4YRcFWjO0O5YAnEByhyLetSzA3ZFIsgk5XIQnX7A9HWm0oz4nY3MXhs6i31Udl 6AB/XjBWYuYbh7N/q+F0y1Hm5XVrqEh7TjT6kFKpbyr3i5ICbZmBIvNRF8kqy1vg0n xG8Gs3Hgq6lhQ== 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 1514F378215E; Wed, 29 May 2024 08:26:46 +0000 (UTC) From: Eugen Hristev To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, jaegeuk@kernel.org, adilger.kernel@dilger.ca, tytso@mit.edu Cc: chao@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, ebiggers@google.com, krisman@suse.de, kernel@collabora.com, Gabriel Krisman Bertazi , Eugen Hristev Subject: [PATCH v17 1/7] ext4: Simplify the handling of cached casefolded names Date: Wed, 29 May 2024 11:26:28 +0300 Message-Id: <20240529082634.141286-2-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529082634.141286-1-eugen.hristev@collabora.com> References: <20240529082634.141286-1-eugen.hristev@collabora.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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.10-rc1] Signed-off-by: Eugen Hristev Reviewed-by: Eric Biggers --- 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 983dad8c07ec..deffd7431c8b 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2511,7 +2511,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 a630b27a4cc6..ec4c9bfc1057 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);