Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5152427iog; Wed, 22 Jun 2022 13:10:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1un5VK41IHtbpAd8CzFPHnNGJmw80vJXCzKqrEqdudf+Sd/yksJGJOJUG/cqmD/RjbSLpK9 X-Received: by 2002:a17:903:32cd:b0:16a:3648:1058 with SMTP id i13-20020a17090332cd00b0016a36481058mr11153446plr.30.1655928647069; Wed, 22 Jun 2022 13:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655928647; cv=none; d=google.com; s=arc-20160816; b=KtrOlHZ+LNVi8LAOjbs4bTvB+EF/6VeBUWXeb7/MgvIhV9+Xz4bym4H1VVBk2CMiSs mtnATXYCHELtM68pwW4X48DpfApQGY9gvS2/JnCZuFJa12LIsXwvkrHMGlvkFNzcDwgM y97PgmO5zb8sWNeZSsE3zSwFEBAKCiL90M4nwpXF4Ig9CfLtsyhNy6UoW6MoGFz8RjEz R4ZhOor/7A0fyOWS4fjwGf1AQ10SmHQJ6lbcgDSnFDvAhV1LU3l4a72m56lKL1erSMsS CWDGrduoyyXLKlDYmS4ozg8lRybZaqCreVHFJnG/Xp0kWO8Qe0AAgT3Yw3kGAZYvfBIw Luhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PSSO6NPlA7Bmi6bNs6yCDxXdz6BmLC/bmAnH/ovbplw=; b=u41uRGZcLaqjpS1rn8LOeOcHJHcgbC5ei1nqS2f4F7z1KRPQ9CPVZVvonTb/+8Qats uNfq2of3rREdnkBRJ3ka6Skhs16ShKvPOgugvJO7/4eTVqe5b743C5pnTIU8yHCkLDca TyOz9G+L3e0cMVxSflY2vekOQHZM6UqTCoRYQLD/cOgclM2NpJCRk07DpNHtZgeT+7sO PmWPD/W0w6DXcNEXE2kxubkvITTDewcj1d0HGfZMni4kmN/Ni3lAA9qusvok46K2t7ey 0AKeAuvcmUym6YVQZsun2PKzQm8C8Kma1OYUMWd7h+dmZ6Mf/OuRqxsA1Ds2zvFMqAbi D2AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=a4aw7jPy; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id na10-20020a17090b4c0a00b001e30806df19si614643pjb.45.2022.06.22.13.10.32; Wed, 22 Jun 2022 13:10:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=a4aw7jPy; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376550AbiFVTrG (ORCPT + 99 others); Wed, 22 Jun 2022 15:47:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376555AbiFVTqe (ORCPT ); Wed, 22 Jun 2022 15:46:34 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A91FA3FDA2; Wed, 22 Jun 2022 12:46:30 -0700 (PDT) Received: from localhost (mtl.collabora.ca [66.171.169.34]) (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: krisman) by madras.collabora.co.uk (Postfix) with ESMTPSA id 58F7B66017B4; Wed, 22 Jun 2022 20:46:29 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1655927189; bh=TUdXpJW4FsMDewNQFYWaGTPQajsKUPpgYfj9KuK8jWE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a4aw7jPyDZZ8yX8Ze1T1JDFpSUccEm7RK1eFysKP3vJNPm7HCGVEbwGTkBfY4R05h j5TjuRR53dMPFLQG30jFXtE1e/hAp5OO/kMtiA0i9IrbEEY3TTkECEZDro/tnDpEPq cAid5ZYw2VW0EUj4i2YMaIrUwwIgniyDPoXtkmWoindo7HOPU8Nw3eihDLERMe7f9o 84jCTqToVy5ab1xuH1ZpHcV650PlnHEEnC3wQt9FMiFk1aEYBrE/M14CSZ93UYMjsB Il+zxIf4ff/RBiyYChoOLY9OeVh8dmiwn3slrJxr2rsyD1tesXCw59t4tTK7ohfDDn Hjdd74C1FdKEg== From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, tytso@mit.edu, jaegeuk@kernel.org Cc: ebiggers@kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH 5/7] libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops Date: Wed, 22 Jun 2022 15:46:01 -0400 Message-Id: <20220622194603.102655-6-krisman@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220622194603.102655-1-krisman@collabora.com> References: <20220622194603.102655-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Now that casefold needs d_revalidate and calls fscrypt_d_revalidate itself, generic_encrypt_ci_dentry_ops and generic_ci_dentry_ops are now equivalent. Merge them together and simplify the setup code. Signed-off-by: Gabriel Krisman Bertazi --- fs/libfs.c | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index e4da68ebd618..05f82e1a6f70 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1477,7 +1477,7 @@ static inline int generic_ci_d_revalidate(struct dentry *dentry, return fscrypt_d_revalidate(dentry, flags); } -static const struct dentry_operations generic_ci_dentry_ops = { +static const struct dentry_operations generic_encrypted_ci_dentry_ops = { .d_hash = generic_ci_d_hash, .d_compare = generic_ci_d_compare, .d_revalidate_name = generic_ci_d_revalidate, @@ -1490,26 +1490,20 @@ 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_name = generic_ci_d_revalidate, -}; -#endif - /** * generic_set_encrypted_ci_d_ops - helper for setting d_ops for given dentry * @dentry: dentry to set ops on * - * Casefolded directories need d_hash and d_compare set, so that the dentries - * contained in them are handled case-insensitively. Note that these operations - * are needed on the parent directory rather than on the dentries in it, and - * while the casefolding flag can be toggled on and off on an empty directory, - * dentry_operations can't be changed later. As a result, if the filesystem has - * casefolding support enabled at all, we have to give all dentries the - * casefolding operations even if their inode doesn't have the casefolding flag - * currently (and thus the casefolding ops would be no-ops for now). + * Casefolded directories need d_hash, d_compare and d_revalidate set, so + * that the dentries contained in them are handled case-insensitively, + * but implement support for fs_encryption. Note that these operations + * are needed on the parent directory rather than on the dentries in it, + * and while the casefolding flag can be toggled on and off on an empty + * directory, dentry_operations can't be changed later. As a result, if + * the filesystem has casefolding support enabled at all, we have to + * give all dentries the casefolding operations even if their inode + * doesn't have the casefolding flag currently (and thus the casefolding + * ops would be no-ops for now). * * 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. @@ -1522,29 +1516,17 @@ static const struct dentry_operations generic_encrypted_ci_dentry_ops = { */ 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) { + if (dentry->d_sb->s_encoding) { d_set_d_op(dentry, &generic_encrypted_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.36.1