Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5656119rdb; Wed, 13 Dec 2023 15:42:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IGH0Dnt0tSSbadgSuc1omgExi65HZqsF6l9Awf0Jlv8kpC1EPQ9fv2APs6xw8nFhxevDfpl X-Received: by 2002:a17:906:c141:b0:a18:abad:195a with SMTP id dp1-20020a170906c14100b00a18abad195amr3602042ejc.47.1702510929530; Wed, 13 Dec 2023 15:42:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702510929; cv=none; d=google.com; s=arc-20160816; b=b2b7fEzwyjIDU5RMuvk7R2CvabtSX0bYa5rqad6ehHqZxRwIAxtypeFoAf4HTvaRST NW1SpjQ/coAEbEReJYs/yeo8TZRT/lN+NR5GRIu6vTvbFiHzn8pjpg1UdppgL7uE5Z1E 9NNE+dSp9e1EVBuoyHXOzwrx79WnOvsHyPfARFChWXsBoqzOEfjMuTtXfS4f8M+xfihO l1MNvrHTUWhLKs8JaCVeHZ8XHDP7Rl5Ad4+MdQzTF9TAmpMgVcymJNIRZzHXGldUz/43 SFeFZocXMtLD/4CXeQJCtJtnn7dIdDEp/iH/lcmku+6pU17JSt6CeMs1DOL+Thl/QqEY v4Vw== ARC-Message-Signature: i=1; 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:dkim-signature :dkim-signature:dkim-signature; bh=sp7vIsMdgWL9TiTqEXZpY2g0TTohq+YTCZxjglEPwgw=; fh=UEin7YZ4eM5mX713C41+LGZX7Kx6awDGobYQnpIpl5Y=; b=nG/DPEuLiT+p5q386+pZSYk9FqyNg4rGjo6+LFpi7EvhIfQhP+ON7uzVob7ArKdQ1O dBJp0YQm/OYFlCfF486G3LWx+SkxequYjrFBi1DV2aXfr8gdoyUv+D83+hgqRCgtY2xF qSAYxy/PcKDBIBkIgfA9+NB8tFhgymJJTsk/2/xiDsoHGO/2Mg+i9NTs4Xyr3YmqZ5Bi A/IKls+FYY67vUbtZDcB0++5GBMi8Cwfoccuz5USc2AgrNLgyOc2ARtiWOBub0+3r2UP gV5lFEU5ksGhi6fIfISD9xphreBnFlVtQw0tn03d+MvArFnt+3KxX995q23Xs7U5tD9L eR2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HuZn8w5O; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=exaASb07; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HuZn8w5O; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-ext4+bounces-439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t14-20020a1709066bce00b00a1d1de4e930si5864737ejs.55.2023.12.13.15.42.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 15:42:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HuZn8w5O; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=exaASb07; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HuZn8w5O; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-ext4+bounces-439-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-439-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (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 1C4A81F219F9 for ; Wed, 13 Dec 2023 23:42:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D445B83AF1; Wed, 13 Dec 2023 23:41:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="HuZn8w5O"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="exaASb07"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="HuZn8w5O"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="exaASb07" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28FDF30FE; Wed, 13 Dec 2023 15:41:00 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 6615D22311; Wed, 13 Dec 2023 23:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702510844; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sp7vIsMdgWL9TiTqEXZpY2g0TTohq+YTCZxjglEPwgw=; b=HuZn8w5OOUZo4mUeGyGKLHtyXrPLxXSjWKJxLu+c6ka69Qg2LA8Dgyngez0fjLbzXvGzJ0 nZ8BpdceSmf/cOhdOymHO2IF73WocYTgFHsgKPREuVRleaovHKQ6LxVyG06k3/MJ2tMxg+ LDOjukPdpHbXzPl5z+Xs42yqcz+eIo4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702510844; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sp7vIsMdgWL9TiTqEXZpY2g0TTohq+YTCZxjglEPwgw=; b=exaASb07Q048vHK7bOAGm7Qzy3s8zM6Z2ELt0jL2mNpuwjK6MOWxJr2lmhPoBPJiW/oE7s bwgaoOCgFHjNShCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702510844; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sp7vIsMdgWL9TiTqEXZpY2g0TTohq+YTCZxjglEPwgw=; b=HuZn8w5OOUZo4mUeGyGKLHtyXrPLxXSjWKJxLu+c6ka69Qg2LA8Dgyngez0fjLbzXvGzJ0 nZ8BpdceSmf/cOhdOymHO2IF73WocYTgFHsgKPREuVRleaovHKQ6LxVyG06k3/MJ2tMxg+ LDOjukPdpHbXzPl5z+Xs42yqcz+eIo4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702510844; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sp7vIsMdgWL9TiTqEXZpY2g0TTohq+YTCZxjglEPwgw=; b=exaASb07Q048vHK7bOAGm7Qzy3s8zM6Z2ELt0jL2mNpuwjK6MOWxJr2lmhPoBPJiW/oE7s bwgaoOCgFHjNShCA== 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 2D8481377F; Wed, 13 Dec 2023 23:40:44 +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 aKANBfxAemVnPgAAD6G6ig (envelope-from ); Wed, 13 Dec 2023 23:40:44 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH 3/8] libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops Date: Wed, 13 Dec 2023 18:40:26 -0500 Message-ID: <20231213234031.1081-4-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213234031.1081-1-krisman@suse.de> References: <20231213234031.1081-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: X-Spam-Score: -0.30 X-Spam-Flag: NO Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -0.30 X-Spamd-Result: default: False [-0.30 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[20.86%] 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 --- fs/libfs.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index e9440d55073c..52c944173e57 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1768,6 +1768,9 @@ 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, +#if defined(CONFIG_FS_ENCRYPTION) + .d_revalidate = fscrypt_d_revalidate, +#endif }; #endif @@ -1777,14 +1780,6 @@ static const struct dentry_operations generic_encrypted_dentry_ops = { }; #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, - .d_revalidate = fscrypt_d_revalidate, -}; -#endif - /** * generic_set_encrypted_ci_d_ops - helper for setting d_ops for given dentry * @dentry: dentry to set ops on @@ -1801,38 +1796,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