diff options
author | Shen Feng <shen@cn.fujitsu.com> | 2008-07-11 19:27:31 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-07-11 19:27:31 -0400 |
commit | 363d4251d4bd984c304e0989789f6494343660fd (patch) | |
tree | 01a697f77e1e486b7f7972f4cbe27b71fca911eb /fs/ext4/mballoc.c | |
parent | f9a8ac99fd79eb961a8573ccf058439bc17b4d3a (diff) |
ext4: remove quota allocation when ext4_mb_new_blocks fails
Quota allocation is not removed when ext4_mb_new_blocks calls
kmem_cache_alloc failed. Also make sure the allocation context is freed
on the error path.
Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 5dcb826401bb..cde232bdaed0 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -4058,8 +4058,9 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | |||
4058 | 4058 | ||
4059 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); | 4059 | ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); |
4060 | if (!ac) { | 4060 | if (!ac) { |
4061 | ar->len = 0; | ||
4061 | *errp = -ENOMEM; | 4062 | *errp = -ENOMEM; |
4062 | return 0; | 4063 | goto out1; |
4063 | } | 4064 | } |
4064 | 4065 | ||
4065 | ext4_mb_poll_new_transaction(sb, handle); | 4066 | ext4_mb_poll_new_transaction(sb, handle); |
@@ -4067,7 +4068,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, | |||
4067 | *errp = ext4_mb_initialize_context(ac, ar); | 4068 | *errp = ext4_mb_initialize_context(ac, ar); |
4068 | if (*errp) { | 4069 | if (*errp) { |
4069 | ar->len = 0; | 4070 | ar->len = 0; |
4070 | goto out; | 4071 | goto out2; |
4071 | } | 4072 | } |
4072 | 4073 | ||
4073 | ac->ac_op = EXT4_MB_HISTORY_PREALLOC; | 4074 | ac->ac_op = EXT4_MB_HISTORY_PREALLOC; |
@@ -4115,11 +4116,12 @@ repeat: | |||
4115 | 4116 | ||
4116 | ext4_mb_release_context(ac); | 4117 | ext4_mb_release_context(ac); |
4117 | 4118 | ||
4118 | out: | 4119 | out2: |
4120 | kmem_cache_free(ext4_ac_cachep, ac); | ||
4121 | out1: | ||
4119 | if (ar->len < inquota) | 4122 | if (ar->len < inquota) |
4120 | DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len); | 4123 | DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len); |
4121 | 4124 | ||
4122 | kmem_cache_free(ext4_ac_cachep, ac); | ||
4123 | return block; | 4125 | return block; |
4124 | } | 4126 | } |
4125 | static void ext4_mb_poll_new_transaction(struct super_block *sb, | 4127 | static void ext4_mb_poll_new_transaction(struct super_block *sb, |