Skip to content

Commit cf5e2ca

Browse files
riteshharjanitytso
authored andcommitted
ext4: mballoc: refactor ext4_mb_discard_preallocations()
Implement ext4_mb_discard_preallocations_should_retry() which we will need in later patches to add more logic like check for sequence number match to see if we should retry for block allocation or not. There should be no functionality change in this patch. Signed-off-by: Ritesh Harjani <[email protected]> Link: https://lore.kernel.org/r/1cfae0098d2aa9afbeb59331401258182868c8f2.1589955723.git.riteshh@linux.ibm.com Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 53f86b1 commit cf5e2ca

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

fs/ext4/mballoc.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4543,6 +4543,17 @@ static int ext4_mb_discard_preallocations(struct super_block *sb, int needed)
45434543
return freed;
45444544
}
45454545

4546+
static bool ext4_mb_discard_preallocations_should_retry(struct super_block *sb,
4547+
struct ext4_allocation_context *ac)
4548+
{
4549+
int freed;
4550+
4551+
freed = ext4_mb_discard_preallocations(sb, ac->ac_o_ex.fe_len);
4552+
if (freed)
4553+
return true;
4554+
return false;
4555+
}
4556+
45464557
/*
45474558
* Main entry point into mballoc to allocate blocks
45484559
* it tries to use preallocation first, then falls back
@@ -4551,7 +4562,6 @@ static int ext4_mb_discard_preallocations(struct super_block *sb, int needed)
45514562
ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
45524563
struct ext4_allocation_request *ar, int *errp)
45534564
{
4554-
int freed;
45554565
struct ext4_allocation_context *ac = NULL;
45564566
struct ext4_sb_info *sbi;
45574567
struct super_block *sb;
@@ -4656,8 +4666,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
46564666
ar->len = ac->ac_b_ex.fe_len;
46574667
}
46584668
} else {
4659-
freed = ext4_mb_discard_preallocations(sb, ac->ac_o_ex.fe_len);
4660-
if (freed)
4669+
if (ext4_mb_discard_preallocations_should_retry(sb, ac))
46614670
goto repeat;
46624671
/*
46634672
* If block allocation fails then the pa allocated above

0 commit comments

Comments
 (0)