mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Daniel Vacek <neelx@suse.com>, Qu Wenruo <wqu@suse.com>
Cc: David Sterba <dsterba@suse.com>,
	linux-fscrypt@vger.kernel.org, linux-btrfs@vger.kernel.org,
	linux-kernel@vger.kernel.org, Josef Bacik <josef@toxicpanda.com>
Subject: Re: [PATCH v2 1/8] btrfs-progs: check: fix max inline extent size
Date: Thu, 2 Jul 2026 07:52:45 +0930	[thread overview]
Message-ID: <2da4b215-165f-4bd6-a2da-07c9012586b7@gmx.com> (raw)
In-Reply-To: <CAPjX3FdE8REFdGT06k2RehJMfETgrxPzHZ3+V7FPaM_c1UwfcQ@mail.gmail.com>



在 2026/7/2 01:17, Daniel Vacek 写道:
> On Fri, 26 Jun 2026 at 01:41, Qu Wenruo <wqu@suse.com> wrote:
>> 在 2026/6/25 02:21, Daniel Vacek 写道:
>>> From: Josef Bacik <josef@toxicpanda.com>
>>>
>>> Fscrypt will use our entire inline extent range for symlinks, which
>>> uncovered a bug in btrfs check where we set the maximum inline extent
>>> size to
>>>
>>> min(sectorsize - 1, BTRFS_MAX_INLINE_DATA_SIZE)
>>>
>>> which isn't correct, we have always allowed sectorsize sized inline
>>> extents, so fix check to use the correct maximum inline extent size.
>>
>> No, we only allow sector sized inline extent when it is compressed.
>> The de-compressed size can be sector sized, but the compressed size
>> still can not reach sector size.
>>
>> So this doesn't seems correct to me.
> 
> With encryption it's the other way around. Even shorter data (symlink
> path) is always padded to multiple of the cipher block size (16 bytes
> with AES). Inlining a full sector size is perfectly valid. The dump
> from my test looks like this:
> 
> ~~~
>      item 45 key (290 DIR_ITEM 3363472967) itemoff 11425 itemsize 62
>          location key (300 INODE_ITEM 0) type SYMLINK
>          transid 14 data_len 0 name_len 32
>          name: \243\365@;\312\321\240\367\377\234_{\245\vW\
> \035\rS\222ryN\323\031g\243\nt3\321+
> 
>      item 58 key (290 DIR_INDEX 11) itemoff 10077 itemsize 62
>          location key (300 INODE_ITEM 0) type SYMLINK
>          transid 14 data_len 0 name_len 32
>          name: \243\365@;\312\321\240\367\377\234_{\245\vW\
> \035\rS\222ryN\323\031g\243\nt3\321+
> 
>      item 86 key (300 INODE_ITEM 0) itemoff 7197 itemsize 160
>          generation 14 transid 14 size 4096 nbytes 4096
>          block group 0 mode 120777 links 1 uid 0 gid 0 rdev 0
>          sequence 1829 flags 0x1000(ENCRYPT)
>          atime 1782916271.8000000 (2026-07-01 16:31:11)
>          ctime 1782916271.8000000 (2026-07-01 16:31:11)
>          mtime 1782916271.8000000 (2026-07-01 16:31:11)
>          otime 1782916271.8000000 (2026-07-01 16:31:11)
>      item 87 key (300 INODE_REF 290) itemoff 7155 itemsize 42
>          index 11 namelen 32 name:
> \243\365@;\312\321\240\367\377\234_{\245\vW\
> \035\rS\222ryN\323\031g\243\nt3\321+
>      item 88 key (300 FSCRYPT_INODE_CTX 0) itemoff 7115 itemsize 40
>          value: 02010403000000005f0642cd89f66ce3ed930fe3ac518b7381bcd7600f7ae1f08195bda44461ed5d
>      item 89 key (300 EXTENT_DATA 0) itemoff 2998 itemsize 4117
>          generation 14 type 0 (inline)
>          inline extent data size 4096 ram_bytes 4096 compression 0 (none)
> ~~~
> 
> Perhaps this would better be folded into patch 7?
> 
> Or do you rather mean special-casing for compression (with the limits
> as you mentioned) and encryption (with full sector size allowed)?

In that case, I'd prefer the limit to be only loosen for encryption.

So we won't have unexpected non-encrypted inlined extents to reach the 
limit.

BTW, it would be great if the progs dump-tree also prints encryption 
value for the inlined extent.

Thanks,
Qu

> 
> --nX
> 
>>> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
>>> Signed-off-by: Daniel Vacek <neelx@suse.com>
>>> ---
>>>    check/main.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/check/main.c b/check/main.c
>>> index 5e29e2c5..dedb4db4 100644
>>> --- a/check/main.c
>>> +++ b/check/main.c
>>> @@ -1720,7 +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,
>>> +     u32 max_inline_size = min_t(u32, gfs_info->sectorsize,
>>>                                BTRFS_MAX_INLINE_DATA_SIZE(gfs_info));
>>>        u8 compression;
>>>        int extent_type;
>>
> 


  reply	other threads:[~2026-07-01 22:22 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24 16:51 [PATCH v2 0/8] btrfs-progs: fscrypt updates Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 1/8] btrfs-progs: check: fix max inline extent size Daniel Vacek
2026-06-25 23:40   ` Qu Wenruo
2026-07-01 15:47     ` Daniel Vacek
2026-07-01 22:22       ` Qu Wenruo [this message]
2026-07-02  5:34         ` Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 2/8] btrfs-progs: add new FEATURE_INCOMPAT_ENCRYPT flag Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 3/8] btrfs-progs: start tracking extent encryption context info Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 4/8] btrfs-progs: add inode encryption contexts Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 5/8] btrfs-progs: print encryptin type field of file extents Daniel Vacek
2026-06-25 23:50   ` Qu Wenruo
2026-07-01 15:59     ` Daniel Vacek
2026-07-01 22:26       ` Qu Wenruo
2026-07-02  5:40         ` Daniel Vacek
2026-07-02  6:19           ` Qu Wenruo
2026-07-02  6:48             ` Daniel Vacek
2026-07-02  6:56               ` Qu Wenruo
2026-07-02  7:05                 ` Daniel Vacek
2026-07-02  7:11                   ` Qu Wenruo
2026-07-02  7:18                     ` Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 6/8] btrfs-progs: handle fscrypt context items Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 7/8] btrfs-progs: check: update inline extent length checking Daniel Vacek
2026-06-24 16:51 ` [PATCH v2 8/8] btrfs-progs: recognize ENCRYPT inode item flag Daniel Vacek

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=2da4b215-165f-4bd6-a2da-07c9012586b7@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neelx@suse.com \
    --cc=wqu@suse.com \
    /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

all inboxes | Powered by JetHome®