Skip to content

Commit 6347558

Browse files
LiBaokun96tytso
authored andcommitted
ext4: refactor choose group to scan group
This commit converts the `choose group` logic to `scan group` using previously prepared helper functions. This allows us to leverage xarrays for ordered non-linear traversal, thereby mitigating the "bouncing" issue inherent in the `choose group` mechanism. This also decouples linear and non-linear traversals, leading to cleaner and more readable code. Key changes: * ext4_mb_choose_next_group() is refactored to ext4_mb_scan_groups(). * Replaced ext4_mb_good_group() with ext4_mb_scan_group() in non-linear traversals, and related functions now return error codes instead of group info. * Added ext4_mb_scan_groups_linear() for performing linear scans starting from a specific group for a set number of times. * Linear scans now execute up to sbi->s_mb_max_linear_groups times, so ac_groups_linear_remaining is removed as it's no longer used. * ac->ac_criteria is now used directly instead of passing cr around. Also, ac->ac_criteria is incremented directly after groups scan fails for the corresponding criteria. * Since we're now directly scanning groups instead of finding a good group then scanning, the following variables and flags are no longer needed, s_bal_cX_groups_considered is sufficient. s_bal_p2_aligned_bad_suggestions s_bal_goal_fast_bad_suggestions s_bal_best_avail_bad_suggestions EXT4_MB_CR_POWER2_ALIGNED_OPTIMIZED EXT4_MB_CR_GOAL_LEN_FAST_OPTIMIZED EXT4_MB_CR_BEST_AVAIL_LEN_OPTIMIZED Signed-off-by: Baokun Li <[email protected]> Reviewed-by: Zhang Yi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent f7eaacb commit 6347558

File tree

3 files changed

+131
-174
lines changed

3 files changed

+131
-174
lines changed

fs/ext4/ext4.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,6 @@ enum criteria {
207207
#define EXT4_MB_USE_RESERVED 0x2000
208208
/* Do strict check for free blocks while retrying block allocation */
209209
#define EXT4_MB_STRICT_CHECK 0x4000
210-
/* Large fragment size list lookup succeeded at least once for
211-
* CR_POWER2_ALIGNED */
212-
#define EXT4_MB_CR_POWER2_ALIGNED_OPTIMIZED 0x8000
213-
/* Avg fragment size rb tree lookup succeeded at least once for
214-
* CR_GOAL_LEN_FAST */
215-
#define EXT4_MB_CR_GOAL_LEN_FAST_OPTIMIZED 0x00010000
216-
/* Avg fragment size rb tree lookup succeeded at least once for
217-
* CR_BEST_AVAIL_LEN */
218-
#define EXT4_MB_CR_BEST_AVAIL_LEN_OPTIMIZED 0x00020000
219210

220211
struct ext4_allocation_request {
221212
/* target inode for block we're allocating */
@@ -1643,9 +1634,6 @@ struct ext4_sb_info {
16431634
atomic_t s_bal_len_goals; /* len goal hits */
16441635
atomic_t s_bal_breaks; /* too long searches */
16451636
atomic_t s_bal_2orders; /* 2^order hits */
1646-
atomic_t s_bal_p2_aligned_bad_suggestions;
1647-
atomic_t s_bal_goal_fast_bad_suggestions;
1648-
atomic_t s_bal_best_avail_bad_suggestions;
16491637
atomic64_t s_bal_cX_groups_considered[EXT4_MB_NUM_CRS];
16501638
atomic64_t s_bal_cX_hits[EXT4_MB_NUM_CRS];
16511639
atomic64_t s_bal_cX_failed[EXT4_MB_NUM_CRS]; /* cX loop didn't find blocks */

0 commit comments

Comments
 (0)