From patchwork Thu Jun 6 07:33:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 13687930 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 6F5197172F; Thu, 6 Jun 2024 07:34:37 +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=1717659279; cv=none; b=Sv2z30K29NH8IXbPa+VqJk9PqIkK2+RMA1/+l3q54+pUn3JqvHef+mQeLrhPNwZqWIBi5Nv1k+XkQSNgI18j4v2cB6J0N+KdmnAW57kVPt/ErfmueXaBoYAip+rJPMC9fmA2wMI5HGJQu7J79X5FnQwsFSKpzQehBxbvjBsYrew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717659279; c=relaxed/simple; bh=XtEHiBrDSf4ce/QizppJREOQW0pGgY68GGnjXcbrJYU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gmr59ANAE3kaexF/+vnz0Px1k3enGXHAxmJn2ddOwrYxLtkRCn4YUHFO7/86TTeMqs/LC3TurBJGaTRz/zP78T4BJapKZIreoaTKt+TwC1cq2QJ4zirizojxREek6MpX47mLujOpwMxa7ByA10Vu3+TiQ8lMt1IU5E3JFjiYjp4= 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=fBkkX++I; 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="fBkkX++I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1717659275; bh=XtEHiBrDSf4ce/QizppJREOQW0pGgY68GGnjXcbrJYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fBkkX++I18I7bSLdl+E9++h7LlHjEqSgLyuRKmIfLuNaFNmSlzC8xVzqvU1jYGjua r0lHU/jHcSe4iEhElLN9+yzuiCRXurnRfXep8HZBg4yFNEHnje+B+Ou6K/vBhzersS hFrZ4EVSc919hcSKgerPHHzH+/DUiUALnY6luH8ROYB819LZJFtw5tYSFy92YQ66Fs JXyRvGSzOY28SXnt76mj67+0TP5rUl3BtkcYdYo3ZWeqvlm/STpq9mMPE/etDhMWia qIMXPHBJ6SwdxflvhlRp4pzoyux0TQy63JlM4Ak5RbNC9Y3MMq+Td8M6k7LS6m6EDn xDpItX3aYx3lg== 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 AA42337821D4; Thu, 6 Jun 2024 07:34:34 +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 v18 1/7] ext4: Simplify the handling of cached casefolded names Date: Thu, 6 Jun 2024 10:33:47 +0300 Message-Id: <20240606073353.47130-2-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240606073353.47130-1-eugen.hristev@collabora.com> References: <20240606073353.47130-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);