Re: [PATCH] common/encrypt: support block sizes larger than the page size
From: Baokun Li
Date: Sun Nov 22 2026 - 22:39:30 EST
Hi Zorro,
Thank you for your review!
On 2026/11/22 01:04, Zorro Lang wrote:
> On Wed, Nov 04, 2026 at 12:09:06AM +0800, Baokun Li wrote:
>> + #
>> + # If the test requires a v2 policy, don't probe with a v1 policy:
>> + # v1 policies are not supported when the block size exceeds the page
>> + # size. _require_encryption_policy_support() will check for the
>> + # requested policy version below.
>> + if [ "$policy_version" -le 1 ]; then
>> + mkdir $SCRATCH_MNT/tmpdir
>> + if _set_encpolicy $SCRATCH_MNT/tmpdir 2>&1 >>$seqres.full | \
>> + grep -Eq 'Inappropriate ioctl for device|Operation not supported'
>> + then
>> + _notrun "kernel does not support $FSTYP encryption"
>> + fi
>> + rmdir $SCRATCH_MNT/tmpdir
>> +
>> + # v1 policies use the block size as their data unit size,
>> + # which doesn't work if the block size exceeds the page size.
>> + _require_v1_encryption_support
>
> How about do _require_v1_encryption_support at first:
>
> if [ "$policy_version" -le 1 ]; then
> _require_v1_encryption_support
> mkdir $SCRATCH_MNT/tmpdir
> if _set_encpolicy $SCRATCH_MNT/tmpdir 2>&1 >>$seqres.full | \
>
> In that case, if block_size > page_size, we can directly skip the test
> with an explicit reason, avoids a redundant mkdir/rmdir and ioctl call.
>
Yes, this can avoid some unnecessary operations.
>> # FS QA Test No. ext4/309
>> #
>> # Verify that file contents encryption works on a filesystem with a block size
>> -# larger than the page size. fscrypt uses the block size as the data unit size
>> -# by default, so this tests data units that span multiple pages, both for the
>> -# writeback path and for the on-disk ciphertext.
>> +# larger than the page size. fscrypt uses min(block size, page size) as the
>> +# default data unit size, so this tests 4K data units on a 32K-block
>
> Does ext4/309 hardcode 32k ?
>
No, that's actually just an example using a block size of 32k; I'll
rephrase that.
Additionally, the final plan has not been fully confirmed yet. I am
still working on the details with Eric. It is expected that all v1 use
cases will be converted to v2 later, and in the testing process, the
data unit size will be explicitly specified. Please refer to:
https://lore.kernel.org/r/20261104195127.GA1971@quark
Cheers,
Baokun