From: Baokun Li <libaokun@linux.alibaba.com>
To: linux-ext4@vger.kernel.org
Cc: linux-fscrypt@vger.kernel.org, linux-block@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
ebiggers@kernel.org, jaegeuk@kernel.org, axboe@kernel.dk,
hch@lst.de, djwong@kernel.org, brauner@kernel.org, tytso@mit.edu,
berto@igalia.com, adilger.kernel@dilger.ca, jack@suse.cz,
yi.zhang@huawei.com, ojaswin@linux.ibm.com,
ritesh.list@gmail.com
Subject: [PATCH 11/13] ext4: allow encryption with a block size larger than the page size
Date: Mon, 12 Oct 2026 01:09:56 +0800 [thread overview]
Message-ID: <20261011170958.1759230-12-libaokun@linux.alibaba.com> (raw)
In-Reply-To: <20261011170958.1759230-1-libaokun@linux.alibaba.com>
ext4 refuses encryption when the block size is larger than the page
size, both at mount time and on a mounted filesystem, and refuses to
load an existing encrypted inode. The checks exist because such a
block size needs folios that cover a whole block, while file contents
were encrypted page by page in the fs-layer path, which cannot handle a
folio that covers several data units.
Since commit 5acc6f649a68 ("fscrypt: Always use blk-crypto for contents
on block-based filesystems") file contents are always encrypted through
blk-crypto, and after the adaptations in the preceding patches, both
inline encryption hardware and blk-crypto-fallback support data units
larger than a page, so the checks can be removed.
Encrypted filesystems still keep their folio order at s_min_folio_order;
allowing large folios needs additional work and will be enabled later.
Performance:
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.
job 4k plain 4k enc 32k plain 32k enc 4k->32k
--------- -------- -------- --------- ------- -------
seqwrite 1981 1044 2062 1399 +34%
seqread 1139 931 1791 1793 +93%
Signed-off-by: Baokun Li <libaokun@linux.alibaba.com>
---
fs/ext4/crypto.c | 9 ---------
fs/ext4/inode.c | 6 ------
fs/ext4/super.c | 25 +++----------------------
3 files changed, 3 insertions(+), 37 deletions(-)
diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c
index 318b2eaea741..1a0fccb084ef 100644
--- a/fs/ext4/crypto.c
+++ b/fs/ext4/crypto.c
@@ -156,15 +156,6 @@ static int ext4_set_context(struct inode *inode, const void *ctx, size_t len,
if (ext4_test_inode_flag(inode, EXT4_INODE_DAX))
return -EOPNOTSUPP;
- /*
- * Encryption is not supported when the block size is larger
- * than the page size. This is rejected at mount time by
- * ext4_check_large_folio(), and this check here is for the case
- * when the 'encrypt' feature is enabled on a mounted filesystem.
- */
- if (inode->i_sb->s_blocksize > PAGE_SIZE)
- return -EOPNOTSUPP;
-
res = ext4_convert_inline_data(inode);
if (res)
return res;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 31248fef8bce..26f0f9714f03 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5671,12 +5671,6 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
ret = -EFSCORRUPTED;
goto bad_inode;
}
- if (IS_ENCRYPTED(inode) && sb->s_blocksize > PAGE_SIZE) {
- ext4_error_inode(inode, function, line, 0,
- "encrypted inode with block size larger than page size");
- ret = -EFSCORRUPTED;
- goto bad_inode;
- }
ext4_set_inode_mapping_order(inode);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index bca0dc87d0b7..9cd5b7445a27 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5116,30 +5116,13 @@ static void ext4_set_max_mapping_order(struct super_block *sb)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
- if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
+ if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
+ ext4_has_feature_encrypt(sb))
sbi->s_max_folio_order = sbi->s_min_folio_order;
else
sbi->s_max_folio_order = EXT4_MAX_PAGECACHE_ORDER(sb);
}
-static int ext4_check_large_folio(struct super_block *sb)
-{
- const char *err_str = NULL;
-
- if (ext4_has_feature_encrypt(sb))
- err_str = "encrypt";
-
- if (!err_str) {
- ext4_set_max_mapping_order(sb);
- } else if (sb->s_blocksize > PAGE_SIZE) {
- ext4_msg(sb, KERN_ERR, "bs(%lu) > ps(%lu) unsupported for %s",
- sb->s_blocksize, PAGE_SIZE, err_str);
- return -EINVAL;
- }
-
- return 0;
-}
-
static int ext4_load_super(struct super_block *sb, ext4_fsblk_t *lsb,
int silent)
{
@@ -5418,9 +5401,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
ext4_apply_options(fc, sb);
- err = ext4_check_large_folio(sb);
- if (err < 0)
- goto failed_mount;
+ ext4_set_max_mapping_order(sb);
err = ext4_encoding_init(sb, es);
if (err)
--
2.43.7
next prev parent reply other threads:[~2026-10-11 17:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 17:09 [PATCH 00/13] block, ext4: allow encryption with a block size larger than the page size Baokun Li
2026-10-11 17:09 ` [PATCH 01/13] ext4: refuse encryption when block size > " Baokun Li
2026-10-11 17:09 ` [PATCH 02/13] ext4: reject encrypted inodes " Baokun Li
2026-10-11 17:09 ` [PATCH 03/13] blk-crypto: reject fallback data unit sizes it can't handle Baokun Li
[not found] ` <sashiko-outbox-167341@kernel.org>
2026-10-12 7:50 ` Baokun Li
2026-10-11 17:09 ` [PATCH 04/13] blk-crypto: decrypt one data unit per crypto request Baokun Li
2026-10-11 17:09 ` [PATCH 05/13] blk-crypto: encrypt " Baokun Li
2026-10-11 17:09 ` [PATCH 06/13] blk-crypto: support data units larger than a page Baokun Li
2026-10-11 17:09 ` [PATCH 07/13] iomap: align the direct I/O bios of encrypted files to the block size Baokun Li
2026-10-11 17:09 ` [PATCH 08/13] block: split encrypted bios at data unit boundaries Baokun Li
2026-10-11 17:09 ` [PATCH 09/13] block: warn about bios that can't be split Baokun Li
2026-10-11 17:09 ` [PATCH 10/13] block: don't require data unit aligned bio_vecs for encrypted bios Baokun Li
[not found] ` <sashiko-outbox-167346@kernel.org>
2026-10-12 8:09 ` Baokun Li
2026-10-11 17:09 ` Baokun Li [this message]
2026-10-11 17:09 ` [PATCH 12/13] ext4: send folios that cover a wraparound to the buffer_head path Baokun Li
2026-10-11 17:09 ` [PATCH 13/13] ext4: allow large folios for encrypted files 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=20261011170958.1759230-12-libaokun@linux.alibaba.com \
--to=libaokun@linux.alibaba.com \
--cc=adilger.kernel@dilger.ca \
--cc=axboe@kernel.dk \
--cc=berto@igalia.com \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=ebiggers@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@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