Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp624901rdb; Mon, 29 Jan 2024 12:44:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXX29fX5iDld47Dj8YsoH7UNHdZJJXJ0y7qAzJkZs2nFDE3s6JoZH/tcNP2v2UOYxaFD2J X-Received: by 2002:aa7:d50f:0:b0:55e:ec29:75c4 with SMTP id y15-20020aa7d50f000000b0055eec2975c4mr3520058edq.21.1706561077920; Mon, 29 Jan 2024 12:44:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706561077; cv=pass; d=google.com; s=arc-20160816; b=AtkxFhhCRgSLlstYWbX/OXPakN4tWl1UCAOQNBvurN6sqyTqjQofpxeD6X17QCKMXj 1DcEBbKYpkGNHjGMZF1g4nwwTFTBzK5IYCpZIEZ9E5xyt9KogQ6VF75Tfve/h7o2SKXM RcojWaPxwIW7u2mfe994wju9JnQS7xZKOMUWMqYJX4TCRO32KcfGzsO08IjZ0EZBfdvy og764lRePNjV5Ut3/iXBw/LOkpK2yYe7mR4ugoEGFL9f0s8XslTpZ6xA/ZdPKzWYBoJ0 r//LQoaaOn0/carkdCf3kWcwGeNkuliLMqwaNU0WMtsnENbbHFLO9OsQ1vB414k3OSyu 1JBA== 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; bh=5LTCLhiM/0w+aHgqPUYmBgmxvsiEHxwft6QE+saHzb8=; fh=M648oune0DwZmCHpgeKmdqyNG9Pnhrh1APj5VeeCjyQ=; b=du6tAIVXiZR0qYVxGACn3Fkb1CxZ+5iewAB9ObdOhz8P2yH5VKkXN2BSjLiceHGZmG gJXur04ZFLGIvnXD0EBAgjEQWr5ndmDX+iQHR/bGHzjxkdkQYbuMqLJCOMl8Nh2hyTxK pBwgxeVXSWQwGH1Bg7FHVkJ7d320HTzfF4JjgpZqV+FsXqhwGoUnPB8MsKZ76XrCTYPs TXE2IXA2bx0/RHr3CFqk7Fh++cpdPEYH/QvMUBHkYPCSJ8eTFVB4RHn40ukswXQ4eWdy xvytGqUlbs5MmmKAM5se0b06prrqYF70HKKvZSlfBywbtK+4/E2xT6oukrI2nT64PJMM pdtg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-ext4+bounces-1006-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1006-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a88-20020a509ee1000000b0055d0a061200si3807543edf.21.2024.01.29.12.44.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 12:44:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1006-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-ext4+bounces-1006-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1006-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 am.mirrors.kernel.org (Postfix) with ESMTPS id ABB5C1F21BFA for ; Mon, 29 Jan 2024 20:44:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8017158D87; Mon, 29 Jan 2024 20:44:05 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2C2B22F0F; Mon, 29 Jan 2024 20:44:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706561045; cv=none; b=KOPGMmi2ogDCqWUuF8PhxJsO9CrOFE9YYyx0es6KO6v87N8OMlsJJ3JI3FfyBlgQpbVtW+6pTv/Vww9JzpwRi40GuZSvthIHseSS7yotaHoP1prIZd1ObmCumdZsVAdNIYWMC+6r6tYh56upV92DfRCS1bXKktWBGlAsvmDmBJQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706561045; c=relaxed/simple; bh=FmV9PYU+Vs8p31SgzrMt6ta1G9gbvcToq7AVmgSPrR0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G4BL9uM3OCeKwoUiTdOQ38zPrbWsBuZDap9fovin9jAwxaaNPMfiSYjrpM6o9a23hM/LXfYaTRs6MzXX1TgqzAtyapqGbI+E97hCVGtfWepmMAIvr7QmmGjb6A+3vfMVpCiSBV3opzL3uuzCHr4EL3WWesqdbXYnXL+TOO67u0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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) by smtp-out1.suse.de (Postfix) with ESMTPS id 576FF22076; Mon, 29 Jan 2024 20:44:02 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id AE9EA12FF7; Mon, 29 Jan 2024 20:44:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 5s6HGBEOuGXsDAAAD6G6ig (envelope-from ); Mon, 29 Jan 2024 20:44:01 +0000 From: Gabriel Krisman Bertazi To: ebiggers@kernel.org, viro@zeniv.linux.org.uk, jaegeuk@kernel.org, tytso@mit.edu Cc: amir73il@gmail.com, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v5 07/12] libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops Date: Mon, 29 Jan 2024 17:43:25 -0300 Message-ID: <20240129204330.32346-8-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240129204330.32346-1-krisman@suse.de> References: <20240129204330.32346-1-krisman@suse.de> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Level: Authentication-Results: smtp-out1.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 576FF22076 X-Spam-Flag: NO In preparation to get case-insensitive dentry operations from sb->s_d_op again, use the same structure for case-insensitive filesystems with and without fscrypt. This means that on a casefolded filesystem without fscrypt, we end up having to call fscrypt_d_revalidate once per dentry, which does the function call extra cost. We could avoid it by calling d_set_always_valid in generic_set_encrypted_ci_d_ops, but this entire function will go away in the following patches, and it is not worth the extra complexity. Also, since the first fscrypt_d_revalidate will call d_set_always_valid for us, we'll only have only pay the cost once, and not per-lookup. Signed-off-by: Gabriel Krisman Bertazi --- Changes since v1: - fix header guard (eric) --- fs/libfs.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index c2aa6fd4795c..c4be0961faf0 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1776,19 +1776,14 @@ static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) static const struct dentry_operations generic_ci_dentry_ops = { .d_hash = generic_ci_d_hash, .d_compare = generic_ci_d_compare, -}; -#endif - #ifdef CONFIG_FS_ENCRYPTION -static const struct dentry_operations generic_encrypted_dentry_ops = { .d_revalidate = fscrypt_d_revalidate, +#endif }; #endif -#if defined(CONFIG_FS_ENCRYPTION) && IS_ENABLED(CONFIG_UNICODE) -static const struct dentry_operations generic_encrypted_ci_dentry_ops = { - .d_hash = generic_ci_d_hash, - .d_compare = generic_ci_d_compare, +#ifdef CONFIG_FS_ENCRYPTION +static const struct dentry_operations generic_encrypted_dentry_ops = { .d_revalidate = fscrypt_d_revalidate, }; #endif @@ -1809,38 +1804,21 @@ static const struct dentry_operations generic_encrypted_ci_dentry_ops = { * Encryption works differently in that the only dentry operation it needs is * d_revalidate, which it only needs on dentries that have the no-key name flag. * The no-key flag can't be set "later", so we don't have to worry about that. - * - * Finally, to maximize compatibility with overlayfs (which isn't compatible - * with certain dentry operations) and to avoid taking an unnecessary - * performance hit, we use custom dentry_operations for each possible - * combination rather than always installing all operations. */ void generic_set_encrypted_ci_d_ops(struct dentry *dentry) { -#ifdef CONFIG_FS_ENCRYPTION - bool needs_encrypt_ops = dentry->d_flags & DCACHE_NOKEY_NAME; -#endif #if IS_ENABLED(CONFIG_UNICODE) - bool needs_ci_ops = dentry->d_sb->s_encoding; -#endif -#if defined(CONFIG_FS_ENCRYPTION) && IS_ENABLED(CONFIG_UNICODE) - if (needs_encrypt_ops && needs_ci_ops) { - d_set_d_op(dentry, &generic_encrypted_ci_dentry_ops); + if (dentry->d_sb->s_encoding) { + d_set_d_op(dentry, &generic_ci_dentry_ops); return; } #endif #ifdef CONFIG_FS_ENCRYPTION - if (needs_encrypt_ops) { + if (dentry->d_flags & DCACHE_NOKEY_NAME) { d_set_d_op(dentry, &generic_encrypted_dentry_ops); return; } #endif -#if IS_ENABLED(CONFIG_UNICODE) - if (needs_ci_ops) { - d_set_d_op(dentry, &generic_ci_dentry_ops); - return; - } -#endif } EXPORT_SYMBOL(generic_set_encrypted_ci_d_ops); -- 2.43.0