diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index ad78bddfb637..110473e66286 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -5539,6 +5539,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, ext4_fsblk_t block = 0; unsigned int inquota = 0; unsigned int reserv_clstrs = 0; + int retries = 0; u64 seq; might_sleep(); @@ -5641,7 +5642,8 @@ repeat: ar->len = ac->ac_b_ex.fe_len; } } else { - if (ext4_mb_discard_preallocations_should_retry(sb, ac, &seq)) + if (++retries < 3 && + ext4_mb_discard_preallocations_should_retry(sb, ac, &seq)) goto repeat; /* * If block allocation fails then the pa allocated above