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 --- 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