Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5873961ioo; Wed, 1 Jun 2022 14:39:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLSU6xNM/78AGwpJkdeg0GCLXVB1lIhg9TdgWIscc35C0146JEYHoxQbVUuPuRyrrCVAPY X-Received: by 2002:a17:902:f650:b0:15f:3a10:a020 with SMTP id m16-20020a170902f65000b0015f3a10a020mr1411885plg.61.1654119552876; Wed, 01 Jun 2022 14:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654119552; cv=none; d=google.com; s=arc-20160816; b=euQsvlg3wOsX40m4Hp4+5tOwBnFAVtZVDwNl7uqEgJ1LWJ19pLaPcs4pXyUE7Ww4Gk qra27DDZVQDL9Gy1q81hMFhkCgwWZ7V7aUDL5eZjf111uo4Hi3TwuBemPQAXlWIV9DRo x+XUyaMP7fQ3iXZoWD0xNOfeGLdYv2jHvssIpwJLIB/tkJOH2XQKtOy01eEUiu7rVxxF ZVaJBiyXs9adueOj6qG6a9/WGbA9Mdk+GiaEse8rXii/WRlIC6PlfWKh/jSx4Ducb8qa kFsRhn0uizQ1szIjsfthP7z7ENNU+k/iK0SrWwr+LTte730B8rlxTcKM7IJVABrktYl9 3KyA== 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=pvTT0L82tOAgxlgXOl8NZHN+dLF4cMiIpAHW4KJaZFM=; b=z5PI1eQ6dQ2QbpzW3b80dnKvBXq7GLw12/MJS0PXehSQNtif9IqucRWcoOSbXf8zXb oHr0qleCeIJylSWWwvedCYmEh+hFFs9gVqhvn1NJkVZKEMNAAPQ0ta4Reu0pzfT5hs6U qnyuBLmQjyJTrBLuHq/QB46zoDwuMW5pevDqGHskiH342tCZ4oCE3T5Gs8qqdQYK1cCv po+Kuuzv2+2UD61MZUsR6qeMc/AZiFMR/aW0qyysSrgl8ZPBguZuO8bNHPMxBigHqomV lA6Pk5gfQh1jhkRrRD8G9VA70+T59Q2iZv/6bmhbXjTHi0Ew/gCWVRuZ4KH6tdwebh37 WASA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="h49m/n59"; spf=softfail (google.com: domain of transitioning linux-ext4-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i10-20020a636d0a000000b003fc48964390si3516452pgc.613.2022.06.01.14.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 14:39:12 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-ext4-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="h49m/n59"; spf=softfail (google.com: domain of transitioning linux-ext4-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA582296319; Wed, 1 Jun 2022 13:48:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230190AbiFAUsm (ORCPT + 99 others); Wed, 1 Jun 2022 16:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230118AbiFAUsE (ORCPT ); Wed, 1 Jun 2022 16:48:04 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B38FB27D0FC; Wed, 1 Jun 2022 13:45:02 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 452BA1F4394C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1654116299; bh=QTM2y9smEdZYIXwJ+bdg4VmJ/jF3wm5qE0XMmetiWjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h49m/n59xKW6nHMlGcysHhGPofAz4PIP4jPDzNTN5t/SXgwxQzoXD+JA4xeKsdIcF rj91KVJ2PHVbc7qaUMJlIkNSzvUondrn5ruu7RjUJmi0U+gUGXTnGqMCSUOPdXusQw 4YISWMPtAnr2tBjDtxZ4wzwW6lwxqntdoLwGikCm6F7jCPJfSy8Iq86u7RsH3hIBy1 QfVXz9rdefOGp/+pVNlVXkgLYqY6w9mbp54ylf5yvT66uV7QgY/QFNmaglf8gbUyzp t5YNb6ZaP+86W6bU6Udke+DIAggSSWXaf27AN9sER6taAVcuH8uKbvQG4ajbIFSfKH iXElV95hPBWFg== 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 RFC 5/7] libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops Date: Wed, 1 Jun 2022 16:44:35 -0400 Message-Id: <20220601204437.676872-6-krisman@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220601204437.676872-1-krisman@collabora.com> References: <20220601204437.676872-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no 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 fe22738291e4..9d91f471203a 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