提交 363d4251 编写于 作者: S Shen Feng 提交者: Theodore Ts'o

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: NShen Feng <shen@cn.fujitsu.com>
Signed-off-by: NMingming Cao <cmm@us.ibm.com>
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
上级 f9a8ac99
...@@ -4058,8 +4058,9 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, ...@@ -4058,8 +4058,9 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS);
if (!ac) { if (!ac) {
ar->len = 0;
*errp = -ENOMEM; *errp = -ENOMEM;
return 0; goto out1;
} }
ext4_mb_poll_new_transaction(sb, handle); ext4_mb_poll_new_transaction(sb, handle);
...@@ -4067,7 +4068,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, ...@@ -4067,7 +4068,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
*errp = ext4_mb_initialize_context(ac, ar); *errp = ext4_mb_initialize_context(ac, ar);
if (*errp) { if (*errp) {
ar->len = 0; ar->len = 0;
goto out; goto out2;
} }
ac->ac_op = EXT4_MB_HISTORY_PREALLOC; ac->ac_op = EXT4_MB_HISTORY_PREALLOC;
...@@ -4115,11 +4116,12 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, ...@@ -4115,11 +4116,12 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
ext4_mb_release_context(ac); ext4_mb_release_context(ac);
out: out2:
kmem_cache_free(ext4_ac_cachep, ac);
out1:
if (ar->len < inquota) if (ar->len < inquota)
DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len); DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len);
kmem_cache_free(ext4_ac_cachep, ac);
return block; return block;
} }
static void ext4_mb_poll_new_transaction(struct super_block *sb, static void ext4_mb_poll_new_transaction(struct super_block *sb,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册