From patchwork Thu Feb 15 04:26: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: 201237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp164388dyb; Wed, 14 Feb 2024 20:27:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWgLy2mP+jliTZ46TeRSa0wP/aKDzWl5ccOP2JCe6WTmqhjRfGo7r7FjOMCl4r2H9VeF+D7sEXaTcdbUqksBTLHhUV6yA== X-Google-Smtp-Source: AGHT+IFPEgPp62aLX4qlclOHvxG73AC0B406l4UAaeofJ+PJKkcOYkpjAwY4tx1mvC0vSEjsK0C4 X-Received: by 2002:a05:6871:4593:b0:206:c520:2811 with SMTP id nl19-20020a056871459300b00206c5202811mr727160oab.2.1707971277305; Wed, 14 Feb 2024 20:27:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707971277; cv=pass; d=google.com; s=arc-20160816; b=xKcF90SzHP9MxsTJDvnJYGNsmOadUgMZAqglrFH/FSx700fL0rRE4H+0RNutZmsZpP 0uG7+/hN9MBAbNhPZiETvXYLP1OSbRcEklbozDl+TQ4NCpUm4AaV6vowNOO0JZdWBBG+ 5BE7yVUGhnIOLOiaIdE38YeFxZK0kcf/yEXQT0ICSPfSTADXBfFeMEUx2zYxbvnly+Qa tfUuhE7j2WuyW1zuNXlqIrTo5Hp4hWtxbG9b2e0v2ldt0vbQjrSAsJj3468cR6zDSyX/ JNYSp5G1zj1mcZ4RjgAJ2loCq91pymMVymqCmt3bWRGdp/R/m355+0kA7aei+LGMtPdl LR8w== 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=fC7cUxxLEav0fq5jlc00mFz7YVl/gqFzB4usX/O13Bz5ZidTUl9/ePNi2F1W0Nwqrp HBsThDr8A94UmpOFiYHi55tLopILMbQ6BspDprjoIibcJBrcbwY1WQJnH1AsYljfNjia VGRz+RtjDnsXJKxq7KjyZbDFf9g2CTcU+3BbZeaAHe0Rt/amOiVOiRaCCe06feOszBMZ VSw1XJc/uvIScga8PHyDNuZEQ7lYg9o3E2jhcfB5p8Xg5PORVgkz2GTtMLqDqHSMxE6A 43U7/c85d0HEnThSGgD6pVgBGdG+zYGWrhC7flxHK6zlkGMrUC38HRF99Gur42bsNZL1 953Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="iYY/4Z5t"; 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-66285-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66285-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w4-20020a636204000000b005d8e1dc1df6si404085pgb.731.2024.02.14.20.27.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 20:27:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66285-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="iYY/4Z5t"; 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-66285-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66285-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 14F64290CC2 for ; Thu, 15 Feb 2024 04:27:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7C65DF5B; Thu, 15 Feb 2024 04:27:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="iYY/4Z5t" 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 C94FDD29E; Thu, 15 Feb 2024 04:27:18 +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=1707971240; cv=none; b=g3uzv0zHPIKKZLRjPisGpWkg148H4xvZ8xr05wkCQKg6fBwsifb4cNFLA4/juyP4Xrjq1B3hNkWM1f1SyAlRA+Kfh2J+418vVZyIsoo/8zSjYhhDQZK6cLJXLSEKz/QV0mNJA1ILQnNaHT6G4Ea2NFt2tC9TC4hn1hRvh1uATGc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707971240; c=relaxed/simple; bh=sYUTU/89PFPnPBoR5kfzfYqhAM5p15Bl509BAaBxeuk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BYzMCBOsCijhPvDKfAmHlV8+ZisTZ2v2cmr1NM2Bc/+oNsUP1PhdVop/Qzn1+e0PY/jlTsXIoaxWenhUt7OeQ9IvRYaf83ePcnGWYDveNsleSkoLhSvnYMXlIX4yrkVxgDbd6DaUXslr5A5M1VxCAyI2kYvzPNIYU3iKNL9eOHo= 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=iYY/4Z5t; 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=1707971237; bh=sYUTU/89PFPnPBoR5kfzfYqhAM5p15Bl509BAaBxeuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iYY/4Z5t/ihjwW9e5zPUPtn+DigkARkrf5zKWntvpQSbLpkKeOBu9qcNvQcv5Se7B Gkp/bqJor106cT3FzPJM7g5xrhua8QGd5U/6Tx8NaL06SQe+6PSA2lN4Ny2tGI5v+A 0jUlUU6LKyyPKZahfMX0V0xOzOJi/e1wP0UdW62cErLkPQoLEdK2lcs+cATJVmIYpD 24g/QFcapNgitSj02khY5c08t9MbRNmwxZGondr/VC89ah0GSFP7GbO9agFwtP9eFX eUH2OwPE7QaF76VDzerEuhDZFdzJOXtyJuwsZU+ujbYvg4odhTrdxMBsiIn4baKHVo O/3Uu2MvPVB7Q== 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 2F53B378208B; Thu, 15 Feb 2024 04:27:11 +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 v10 1/8] ext4: Simplify the handling of cached insensitive names Date: Thu, 15 Feb 2024 06:26:47 +0200 Message-Id: <20240215042654.359210-2-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215042654.359210-1-eugen.hristev@collabora.com> References: <20240215042654.359210-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: 1790937689681299434 X-GMAIL-MSGID: 1790937689681299434 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);