From: Baokun Li <libaokun@linux.alibaba.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-fscrypt@vger.kernel.org, jaegeuk@kernel.org, tytso@mit.edu,
linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca,
jack@suse.cz, yi.zhang@huawei.com, ojaswin@linux.ibm.com,
ritesh.list@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] fscrypt: Cap data units at the page size
Date: Wed, 4 Nov 2026 10:31:46 +0800 [thread overview]
Message-ID: <922240f9-8233-4466-a787-2f7ddba7c490@linux.alibaba.com> (raw)
In-Reply-To: <20261103224006.GC2281@quark>
Hi Eric,
Thank you for your feedback.
On 2026/11/4 06:40, Eric Biggers wrote:
> On Tue, Nov 03, 2026 at 11:31:29PM +0800, Baokun Li wrote:
>> diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h
>> index e602c31b3844..0dc158563e71 100644
>> --- a/fs/crypto/fscrypt_private.h
>> +++ b/fs/crypto/fscrypt_private.h
>> @@ -203,7 +203,9 @@ static inline int
>> fscrypt_policy_v2_du_bits(const struct fscrypt_policy_v2 *policy,
>> const struct inode *inode)
>> {
>> - return policy->log2_data_unit_size ?: inode->i_blkbits;
>> + if (policy->log2_data_unit_size)
>> + return policy->log2_data_unit_size;
>> + return min_t(unsigned int, inode->i_blkbits, PAGE_SHIFT);
>> }
>
> This would make the interpretation of the default value
> log2_data_unit_size=0 depend on the page size, which (unlike i_blkbits)
> is not part of the filesystem's on-disk format.
This is indeed a point we struggled with before.
The problem is that on a filesystem with LBS enabled, once fscrypt is
enabled, log2_data_unit_size=0 causes data corruption. So we default
to a sub-block data unit size to avoid it.
In the previous discussion it was said that for cross-machine
compatibility, users would explicitly set a data unit size of 4K or
smaller. So this change did not consider cross-machine or cross-page-
size compatibility.
>
> I think that for a sub-block data unit size to be used, it should need
> to continue to be explicitly specified. Otherwise the default would
> become ambiguous.
This does change the semantics of the default value, and supporting a
data unit size larger than the page size later would be even worse.
What I had in mind before was to keep the default as min(bs, PS) and
allow DU > PS only when explicitly specified, which seemed to give
better compatibility. Cross-machine or cross-page-size cases seem
uncommon, and existing machines have probably already avoided them by
specifying a 4K or smaller DU.
Keeping the existing default semantics and returning an error in the
LBS case for the user to specify seems feasible. But then
test_dummy_encryption and the xfstests cases that use the default would
need to specify the DU explicitly, otherwise the LBS + encrypt test
coverage would drop a lot. That is, in the kernel or the tests we
always have to set a default DU size.
If you confirm that we should take the route where LBS requires an
explicit data unit size and the default is rejected, I can adapt the
kernel and xfstests in v2. Or should we go back to the more compatible
DU > page size approach?
Looking forward to hearing your thoughts.
Cheers,
Baokun
next prev parent reply other threads:[~2026-11-04 2:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 15:31 [PATCH 0/4] ext4: support encryption with block size larger than " Baokun Li
2026-11-03 15:31 ` [PATCH 1/4] fscrypt: Cap data units at the " Baokun Li
2026-11-03 22:40 ` Eric Biggers
2026-11-04 2:31 ` Baokun Li [this message]
2026-11-03 15:31 ` [PATCH 2/4] fscrypt: Validate the test_dummy_encryption policy for new inodes Baokun Li
2026-11-03 15:31 ` [PATCH 3/4] ext4: don't put a DUN wraparound in the middle of a read bio Baokun Li
2026-11-03 15:31 ` [PATCH 4/4] ext4: allow large folios and bs > ps encryption Baokun Li
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=922240f9-8233-4466-a787-2f7ddba7c490@linux.alibaba.com \
--to=libaokun@linux.alibaba.com \
--cc=adilger.kernel@dilger.ca \
--cc=ebiggers@kernel.org \
--cc=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.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®