From: Eric Biggers <ebiggers@kernel.org>
To: linux-fscrypt@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] fscrypt: introduce fscrypt_needs_contents_encryption()
Date: Fri, 3 Jan 2020 08:59:53 -0800 [thread overview]
Message-ID: <20200103165953.GH19521@gmail.com> (raw)
In-Reply-To: <20191209205021.231767-1-ebiggers@kernel.org>
On Mon, Dec 09, 2019 at 12:50:21PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Add a function fscrypt_needs_contents_encryption() which takes an inode
> and returns true if it's an encrypted regular file and the kernel was
> built with fscrypt support.
>
> This will allow replacing duplicated checks of IS_ENCRYPTED() &&
> S_ISREG() on the I/O paths in ext4 and f2fs, while also optimizing out
> unneeded code when !CONFIG_FS_ENCRYPTION.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> include/linux/fscrypt.h | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
> index cb18b5fbcef92..2a29f56b1a1cb 100644
> --- a/include/linux/fscrypt.h
> +++ b/include/linux/fscrypt.h
> @@ -72,6 +72,21 @@ static inline bool fscrypt_has_encryption_key(const struct inode *inode)
> return READ_ONCE(inode->i_crypt_info) != NULL;
> }
>
> +/**
> + * fscrypt_needs_contents_encryption() - check whether an inode needs
> + * contents encryption
> + *
> + * Return: %true iff the inode is an encrypted regular file and the kernel was
> + * built with fscrypt support.
> + *
> + * If you need to know whether the encrypt bit is set even when the kernel was
> + * built without fscrypt support, you must use IS_ENCRYPTED() directly instead.
> + */
> +static inline bool fscrypt_needs_contents_encryption(const struct inode *inode)
> +{
> + return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode);
> +}
> +
> static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
> {
> return inode->i_sb->s_cop->dummy_context &&
> @@ -269,6 +284,11 @@ static inline bool fscrypt_has_encryption_key(const struct inode *inode)
> return false;
> }
>
> +static inline bool fscrypt_needs_contents_encryption(const struct inode *inode)
> +{
> + return false;
> +}
> +
> static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
> {
> return false;
> --
> 2.24.0.393.g34dc348eaf-goog
>
Applied to fscrypt.git#master for 5.6.
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
prev parent reply other threads:[~2020-01-03 17:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-09 20:50 [f2fs-dev] [PATCH] fscrypt: introduce fscrypt_needs_contents_encryption() Eric Biggers
2020-01-03 16:59 ` Eric Biggers [this message]
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=20200103165953.GH19521@gmail.com \
--to=ebiggers@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).