From: Eric Biggers <ebiggers@kernel.org>
To: Gabriel Krisman Bertazi <krisman@suse.de>
Cc: viro@zeniv.linux.org.uk, jaegeuk@kernel.org, tytso@mit.edu,
amir73il@gmail.com, linux-ext4@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org, brauner@kernel.org
Subject: Re: [PATCH v6 03/10] fscrypt: Drop d_revalidate for valid dentries during lookup
Date: Wed, 14 Feb 2024 15:59:04 -0800 [thread overview]
Message-ID: <20240214235904.GH1638@sol.localdomain> (raw)
In-Reply-To: <20240213021321.1804-4-krisman@suse.de>
On Mon, Feb 12, 2024 at 09:13:14PM -0500, Gabriel Krisman Bertazi wrote:
> Finally, we need to clean the dentry->flags even for unencrypted
> dentries, so the ->d_lock might be acquired even for them. In order to
might => must?
> diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
> index 47567a6a4f9d..d1f17b90c30f 100644
> --- a/include/linux/fscrypt.h
> +++ b/include/linux/fscrypt.h
> @@ -951,10 +951,29 @@ static inline int fscrypt_prepare_rename(struct inode *old_dir,
> static inline void fscrypt_prepare_dentry(struct dentry *dentry,
> bool is_nokey_name)
> {
> + /*
> + * This code tries to only take ->d_lock when necessary to write
> + * to ->d_flags. We shouldn't be peeking on d_flags for
> + * DCACHE_OP_REVALIDATE unlocked, but in the unlikely case
> + * there is a race, the worst it can happen is that we fail to
> + * unset DCACHE_OP_REVALIDATE and pay the cost of an extra
> + * d_revalidate.
> + */
> if (is_nokey_name) {
> spin_lock(&dentry->d_lock);
> dentry->d_flags |= DCACHE_NOKEY_NAME;
> spin_unlock(&dentry->d_lock);
> + } else if (dentry->d_flags & DCACHE_OP_REVALIDATE &&
> + dentry->d_op->d_revalidate == fscrypt_d_revalidate) {
> + /*
> + * Unencrypted dentries and encrypted dentries where the
> + * key is available are always valid from fscrypt
> + * perspective. Avoid the cost of calling
> + * fscrypt_d_revalidate unnecessarily.
> + */
> + spin_lock(&dentry->d_lock);
> + dentry->d_flags &= ~DCACHE_OP_REVALIDATE;
> + spin_unlock(&dentry->d_lock);
> }
> }
Does this all get optimized out when !CONFIG_FS_ENCRYPTION?
As-is, I don't think the d_revalidate part will be optimized out.
You may need to create a !CONFIG_FS_ENCRYPTION stub explicitly.
- Eric
WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers@kernel.org>
To: Gabriel Krisman Bertazi <krisman@suse.de>
Cc: brauner@kernel.org, tytso@mit.edu, amir73il@gmail.com,
linux-f2fs-devel@lists.sourceforge.net, viro@zeniv.linux.org.uk,
linux-fsdevel@vger.kernel.org, jaegeuk@kernel.org,
linux-ext4@vger.kernel.org
Subject: Re: [f2fs-dev] [PATCH v6 03/10] fscrypt: Drop d_revalidate for valid dentries during lookup
Date: Wed, 14 Feb 2024 15:59:04 -0800 [thread overview]
Message-ID: <20240214235904.GH1638@sol.localdomain> (raw)
In-Reply-To: <20240213021321.1804-4-krisman@suse.de>
On Mon, Feb 12, 2024 at 09:13:14PM -0500, Gabriel Krisman Bertazi wrote:
> Finally, we need to clean the dentry->flags even for unencrypted
> dentries, so the ->d_lock might be acquired even for them. In order to
might => must?
> diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
> index 47567a6a4f9d..d1f17b90c30f 100644
> --- a/include/linux/fscrypt.h
> +++ b/include/linux/fscrypt.h
> @@ -951,10 +951,29 @@ static inline int fscrypt_prepare_rename(struct inode *old_dir,
> static inline void fscrypt_prepare_dentry(struct dentry *dentry,
> bool is_nokey_name)
> {
> + /*
> + * This code tries to only take ->d_lock when necessary to write
> + * to ->d_flags. We shouldn't be peeking on d_flags for
> + * DCACHE_OP_REVALIDATE unlocked, but in the unlikely case
> + * there is a race, the worst it can happen is that we fail to
> + * unset DCACHE_OP_REVALIDATE and pay the cost of an extra
> + * d_revalidate.
> + */
> if (is_nokey_name) {
> spin_lock(&dentry->d_lock);
> dentry->d_flags |= DCACHE_NOKEY_NAME;
> spin_unlock(&dentry->d_lock);
> + } else if (dentry->d_flags & DCACHE_OP_REVALIDATE &&
> + dentry->d_op->d_revalidate == fscrypt_d_revalidate) {
> + /*
> + * Unencrypted dentries and encrypted dentries where the
> + * key is available are always valid from fscrypt
> + * perspective. Avoid the cost of calling
> + * fscrypt_d_revalidate unnecessarily.
> + */
> + spin_lock(&dentry->d_lock);
> + dentry->d_flags &= ~DCACHE_OP_REVALIDATE;
> + spin_unlock(&dentry->d_lock);
> }
> }
Does this all get optimized out when !CONFIG_FS_ENCRYPTION?
As-is, I don't think the d_revalidate part will be optimized out.
You may need to create a !CONFIG_FS_ENCRYPTION stub explicitly.
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2024-02-14 23:59 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 2:13 [PATCH v6 00/10] Set casefold/fscrypt dentry operations through sb->s_d_op Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [PATCH v6 01/10] ovl: Always reject mounting over case-insensitive directories Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [PATCH v6 02/10] fscrypt: Factor out a helper to configure the lookup dentry Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-14 23:54 ` Eric Biggers
2024-02-14 23:54 ` [f2fs-dev] " Eric Biggers
2024-02-13 2:13 ` [PATCH v6 03/10] fscrypt: Drop d_revalidate for valid dentries during lookup Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-14 23:59 ` Eric Biggers [this message]
2024-02-14 23:59 ` Eric Biggers
2024-02-20 23:03 ` Gabriel Krisman Bertazi
2024-02-20 23:03 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [PATCH v6 04/10] fscrypt: Drop d_revalidate once the key is added Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-15 0:16 ` Eric Biggers
2024-02-15 0:16 ` [f2fs-dev] " Eric Biggers
2024-02-15 0:31 ` Eric Biggers
2024-02-15 0:31 ` [f2fs-dev] " Eric Biggers
2024-02-20 0:48 ` Gabriel Krisman Bertazi
2024-02-20 0:48 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [PATCH v6 05/10] libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [PATCH v6 06/10] libfs: Add helper to choose dentry operations at mount-time Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [PATCH v6 07/10] ext4: Configure dentry operations at dentry-creation time Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [PATCH v6 08/10] f2fs: " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [PATCH v6 09/10] ubifs: " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-13 2:13 ` [PATCH v6 10/10] libfs: Drop generic_set_encrypted_ci_d_ops Gabriel Krisman Bertazi
2024-02-13 2:13 ` [f2fs-dev] " Gabriel Krisman Bertazi
2024-02-15 0:24 ` [PATCH v6 00/10] Set casefold/fscrypt dentry operations through sb->s_d_op Eric Biggers
2024-02-15 0:24 ` [f2fs-dev] " Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240214235904.GH1638@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=krisman@suse.de \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.