提交 68fd9750 编写于 作者: T Theodore Ts'o

ext4: retry allocations conservatively

Now that we no longer try to reserve metadata blocks for delayed
allocations (which tended to overestimate the required number of
blocks significantly), we really don't need retry allocations when the
disk is very full as aggressively any more.

The only time when it makes sense to retry an allocation is if we have
freshly deleted blocks that will only become available after a
transaction commit.  And if we lose that race, it's not worth it to
try more than once.
Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
上级 545052e9
...@@ -600,22 +600,21 @@ int ext4_claim_free_clusters(struct ext4_sb_info *sbi, ...@@ -600,22 +600,21 @@ int ext4_claim_free_clusters(struct ext4_sb_info *sbi,
* ext4_should_retry_alloc() is called when ENOSPC is returned, and if * ext4_should_retry_alloc() is called when ENOSPC is returned, and if
* it is profitable to retry the operation, this function will wait * it is profitable to retry the operation, this function will wait
* for the current or committing transaction to complete, and then * for the current or committing transaction to complete, and then
* return TRUE. * return TRUE. We will only retry once.
*
* if the total number of retries exceed three times, return FALSE.
*/ */
int ext4_should_retry_alloc(struct super_block *sb, int *retries) int ext4_should_retry_alloc(struct super_block *sb, int *retries)
{ {
if (!ext4_has_free_clusters(EXT4_SB(sb), 1, 0) || if (!ext4_has_free_clusters(EXT4_SB(sb), 1, 0) ||
(*retries)++ > 3 || (*retries)++ > 1 ||
!EXT4_SB(sb)->s_journal) !EXT4_SB(sb)->s_journal)
return 0; return 0;
jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
smp_mb(); smp_mb();
if (EXT4_SB(sb)->s_mb_free_pending) if (EXT4_SB(sb)->s_mb_free_pending == 0)
jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal); return 0;
jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal);
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册