@@ -3836,6 +3836,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
int err;
int busy = 0;
int free = 0;
+ int tried = 0;
mb_debug(1, "discard preallocation for group %u\n", group);
@@ -3886,9 +3887,11 @@ repeat:
list_add(&pa->u.pa_tmp_list, &list);
}
- /* if we still need more blocks and some PAs were used, try again */
- if (free < needed && busy) {
+ /* if we still need more blocks and some PAs were used, try again,
+ here 20 is a random value. */
+ if (free < needed && busy && tried < 20) {
busy = 0;
+ tried++;
ext4_unlock_group(sb, group);
cond_resched();
goto repeat;