From: Josef Bacik <josef@toxicpanda.com>
To: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Cc: "Theodore Y. Ts'o" <tytso@mit.edu>,
Jaegeuk Kim <jaegeuk@kernel.org>,
Eric Biggers <ebiggers@kernel.org>, Chris Mason <clm@fb.com>,
David Sterba <dsterba@suse.com>,
linux-fscrypt@vger.kernel.org, linux-btrfs@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH v2 14/17] btrfs: create and free extent fscrypt_infos
Date: Mon, 17 Jul 2023 13:58:00 -0400 [thread overview]
Message-ID: <20230717175800.GN691303@perftesting> (raw)
In-Reply-To: <fe6e2a2a1fb1c7e3942c83a496aed1694ccb5b44.1689564024.git.sweettea-kernel@dorminy.me>
On Sun, Jul 16, 2023 at 11:52:45PM -0400, Sweet Tea Dorminy wrote:
> Each extent_map will end up with a pointer to its associated
> fscrypt_info if any, which should have the same lifetime as the
> extent_map. Add creation of fscrypt_infos for new extent_maps, and
> freeing as appropriate.
>
> Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
> ---
> fs/btrfs/extent_map.c | 8 ++++++++
> fs/btrfs/extent_map.h | 3 +++
> fs/btrfs/inode.c | 8 ++++++++
> 3 files changed, 19 insertions(+)
>
> diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
> index 0cdb3e86f29b..4fa5f97559da 100644
> --- a/fs/btrfs/extent_map.c
> +++ b/fs/btrfs/extent_map.c
> @@ -65,6 +65,8 @@ void free_extent_map(struct extent_map *em)
> if (!em)
> return;
> if (refcount_dec_and_test(&em->refs)) {
> + if (em->fscrypt_info)
> + fscrypt_free_extent_info(&em->fscrypt_info);
> WARN_ON(extent_map_in_tree(em));
> WARN_ON(!list_empty(&em->list));
> if (test_bit(EXTENT_FLAG_FS_MAPPING, &em->flags))
> @@ -207,6 +209,12 @@ static int mergable_maps(struct extent_map *prev, struct extent_map *next)
> if (!list_empty(&prev->list) || !list_empty(&next->list))
> return 0;
>
> + /*
> + * Don't merge adjacent encrypted maps.
> + */
> + if (prev->fscrypt_info || next->fscrypt_info)
> + return 0;
> +
> ASSERT(next->block_start != EXTENT_MAP_DELALLOC &&
> prev->block_start != EXTENT_MAP_DELALLOC);
>
> diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h
> index 35d27c756e08..3a1b66b1cedf 100644
> --- a/fs/btrfs/extent_map.h
> +++ b/fs/btrfs/extent_map.h
> @@ -27,6 +27,8 @@ enum {
> EXTENT_FLAG_FS_MAPPING,
> /* This em is merged from two or more physically adjacent ems */
> EXTENT_FLAG_MERGED,
> + /* This em has a fscrypt info */
> + EXTENT_FLAG_ENCRYPTED,
> };
>
> struct extent_map {
> @@ -50,6 +52,7 @@ struct extent_map {
> */
> u64 generation;
> unsigned long flags;
> + struct fscrypt_info *fscrypt_info;
> /* Used for chunk mappings, flag EXTENT_FLAG_FS_MAPPING must be set */
> struct map_lookup *map_lookup;
> refcount_t refs;
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 40c2ec328730..b43fc253ecd1 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7460,6 +7460,14 @@ static struct extent_map *create_io_em(struct btrfs_inode *inode, u64 start,
> em->compress_type = compress_type;
> }
>
> + ret = fscrypt_prepare_new_extent(&inode->vfs_inode, &em->fscrypt_info);
> + if (ret < 0) {
> + free_extent_map(em);
> + return ERR_PTR(ret);
> + }
> + if (em->fscrypt_info)
> + set_bit(EXTENT_FLAG_ENCRYPTED, &em->flags);
We don't check this flag anywhere, you can drop it. Thanks,
Josef
next prev parent reply other threads:[~2023-07-17 17:58 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-17 3:52 [PATCH v2 00/17] btrfs: add encryption feature Sweet Tea Dorminy
2023-07-17 3:52 ` [PATCH v2 01/17] btrfs: disable various operations on encrypted inodes Sweet Tea Dorminy
2023-07-17 3:52 ` [PATCH v2 02/17] btrfs: disable verity " Sweet Tea Dorminy
2023-07-17 3:52 ` [PATCH v2 03/17] fscrypt: expose fscrypt_nokey_name Sweet Tea Dorminy
2023-07-17 3:52 ` [PATCH v2 04/17] btrfs: start using fscrypt hooks Sweet Tea Dorminy
2023-07-17 15:34 ` Luís Henriques
2023-07-17 17:28 ` David Sterba
2023-07-18 8:36 ` Luís Henriques
2023-07-17 3:52 ` [PATCH v2 05/17] btrfs: add inode encryption contexts Sweet Tea Dorminy
2023-07-17 15:41 ` Josef Bacik
2023-07-17 3:52 ` [PATCH v2 06/17] btrfs: add new FEATURE_INCOMPAT_ENCRYPT flag Sweet Tea Dorminy
2023-07-17 15:42 ` Josef Bacik
2023-07-17 3:52 ` [PATCH v2 07/17] btrfs: adapt readdir for encrypted and nokey names Sweet Tea Dorminy
2023-07-17 15:34 ` Luís Henriques
2023-07-17 17:46 ` Josef Bacik
2023-07-17 3:52 ` [PATCH v2 08/17] btrfs: use correct name hash for " Sweet Tea Dorminy
2023-07-17 3:52 ` [PATCH v2 09/17] btrfs: implement fscrypt ioctls Sweet Tea Dorminy
2023-07-17 3:52 ` [PATCH v2 10/17] btrfs: add encryption to CONFIG_BTRFS_DEBUG Sweet Tea Dorminy
2023-07-17 3:52 ` [PATCH v2 11/17] btrfs: add get_devices hook for fscrypt Sweet Tea Dorminy
2023-07-17 17:51 ` Josef Bacik
2023-07-17 3:52 ` [PATCH v2 12/17] btrfs: turn on inlinecrypt mount option for encrypt Sweet Tea Dorminy
2023-07-17 15:34 ` Luís Henriques
2023-07-17 17:55 ` Josef Bacik
2023-07-17 3:52 ` [PATCH v2 13/17] btrfs: turn on the encryption ioctls Sweet Tea Dorminy
2023-07-17 3:52 ` [PATCH v2 14/17] btrfs: create and free extent fscrypt_infos Sweet Tea Dorminy
2023-07-17 17:58 ` Josef Bacik [this message]
2023-07-17 3:52 ` [PATCH v2 15/17] btrfs: start tracking extent encryption context info Sweet Tea Dorminy
2023-07-17 18:11 ` Josef Bacik
2023-07-17 3:52 ` [PATCH v2 16/17] btrfs: explicitly track file extent length and encryption Sweet Tea Dorminy
2023-07-17 15:30 ` Josef Bacik
2023-07-17 18:12 ` Josef Bacik
2023-07-17 3:52 ` [PATCH v2 17/17] btrfs: save and load fscrypt extent contexts Sweet Tea Dorminy
2023-07-17 18:15 ` Josef Bacik
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=20230717175800.GN691303@perftesting \
--to=josef@toxicpanda.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=ebiggers@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=sweettea-kernel@dorminy.me \
--cc=tytso@mit.edu \
/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.