From: Baokun Li <libaokun@linux.alibaba.com>
To: linux-fscrypt@vger.kernel.org
Cc: ebiggers@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: [PATCH 0/4] ext4: support encryption with block size larger than page size
Date: Tue, 3 Nov 2026 23:31:28 +0800 [thread overview]
Message-ID: <20261103153132.4154855-1-libaokun@linux.alibaba.com> (raw)
Motivation
==========
Currently ext4 refuses encryption on a filesystem whose block size
is larger than page size. The reason is in the fallback path:
fscrypt takes the fs block size as the default data unit size,
while blk-crypto-fallback supports no data unit larger than a page.
fscrypt already supports a data unit size smaller than the block size.
So when none is specified, taking the smaller of the block size and the
page size as the data unit size is enough for fscrypt to support LBS.
Based on v7.4-rc1.
Patch Overview
==============
Patch 1: Caps the default data unit at the page size and rejects the
policies that would exceed it.
Patch 2: Validates the test_dummy_encryption policy before applying it.
Patch 3: Sends a folio that covers a DUN wraparound to the buffer_head
path.
Patch 4: Removes the block size > page size checks and enables large
folios for encrypted files.
Testing
=======
kvm-xfstests -c ext4/all -g auto has been executed with no new failures.
On ext4/32k, two groups of tests fail because they are not adapted, and
no other regressions were observed:
- the tests that use v1 policies: ext4/024, generic/395, 397, 398, 399,
419, 421, 429, 440, 576, 580, 581, 593, 613.
- the tests that don't explicitly set the data unit size (generic/582,
583, 584): the kernel gets a 4K data unit by default on a 4K-page
machine while the tests still use the block size.
With the xfstests fix, the first group is skipped and the second group
passes. The fix will be sent separately.
Benchmark
=========
Hardware: 96-core machine, 3.84T NVMe, 512G memory
Filesystem: ext4, encryption on the fallback path
Buffered sequential 1M writes and reads (1G, fsync) in MiB/s;
medians of 3 runs.
Base tree, 4k-block filesystem:
job 4k plain 4k enc
-------- -------- ------
seqwrite 1969 1418
seqread 1021 907
LBS enabled, encrypted 4k-block vs 32k-block filesystem:
job 4k enc 32k enc 32k plain 4k->32k
-------- ------ ------- --------- -------
seqwrite 1430 1958 2138 +37%
seqread 964 2004 1834 +108%
Buffered sequential writes (1G, fsync) of the encrypted 4k-block
filesystem across request sizes, base tree vs this series:
fio bs Before After gain
------ ------ ----- ----
4k 1272 1261 -1%
16k 1457 1803 +24%
64k 1499 2060 +37%
256k 1488 2103 +41%
1M 1418 1928 +36%
Comments and questions are, as always, welcome.
Thanks,
Baokun
Baokun Li (4):
fscrypt: Cap data units at the page size
fscrypt: Validate the test_dummy_encryption policy for new inodes
ext4: don't put a DUN wraparound in the middle of a read bio
ext4: allow large folios and bs > ps encryption
Documentation/filesystems/fscrypt.rst | 19 +++++++++++++++----
fs/crypto/fscrypt_private.h | 4 +++-
fs/crypto/keysetup.c | 8 ++++++++
fs/crypto/policy.c | 11 ++++++++++-
fs/ext4/crypto.c | 9 ---------
fs/ext4/inode.c | 6 ------
fs/ext4/readpage.c | 10 ++++++++++
fs/ext4/super.c | 22 +---------------------
8 files changed, 47 insertions(+), 42 deletions(-)
--
2.43.7
next reply other threads:[~2026-11-03 15:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 15:31 Baokun Li [this message]
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-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=20261103153132.4154855-1-libaokun@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®