From: Qu Wenruo <wqu@suse.com>
To: Daniel Vacek <neelx@suse.com>, David Sterba <dsterba@suse.com>
Cc: linux-fscrypt@vger.kernel.org, linux-btrfs@vger.kernel.org,
linux-kernel@vger.kernel.org,
Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Subject: Re: [PATCH v3 6/7] btrfs-progs: check: update inline extent length checking
Date: Wed, 8 Jul 2026 08:13:30 +0930 [thread overview]
Message-ID: <12ca4ad2-0b35-41ef-8527-7a047549986d@suse.com> (raw)
In-Reply-To: <20260707142736.2330146-7-neelx@suse.com>
在 2026/7/7 23:57, Daniel Vacek 写道:
> From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
>
> As part of the encryption changes, encrypted inline file extents record
> their actual data length in ram_bytes, like compressed inline file
> extents, while the item's length records the actual size. As such,
> encrypted inline extents must be treated like compressed ones for
> inode length consistency checking.
>
> Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
> Signed-off-by: Daniel Vacek <neelx@suse.com>
> ---
> check/main.c | 31 +++++++++++++++++--------------
> 1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/check/main.c b/check/main.c
> index 9447b01e..cadcfef0 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -1720,9 +1720,7 @@ static int process_file_extent(struct btrfs_root *root,
> u64 disk_bytenr = 0;
> u64 extent_offset = 0;
> u64 mask = gfs_info->sectorsize - 1;
> - u32 max_inline_size = min_t(u32, mask,
> - BTRFS_MAX_INLINE_DATA_SIZE(gfs_info));
> - u8 compression;
> + u8 compression, encryption;
> int extent_type;
> int ret;
>
> @@ -1747,25 +1745,30 @@ static int process_file_extent(struct btrfs_root *root,
> fi = btrfs_item_ptr(eb, slot, struct btrfs_file_extent_item);
> extent_type = btrfs_file_extent_type(eb, fi);
> compression = btrfs_file_extent_compression(eb, fi);
> + encryption = btrfs_file_extent_encryption(eb, fi);
>
> if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
> - num_bytes = btrfs_file_extent_ram_bytes(eb, fi);
> - if (num_bytes == 0)
> + u32 max_inline_size = min_t(u32, mask,
> + BTRFS_MAX_INLINE_DATA_SIZE(gfs_info));
> + u64 num_disk_bytes = btrfs_file_extent_inline_item_len(eb, slot);
> + u64 num_decoded_bytes = btrfs_file_extent_ram_bytes(eb, fi);
> + if (num_decoded_bytes == 0)
> rec->errors |= I_ERR_BAD_FILE_EXTENT;
> - if (compression) {
> - if (btrfs_file_extent_inline_item_len(eb, slot) >
> - max_inline_size ||
> - num_bytes > gfs_info->sectorsize)
> + if (compression || encryption) {
> + if (encryption)
> + max_inline_size = min_t(u32, gfs_info->sectorsize,
> + BTRFS_MAX_INLINE_DATA_SIZE(gfs_info));
The change looks good to me now.
However I'm just curious, is it possible to limit the encrypted data
size to sectorsize-1?
Or it is some fscrypt limit internal requiring a power-of-2 size or just
lack of interface?
Anyway I won't object this new change.
Thanks,
Qu
> + if (num_disk_bytes > max_inline_size ||
> + num_decoded_bytes > gfs_info->sectorsize)
> rec->errors |= I_ERR_FILE_EXTENT_TOO_LARGE;
> } else {
> - if (num_bytes > max_inline_size)
> + if (num_decoded_bytes > max_inline_size)
> rec->errors |= I_ERR_FILE_EXTENT_TOO_LARGE;
> - if (btrfs_file_extent_inline_item_len(eb, slot) !=
> - num_bytes)
> + if (num_disk_bytes != num_decoded_bytes)
> rec->errors |= I_ERR_INLINE_RAM_BYTES_WRONG;
> }
> - rec->found_size += num_bytes;
> - num_bytes = (num_bytes + mask) & ~mask;
> + rec->found_size += num_decoded_bytes;
> + num_bytes = (num_decoded_bytes + mask) & ~mask;
> } else if (extent_type == BTRFS_FILE_EXTENT_REG ||
> extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
> num_bytes = btrfs_file_extent_num_bytes(eb, fi);
next prev parent reply other threads:[~2026-07-07 22:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 14:27 [PATCH v3 0/7] btrfs-progs: fscrypt updates Daniel Vacek
2026-07-07 14:27 ` [PATCH v3 1/7] btrfs-progs: add new FEATURE_INCOMPAT_ENCRYPT flag Daniel Vacek
2026-07-07 14:27 ` [PATCH v3 2/7] btrfs-progs: start tracking extent encryption context info Daniel Vacek
2026-07-07 14:27 ` [PATCH v3 3/7] btrfs-progs: add inode encryption contexts Daniel Vacek
2026-07-07 14:27 ` [PATCH v3 4/7] btrfs-progs: print encryptin type field of file extents Daniel Vacek
2026-07-07 22:40 ` Qu Wenruo
2026-07-08 4:38 ` Daniel Vacek
2026-07-07 14:27 ` [PATCH v3 5/7] btrfs-progs: handle fscrypt context items Daniel Vacek
2026-07-07 14:27 ` [PATCH v3 6/7] btrfs-progs: check: update inline extent length checking Daniel Vacek
2026-07-07 22:43 ` Qu Wenruo [this message]
2026-07-08 5:00 ` Daniel Vacek
2026-07-08 5:07 ` Qu Wenruo
2026-07-07 14:27 ` [PATCH v3 7/7] btrfs-progs: recognize ENCRYPT inode item flag Daniel Vacek
2026-07-07 14:33 ` [PATCH v3 0/7] btrfs-progs: fscrypt updates Daniel Vacek
2026-07-08 4:59 ` Qu Wenruo
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=12ca4ad2-0b35-41ef-8527-7a047549986d@suse.com \
--to=wqu@suse.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neelx@suse.com \
--cc=sweettea-kernel@dorminy.me \
/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