Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2919076rwr; Fri, 21 Apr 2023 17:04:47 -0700 (PDT) X-Google-Smtp-Source: AKy350Zc4w4k1BozPuOWkdaz2BdoziYRRn5TP12dBGGZWlVeKgbzul39HOn8A+j7WzlfHFAk/4tu X-Received: by 2002:a17:903:2807:b0:1a6:d2af:5a3f with SMTP id kp7-20020a170903280700b001a6d2af5a3fmr5655225plb.3.1682121887294; Fri, 21 Apr 2023 17:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682121887; cv=none; d=google.com; s=arc-20160816; b=E3cf5hpBz6PtQjtBAd8+KmLea9lkDn4uzSKX/bT4a28WzZXmgQNtR2mpAn0Vs3mrpq gn6nuPPZBTuCeg7mJAZIpIa0X9f3ayKxtwXoqrNBTDbT4AbfyJTnvSS0+WDY+rKrP6gq S2tVTezu0POllZrmxzOKAeoZ5rxC+WDbXpcbDU3kOi+5Yg+PIFDc02yRWNOicUx/qVkW eT1rZoAOjEwPvQWUl3XtvlwVmcJouUbdXDU2sq+pVm0NAgJwoKIOkqE+e4QulMW7Pdh7 h9zXgfJ9YdDm0BCbHrueZPvPLXrwuAUSacgGKE0gxXylWU+Ussr6+7IFM/EVIXTw+jk+ 38IA== 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:dkim-signature; bh=XQ2hnOdmsNbOalgg2OMbyQl6sErzhoHUuwjQS8j97Nk=; b=GVaWAMil+LlBrznuTFAmXUfeF3MZKf9uwGE+uINtgyEwO0F8+z82Nk/QhMl0xGX3M4 zI/aw9okr3iurfUuYHh5PcjJcZrZP8GZ2YJxVhaT4t2ojwE3G8rESKa4RZ9obNIlflio LPzFbHl82chdY3VUOh0Ei67HmmJSFIBpSPdACaw4hghN7Ed2InjuIfYbS9Gc0Fxclplm ZMn7zYIgvSsTTE+vCHYAGoLBJx3S9bT6m1s6T3/+PowwHBEo8BEXQ0xiU2YLA5LvM6Yd eOtvrKgedvzN/tf/plFGzI6ZBbqPp43etfGJ6apRMWA2qRj3y2oR7QaUs7K3KtUTl22Z uL/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=BFFUkMJ1; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a630704000000b0051b13a071a8si5734427pgh.575.2023.04.21.17.04.34; Fri, 21 Apr 2023 17:04: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=@suse.de header.s=susede2_rsa header.b=BFFUkMJ1; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233684AbjDVADp (ORCPT + 99 others); Fri, 21 Apr 2023 20:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233753AbjDVADd (ORCPT ); Fri, 21 Apr 2023 20:03:33 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C9632728; Fri, 21 Apr 2023 17:03:21 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6A3491F74A; Sat, 22 Apr 2023 00:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1682121799; 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=XQ2hnOdmsNbOalgg2OMbyQl6sErzhoHUuwjQS8j97Nk=; b=BFFUkMJ1mM7zUwoO7pQsExf12xi88DS2xXyZNV7FNQe2tPCYu5DFviHR63leB2aNdNLxTv Cy+5M6J0UJGnYrDc9NFhlqmjaQlLZ5v5tD3Q3BDyEBz1R18O1Vdy64FLdBclnhPVCH6QX8 BVJ/thhQSe5logCbkyLyr5pL7bTju40= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1682121799; 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=XQ2hnOdmsNbOalgg2OMbyQl6sErzhoHUuwjQS8j97Nk=; b=gtw9hA5UoDxnDy6dq4kGmTD0HMrJQA5PKwzHB1peiO1mQBQ+DaGe43T9pDTCPEU7J/+h66 +ZReDzfsoTb/nqAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 328041358E; Sat, 22 Apr 2023 00:03:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qoS1BkckQ2TpdwAAMHmgww (envelope-from ); Sat, 22 Apr 2023 00:03:19 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, brauner@kernel.org Cc: tytso@mit.edu, jaegeuk@kernel.org, ebiggers@kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, krisman@suse.de Subject: [PATCH v2 5/7] libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops Date: Fri, 21 Apr 2023 20:03:08 -0400 Message-Id: <20230422000310.1802-6-krisman@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230422000310.1802-1-krisman@suse.de> References: <20230422000310.1802-1-krisman@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 From: Gabriel Krisman Bertazi 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 0886044db593..348ec6130198 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1504,7 +1504,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, @@ -1517,26 +1517,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. @@ -1549,30 +1543,18 @@ 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.40.0