Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8795378rwp; Wed, 19 Jul 2023 15:48:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlGi/zrNTO60t9pdstI5aEbkG8sbvwovI3DMN04rQB5/BFrghdUXfnWVDplliiBH+5WscbYr X-Received: by 2002:a05:6a21:9994:b0:133:31a5:51e7 with SMTP id ve20-20020a056a21999400b0013331a551e7mr4674573pzb.15.1689806907797; Wed, 19 Jul 2023 15:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689806907; cv=none; d=google.com; s=arc-20160816; b=OWPCtrL7SzkyLn4fZI8LpTmEFPe0Ns5xNUmJC9eoW1vy/G08Akjfsjmb2fptJ7z3Tg khkm0jOahHRzeVw37MpaqSmYfvR/3Ut/yDBE+xFSD6GqsMbE3HNGGYFmtY7UFWSwlSLQ 2HFSUqVjcVlyjt+gAllaeCuklDSwe7dtaeFTtYTBoQ3K93QVUYYRk7JnfeVH6oOh+x9O QO6NQp6zQehg5CgQvQBayb1UvTJzc7dcUNKsJjQtOfD6M8a7S6f5/fF6zMTF4wNT8QwI 2bXu/nFV57cXv4vKWm+h5WiKlOk6/HEId70OcJff62CHy8b0+90IZLj7dCTHX6DvKTjf c6Qw== 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=Hch9rlN4VJgrjRd/qxMeA52Jlrh8ygkMI0uHGfFx36A=; fh=HFDFbc5lRXwuu0vgGURCiLYm5ywsvQKdSNBX4pGxTs4=; b=nV19fUCAg0uFjoazRDk3x2jkwq4JFiGVjaz7BrcBsI/cck6z5rWwjFWAz5bK6uH8JH i6PJVWvggFZxGr9eHd+5nG73FZmAmyzbVqW83Z5Oylc54iA16MIOxeB2qibdFhxZNY2o QogIFzam1HOODp6hyS18k1VENRc/uaZuNSXlMQ8URV6d3w6rD87c7I8rTbib6s1BudsC 2D5bkbQoPg9gCQdzixg3flLyJOxueST4cWdZE3PvCljPXzNkbtSKIDV0CNEfezT3zE1O qyjgYkhvMS6Lpn+igs2Ir0tGhhiu4KvVDDuH+EJvscdq6e4ztotvkujH/MwgvaxxGaDJ Zocg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=AtIHlxZt; 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 x129-20020a636387000000b0055b7319a311si4386167pgb.356.2023.07.19.15.48.11; Wed, 19 Jul 2023 15:48:27 -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=AtIHlxZt; 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 S230031AbjGSWTm (ORCPT + 99 others); Wed, 19 Jul 2023 18:19:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbjGSWTk (ORCPT ); Wed, 19 Jul 2023 18:19:40 -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 8FB901BCF; Wed, 19 Jul 2023 15:19:39 -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 4F329201F0; Wed, 19 Jul 2023 22:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689805178; 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=Hch9rlN4VJgrjRd/qxMeA52Jlrh8ygkMI0uHGfFx36A=; b=AtIHlxZtdwfFL8etZ4a0rC26jKXXUp8fht+Sh8Gj8rBWIKu1+fMDVB0CyJBDXnD2AxiFf/ Ug+zlgMRvz4XXY/HwzHwrXPtfk+vLjePQmsezVmT/rgYfu+jzmuZ7gQ3oNxgSJWLq9l7Zl REOFex8/d3/O2Pxcx1iTavd//8tQeYU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689805178; 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=Hch9rlN4VJgrjRd/qxMeA52Jlrh8ygkMI0uHGfFx36A=; b=SpIZfCLRol76uv25gJkvNj+jME54/WioV8CD7hAa4yHCf3J/j+u9XBdi7Nw4Bq563oaY6m vq3NOEg2uFBVJ3Cw== 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 19F501361C; Wed, 19 Jul 2023 22:19:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 7Ka8AHphuGQdJgAAMHmgww (envelope-from ); Wed, 19 Jul 2023 22:19:38 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, brauner@kernel.org, tytso@mit.edu, ebiggers@kernel.org, jaegeuk@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi , Gabriel Krisman Bertazi Subject: [PATCH v3 5/7] libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops Date: Wed, 19 Jul 2023 18:19:16 -0400 Message-ID: <20230719221918.8937-6-krisman@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230719221918.8937-1-krisman@suse.de> References: <20230719221918.8937-1-krisman@suse.de> 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,RCVD_IN_DNSWL_BLOCKED, 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 --- changes since v2: - reword comment for clarity (Eric) --- fs/libfs.c | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 0e5d3bb1dddc..73cd06e7ff90 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1509,7 +1509,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, @@ -1522,26 +1522,19 @@ 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 some dentry_operations set, so that the dentries + * contained in them are handled case-insensitively. Note that d_hash and + * d_compare 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. @@ -1550,34 +1543,22 @@ static const struct dentry_operations generic_encrypted_ci_dentry_ops = { * 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. + * combination of operations rather than always installing them. */ 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.41.0