Skip to contentSkip to conversation

ext4: Use optimized mballoc scanning regardless of inode format

PATCH Superseded Jan Kara 2 participants 3 messages Jan 8 – Jan 9 ext4 file system

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 ext4: Use optimized mballoc scanning regardless of inode format

Currently we don't used mballoc optimized scanning (using max free extent order and avg free extent order group lists) for inodes with indirect block based format. This is confusing for users and I don't see a good reason for that. Even with indirect block based inode format we can spend big amount of time searching for free blocks for large filesystems with fragmented free space. To add to the confusion before commit 077d0c2c78df ("ext4: make mb_optimize_scan performance mount option work with extents") optimized scanning was applied *only* to indirect block based inodes so that commit appears as a performance regression to some users. Just use optimized scanning whenever it is enabled by mount options.

---
 fs/ext4/mballoc.c | 2 --
 1 file changed, 2 deletions(-)
fs/ext4/mballoc.c +0 -2
index 56d50fd3310b..4ee7ab4ce86e 100644
@@ -1133,8 +1133,6 @@ static inline int should_optimize_scan(struct ext4_allocation_context *ac)
 		return 0;
 	if (ac->ac_criteria >= CR_GOAL_LEN_SLOW)
 		return 0;
-	if (!ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS))
-		return 0;
 	return 1;
 }
 
Signature · 1 line
2.51.0
#1 lore raw
Quoted 12 lines · Jan Kara

Currently we don't used mballoc optimized scanning (using max free extent order and avg free extent order group lists) for inodes with indirect block based format. This is confusing for users and I don't see a good reason for that. Even with indirect block based inode format we can spend big amount of time searching for free blocks for large filesystems with fragmented free space. To add to the confusion before commit 077d0c2c78df ("ext4: make mb_optimize_scan performance mount option work with extents") optimized scanning was applied *only* to indirect block based inodes so that commit appears as a performance regression to some users. Just use optimized scanning whenever it is enabled by mount options.

Quoted 1 line

Makes sense. Block allocation should not be tied to the inode format, and we should remove this restriction.

However, inodes with the indirect block based format only support 32-bit physical block numbers. We already check the maximum supported block group in ext4_mb_scan_groups_linear, but we don’t perform the same check in ext4_mb_scan_groups_xa_range.

So if we want to drop this restriction, we need to specify the appropriate end value for inodes using the indirect block based format in ext4_mb_scan_groups_xa_range; otherwise, an overflow could occur and lead to corrupted block allocation.

Regards,
Baokun

Quoted 17 lines
---
 fs/ext4/mballoc.c | 2 --
 1 file changed, 2 deletions(-)
fs/ext4/mballoc.c +0 -2
index 56d50fd3310b..4ee7ab4ce86e 100644
@@ -1133,8 +1133,6 @@ static inline int should_optimize_scan(struct ext4_allocation_context *ac)
 		return 0;
 	if (ac->ac_criteria >= CR_GOAL_LEN_SLOW)
 		return 0;
-	if (!ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS))
-		return 0;
 	return 1;
 }
 
author reviewer
#2 lore raw
Quoted 23 lines · Baokun Li
Quoted 12 lines · Jan Kara

Currently we don't used mballoc optimized scanning (using max free extent order and avg free extent order group lists) for inodes with indirect block based format. This is confusing for users and I don't see a good reason for that. Even with indirect block based inode format we can spend big amount of time searching for free blocks for large filesystems with fragmented free space. To add to the confusion before commit 077d0c2c78df ("ext4: make mb_optimize_scan performance mount option work with extents") optimized scanning was applied *only* to indirect block based inodes so that commit appears as a performance regression to some users. Just use optimized scanning whenever it is enabled by mount options.

Quoted 1 line

Makes sense. Block allocation should not be tied to the inode format, and we should remove this restriction.

However, inodes with the indirect block based format only support 32-bit physical block numbers. We already check the maximum supported block group in ext4_mb_scan_groups_linear, but we don’t perform the same check in ext4_mb_scan_groups_xa_range.

Quoted 4 lines

So if we want to drop this restriction, we need to specify the appropriate end value for inodes using the indirect block based format in ext4_mb_scan_groups_xa_range; otherwise, an overflow could occur and lead to corrupted block allocation.

Good point. I'll fix that up and send v2. Thanks for review!

Honza

Quoted 24 lines

Regards,
Baokun

Quoted 17 lines
---
 fs/ext4/mballoc.c | 2 --
 1 file changed, 2 deletions(-)
fs/ext4/mballoc.c +0 -2
index 56d50fd3310b..4ee7ab4ce86e 100644
@@ -1133,8 +1133,6 @@ static inline int should_optimize_scan(struct ext4_allocation_context *ac)
 		return 0;
 	if (ac->ac_criteria >= CR_GOAL_LEN_SLOW)
 		return 0;
-	if (!ext4_test_inode_flag(ac->ac_inode, EXT4_INODE_EXTENTS))
-		return 0;
 	return 1;
 }
 
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR