Commit cf5e2ca6 authored by Ritesh Harjani's avatar Ritesh Harjani Committed by Theodore Ts'o

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: default avatarRitesh Harjani <riteshh@linux.ibm.com>
Link: https://lore.kernel.org/r/1cfae0098d2aa9afbeb59331401258182868c8f2.1589955723.git.riteshh@linux.ibm.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 53f86b17
...@@ -4543,6 +4543,17 @@ static int ext4_mb_discard_preallocations(struct super_block *sb, int needed) ...@@ -4543,6 +4543,17 @@ static int ext4_mb_discard_preallocations(struct super_block *sb, int needed)
return freed; return freed;
} }
static bool ext4_mb_discard_preallocations_should_retry(struct super_block *sb,
struct ext4_allocation_context *ac)
{
int freed;
freed = ext4_mb_discard_preallocations(sb, ac->ac_o_ex.fe_len);
if (freed)
return true;
return false;
}
/* /*
* Main entry point into mballoc to allocate blocks * Main entry point into mballoc to allocate blocks
* it tries to use preallocation first, then falls back * 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) ...@@ -4551,7 +4562,6 @@ static int ext4_mb_discard_preallocations(struct super_block *sb, int needed)
ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
struct ext4_allocation_request *ar, int *errp) struct ext4_allocation_request *ar, int *errp)
{ {
int freed;
struct ext4_allocation_context *ac = NULL; struct ext4_allocation_context *ac = NULL;
struct ext4_sb_info *sbi; struct ext4_sb_info *sbi;
struct super_block *sb; struct super_block *sb;
...@@ -4656,8 +4666,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, ...@@ -4656,8 +4666,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
ar->len = ac->ac_b_ex.fe_len; ar->len = ac->ac_b_ex.fe_len;
} }
} else { } else {
freed = ext4_mb_discard_preallocations(sb, ac->ac_o_ex.fe_len); if (ext4_mb_discard_preallocations_should_retry(sb, ac))
if (freed)
goto repeat; goto repeat;
/* /*
* If block allocation fails then the pa allocated above * If block allocation fails then the pa allocated above
......
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