diff mbox series

[v2,22/24] ext4: support verifying data from large folios with fs-verity

Message ID 20251107144249.435029-23-libaokun@huaweicloud.com
State Superseded
Headers show
Series ext4: enable block size larger than page size | expand

Commit Message

Baokun Li Nov. 7, 2025, 2:42 p.m. UTC
From: Baokun Li <libaokun1@huawei.com>

Eric Biggers already added support for verifying data from large folios
several years ago in commit 5d0f0e57ed90 ("fsverity: support verifying
data from large folios").

With ext4 now supporting large block sizes, the fs-verity tests
`kvm-xfstests -c ext4/64k -g verity -x encrypt` pass without issues.

Therefore, remove the restriction and allow LBS to be enabled together
with fs-verity.

Cc: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
 fs/ext4/inode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Jan Kara Nov. 10, 2025, 9:54 a.m. UTC | #1
On Fri 07-11-25 22:42:47, libaokun@huaweicloud.com wrote:
> From: Baokun Li <libaokun1@huawei.com>
> 
> Eric Biggers already added support for verifying data from large folios
> several years ago in commit 5d0f0e57ed90 ("fsverity: support verifying
> data from large folios").
> 
> With ext4 now supporting large block sizes, the fs-verity tests
> `kvm-xfstests -c ext4/64k -g verity -x encrypt` pass without issues.
> 
> Therefore, remove the restriction and allow LBS to be enabled together
> with fs-verity.
> 
> Cc: Eric Biggers <ebiggers@kernel.org>
> Signed-off-by: Baokun Li <libaokun1@huawei.com>

Nice!

> @@ -5175,7 +5173,8 @@ void ext4_set_inode_mapping_order(struct inode *inode)
>  		return;
>  
>  	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
> -	    ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA))
> +	    ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA) ||
> +	    ext4_has_feature_verity(inode->i_sb))
>  		max_order = EXT4_SB(inode->i_sb)->s_min_folio_order;
>  	else
>  		max_order = EXT4_MAX_PAGECACHE_ORDER(inode);

Is there a reason why fsverity needs the folio order to match the block
size? I didn't find any by a quick glance. If yes, please state it in
the changelog. If no, then I'd just use EXT4_MAX_PAGECACHE_ORDER() because
it will give us some performance e.g. for mmapped executables protected by
fsverify...

								Honza
Baokun Li Nov. 10, 2025, 12:08 p.m. UTC | #2
On 2025-11-10 17:54, Jan Kara wrote:
> On Fri 07-11-25 22:42:47, libaokun@huaweicloud.com wrote:
>> From: Baokun Li <libaokun1@huawei.com>
>>
>> Eric Biggers already added support for verifying data from large folios
>> several years ago in commit 5d0f0e57ed90 ("fsverity: support verifying
>> data from large folios").
>>
>> With ext4 now supporting large block sizes, the fs-verity tests
>> `kvm-xfstests -c ext4/64k -g verity -x encrypt` pass without issues.
>>
>> Therefore, remove the restriction and allow LBS to be enabled together
>> with fs-verity.
>>
>> Cc: Eric Biggers <ebiggers@kernel.org>
>> Signed-off-by: Baokun Li <libaokun1@huawei.com>
> Nice!
>
>> @@ -5175,7 +5173,8 @@ void ext4_set_inode_mapping_order(struct inode *inode)
>>  		return;
>>  
>>  	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
>> -	    ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA))
>> +	    ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA) ||
>> +	    ext4_has_feature_verity(inode->i_sb))
>>  		max_order = EXT4_SB(inode->i_sb)->s_min_folio_order;
>>  	else
>>  		max_order = EXT4_MAX_PAGECACHE_ORDER(inode);
> Is there a reason why fsverity needs the folio order to match the block
> size? I didn't find any by a quick glance. If yes, please state it in
> the changelog. If no, then I'd just use EXT4_MAX_PAGECACHE_ORDER() because
> it will give us some performance e.g. for mmapped executables protected by
> fsverify...
>
> 								Honza
>
There is no real limitation that prevents verity from using
EXT4_MAX_PAGECACHE_ORDER(). The reason I did not enable it by default
is that none of the filesystems supporting fs-verity had large folios
support at the time, and thus fs-verity with large folios has not yet
been tested in practice. For this reason, I only enabled it when LBS
is turned on.

As you pointed out, turning it on gives some performance gains. And
it also lets fs-verity get more testing. I’ll switch to
EXT4_MAX_PAGECACHE_ORDER(inode) in the next version.

Thank you for your review!


Cheers,
Baokun
diff mbox series

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 517701024d18..b95826e4a419 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -5152,8 +5152,6 @@  static bool ext4_should_enable_large_folio(struct inode *inode)
 
 	if (!S_ISREG(inode->i_mode))
 		return false;
-	if (ext4_has_feature_verity(sb))
-		return false;
 	if (ext4_has_feature_encrypt(sb))
 		return false;
 
@@ -5175,7 +5173,8 @@  void ext4_set_inode_mapping_order(struct inode *inode)
 		return;
 
 	if (test_opt(inode->i_sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA ||
-	    ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA))
+	    ext4_test_inode_flag(inode, EXT4_INODE_JOURNAL_DATA) ||
+	    ext4_has_feature_verity(inode->i_sb))
 		max_order = EXT4_SB(inode->i_sb)->s_min_folio_order;
 	else
 		max_order = EXT4_MAX_PAGECACHE_ORDER(inode);