Commit 304749c0 authored by Ojaswin Mujoo's avatar Ojaswin Mujoo Committed by Theodore Ts'o

ext4: replace CR_FAST macro with inline function for readability

Replace CR_FAST with ext4_mb_cr_expensive() inline function for better
readability. This function returns true if the criteria is one of the
expensive/slower ones where lots of disk IO/prefetching is acceptable.

No functional changes are intended in this patch.
Signed-off-by: default avatarOjaswin Mujoo <ojaswin@linux.ibm.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Reviewed-by: default avatarRitesh Harjani (IBM) <ritesh.list@gmail.com>
Link: https://lore.kernel.org/r/20230630085927.140137-1-ojaswin@linux.ibm.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 1e1566b9
...@@ -176,9 +176,6 @@ enum criteria { ...@@ -176,9 +176,6 @@ enum criteria {
EXT4_MB_NUM_CRS EXT4_MB_NUM_CRS
}; };
/* criteria below which we use fast block scanning and avoid unnecessary IO */
#define CR_FAST CR_GOAL_LEN_SLOW
/* /*
* Flags used in mballoc's allocation_context flags field. * Flags used in mballoc's allocation_context flags field.
* *
...@@ -2924,6 +2921,10 @@ extern int ext4_trim_fs(struct super_block *, struct fstrim_range *); ...@@ -2924,6 +2921,10 @@ extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
extern void ext4_process_freed_data(struct super_block *sb, tid_t commit_tid); extern void ext4_process_freed_data(struct super_block *sb, tid_t commit_tid);
extern void ext4_mb_mark_bb(struct super_block *sb, ext4_fsblk_t block, extern void ext4_mb_mark_bb(struct super_block *sb, ext4_fsblk_t block,
int len, int state); int len, int state);
static inline bool ext4_mb_cr_expensive(enum criteria cr)
{
return cr >= CR_GOAL_LEN_SLOW;
}
/* inode.c */ /* inode.c */
void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw, void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw,
......
...@@ -2450,7 +2450,7 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac, ...@@ -2450,7 +2450,7 @@ void ext4_mb_complex_scan_group(struct ext4_allocation_context *ac,
break; break;
} }
if (ac->ac_criteria < CR_FAST) { if (!ext4_mb_cr_expensive(ac->ac_criteria)) {
/* /*
* In CR_GOAL_LEN_FAST and CR_BEST_AVAIL_LEN, we are * In CR_GOAL_LEN_FAST and CR_BEST_AVAIL_LEN, we are
* sure that this group will have a large enough * sure that this group will have a large enough
...@@ -2634,7 +2634,12 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac, ...@@ -2634,7 +2634,12 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac,
free = grp->bb_free; free = grp->bb_free;
if (free == 0) if (free == 0)
goto out; goto out;
if (cr <= CR_FAST && free < ac->ac_g_ex.fe_len) /*
* In all criterias except CR_ANY_FREE we try to avoid groups that
* can't possibly satisfy the full goal request due to insufficient
* free blocks.
*/
if (cr < CR_ANY_FREE && free < ac->ac_g_ex.fe_len)
goto out; goto out;
if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp))) if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp)))
goto out; goto out;
...@@ -2658,7 +2663,7 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac, ...@@ -2658,7 +2663,7 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac,
* sure we locate metadata blocks in the first block group in * sure we locate metadata blocks in the first block group in
* the flex_bg if possible. * the flex_bg if possible.
*/ */
if (cr < CR_FAST && if (!ext4_mb_cr_expensive(cr) &&
(!sbi->s_log_groups_per_flex || (!sbi->s_log_groups_per_flex ||
((group & ((1 << sbi->s_log_groups_per_flex) - 1)) != 0)) && ((group & ((1 << sbi->s_log_groups_per_flex) - 1)) != 0)) &&
!(ext4_has_group_desc_csum(sb) && !(ext4_has_group_desc_csum(sb) &&
...@@ -2852,7 +2857,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac) ...@@ -2852,7 +2857,7 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
* spend a lot of time loading imperfect groups * spend a lot of time loading imperfect groups
*/ */
if ((prefetch_grp == group) && if ((prefetch_grp == group) &&
(cr >= CR_FAST || (ext4_mb_cr_expensive(cr) ||
prefetch_ios < sbi->s_mb_prefetch_limit)) { prefetch_ios < sbi->s_mb_prefetch_limit)) {
nr = sbi->s_mb_prefetch; nr = sbi->s_mb_prefetch;
if (ext4_has_feature_flex_bg(sb)) { if (ext4_has_feature_flex_bg(sb)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment