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 4/4] ext4: allow large folios and bs > ps encryption
Date: Tue, 3 Nov 2026 23:31:32 +0800 [thread overview]
Message-ID: <20261103153132.4154855-5-libaokun@linux.alibaba.com> (raw)
In-Reply-To: <20261103153132.4154855-1-libaokun@linux.alibaba.com>
ext4 refuses encryption when the block size exceeds the page size
in three places: at mount time (ext4_check_large_folio()),
in ext4_set_context(), and in __ext4_iget().
Sub-block data units are now enabled by default, so encryption
works on a filesystem whose block size exceeds the page size.
Remove the three checks; stable trees should keep them and
not backport this feature.
ext4_set_max_mapping_order() now runs on every mount, and
the preceding patch routes a folio that crosses a DUN wraparound
to the buffer_head path. Encrypted files therefore get the same
large folio orders as unencrypted files, including when block size
is larger than page size.
Signed-off-by: Baokun Li <libaokun@linux.alibaba.com>
---
fs/ext4/crypto.c | 9 ---------
fs/ext4/inode.c | 6 ------
fs/ext4/super.c | 22 +---------------------
3 files changed, 1 insertion(+), 36 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 10cd85d4c721..b4d581aa5ee1 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -6571,12 +6571,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 9cae52471dee..ba2d2e184d3a 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5165,24 +5165,6 @@ static void ext4_set_max_mapping_order(struct super_block *sb)
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)
{
@@ -5461,9 +5443,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
prev parent 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 [PATCH 0/4] ext4: support encryption with block size larger than page size 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-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 ` Baokun Li [this message]
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-5-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®