From 2e779249c50c7fbc3b9da711a468313be03e40bf Mon Sep 17 00:00:00 2001 From: Curt Wohlgemuth Date: Tue, 8 Dec 2009 22:18:25 -0500 Subject: [PATCH] --- yaml --- r: 174399 b: refs/heads/master c: b844167edc7fcafda9623955c05e4c1b3c32ebc7 h: refs/heads/master i: 174397: b85ce38f506866b9fc6dbff4830ce0be3bab3bf5 174395: 9ee969463f068c055d4fad8a8986b417d9a5c87b 174391: 923a62c1528763dd9bf5947558a3c20479c24b06 174383: aabdc8ed634869a89414585cb37b8e84d7896bb8 174367: 4b6b959a72be196b1357e2a6e224dfc5da172f66 174335: 5270c6562ef6f8d3975bd5480dd563e724317842 v: v3 --- [refs] | 2 +- trunk/fs/ext4/mballoc.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 4a81b5c63bfb..69ac9fccc6f0 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d4edac314e9ad0b21ba20ba8bc61b61f186f79e1 +refs/heads/master: b844167edc7fcafda9623955c05e4c1b3c32ebc7 diff --git a/trunk/fs/ext4/mballoc.c b/trunk/fs/ext4/mballoc.c index ab2dad1dfb7e..19635c341994 100644 --- a/trunk/fs/ext4/mballoc.c +++ b/trunk/fs/ext4/mballoc.c @@ -3010,6 +3010,24 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac) trace_ext4_mballoc_prealloc(ac); } +/* + * Called on failure; free up any blocks from the inode PA for this + * context. We don't need this for MB_GROUP_PA because we only change + * pa_free in ext4_mb_release_context(), but on failure, we've already + * zeroed out ac->ac_b_ex.fe_len, so group_pa->pa_free is not changed. + */ +static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac) +{ + struct ext4_prealloc_space *pa = ac->ac_pa; + int len; + + if (pa && pa->pa_type == MB_INODE_PA) { + len = ac->ac_b_ex.fe_len; + pa->pa_free += len; + } + +} + /* * use blocks preallocated to inode */ @@ -4295,6 +4313,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, ac->ac_status = AC_STATUS_CONTINUE; goto repeat; } else if (*errp) { + ext4_discard_allocated_blocks(ac); ac->ac_b_ex.fe_len = 0; ar->len = 0; ext4_mb_show_ac(ac);