From patchwork Wed Aug 16 05:08:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13354569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6AE97C04FDF for ; Wed, 16 Aug 2023 05:08:28 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1qW8lf-0001qo-Sz; Wed, 16 Aug 2023 05:08:27 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qW8le-0001qh-Mb for linux-f2fs-devel@lists.sourceforge.net; Wed, 16 Aug 2023 05:08:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=+WpWeF/beREB2Fn9GeBuU/+YeiAk2ooPdVMPezCQUNU=; b=FoSRihzB5K+UYiY5wcW4wz9RfV 1CHXzyO8byINqpksZfKhiT3vglZZUB3j9HmdSqDX7ETSr/siZtVfr5pe829Idrk4xeQRKndRMPsnR dk7ozAv1K3hh9N/D/NyXp1445W6EnCHFAu8GFbOwnw2c6ETY1u9NEyA4/jLemAQzd92M=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=+WpWeF/beREB2Fn9GeBuU/+YeiAk2ooPdVMPezCQUNU=; b=GzIFU6Sj7JjlUJ1CtRUZv0q0lD fdZXmvNXRj3wYn3BykOKwdwO+N+O4eavJbGe0VgV2aVRjFbGcd4hUE6JE1X5FByN7IV2tC0yK42rW PVKRs2pkbhIoYHqLp1Im9FNMp1DiFz3ymlmRuiOpUcGQlsrsvywhgHSM3Ug13L9gpxyo=; Received: from smtp-out1.suse.de ([195.135.220.28]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1qW8ld-006njT-3L for linux-f2fs-devel@lists.sourceforge.net; Wed, 16 Aug 2023 05:08:26 +0000 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-out1.suse.de (Postfix) with ESMTPS id DD4492197E; Wed, 16 Aug 2023 05:08:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692162498; 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=+WpWeF/beREB2Fn9GeBuU/+YeiAk2ooPdVMPezCQUNU=; b=lm26MfDUBiHQuyHb46zaQ0o6C2cOU0FMGKuUoH5PiNp/835savhoWnQU4yN/xwQp+sgURX HJwxuqQSkWegX9sgFI3dP7n6NulUFc/z/stg/WjNWzB40wUHvT8QnccJh7eqR7AgwBubKc 05pmpGknUCyYROU9sNy4reGD1/4T/9o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692162498; 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=+WpWeF/beREB2Fn9GeBuU/+YeiAk2ooPdVMPezCQUNU=; b=hmNCRvvC0SKQcXmET/OnFbvqes+JG+oLvQXYa/0idPerhVvI3iw5xCvUj+5nqfEpBf2ScO p+rJlV8dLA6NbRBQ== 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 A804E133F2; Wed, 16 Aug 2023 05:08:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6J9KI8JZ3GQFTwAAMHmgww (envelope-from ); Wed, 16 Aug 2023 05:08:18 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, brauner@kernel.org, tytso@mit.edu, ebiggers@kernel.org, jaegeuk@kernel.org Date: Wed, 16 Aug 2023 01:08:01 -0400 Message-ID: <20230816050803.15660-8-krisman@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230816050803.15660-1-krisman@suse.de> References: <20230816050803.15660-1-krisman@suse.de> MIME-Version: 1.0 X-Headers-End: 1qW8ld-006njT-3L Subject: [f2fs-dev] [PATCH v6 7/9] libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi , linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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 994e4c98ec07..e7a44a2be0ee 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1523,7 +1523,7 @@ static int generic_ci_d_revalidate(struct dentry *dentry, return fscrypt_d_revalidate(dentry, name, 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 = generic_ci_d_revalidate, @@ -1536,26 +1536,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 = 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. @@ -1564,34 +1557,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);