Fix up descriptions.
[ext4-patch-queue.git] / retry-allocations-conservatively
blob33dc319f635b264f53473fbe6d18420510262e8b
1 ext4: retry allocations conservatively
3 Now that we no longer try to reserve metadata blocks for delayed
4 allocations (which tended to overestimate the required number of
5 blocks significantly), we really don't need retry allocations when the
6 disk is very full as aggressively any more.
8 The only time when it makes sense to retry an allocation is if we have
9 freshly deleted blocks that will only become available after a
10 transaction commit.  And if we lose that race, it's not worth it to
11 try more than once.
13 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
14 ---
15  fs/ext4/balloc.c | 15 +++++++--------
16  1 file changed, 7 insertions(+), 8 deletions(-)
18 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
19 index e04ec868e37e..a3798b25a8dc 100644
20 --- a/fs/ext4/balloc.c
21 +++ b/fs/ext4/balloc.c
22 @@ -600,22 +600,21 @@ int ext4_claim_free_clusters(struct ext4_sb_info *sbi,
23   * ext4_should_retry_alloc() is called when ENOSPC is returned, and if
24   * it is profitable to retry the operation, this function will wait
25   * for the current or committing transaction to complete, and then
26 - * return TRUE.
27 - *
28 - * if the total number of retries exceed three times, return FALSE.
29 + * return TRUE.  We will only retry once.
30   */
31  int ext4_should_retry_alloc(struct super_block *sb, int *retries)
32  {
33         if (!ext4_has_free_clusters(EXT4_SB(sb), 1, 0) ||
34 -           (*retries)++ > 3 ||
35 +           (*retries)++ > 1 ||
36             !EXT4_SB(sb)->s_journal)
37                 return 0;
39 -       jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
41         smp_mb();
42 -       if (EXT4_SB(sb)->s_mb_free_pending)
43 -               jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal);
44 +       if (EXT4_SB(sb)->s_mb_free_pending == 0)
45 +               return 0;
47 +       jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
48 +       jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal);
49         return 1;
50  }