aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>2012-09-26 20:43:37 -0400
committerTheodore Ts'o <tytso@mit.edu>2012-09-26 20:43:37 -0400
commit85556c9a503ababa889bd7bb7a9b3effba795d00 (patch)
treec006a06209ee01d2ea46f8a6000d18742cceb640 /fs/ext4
parent8c85447391735469f407add6fdb0630ce59d7f6d (diff)
ext4: use kmem_cache_zalloc instead of kmem_cache_alloc/memset
Using kmem_cache_zalloc() instead of kmem_cache_alloc() and memset(). spatch with a semantic match is used to found this problem. (http://coccinelle.lip6.fr/) Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/mballoc.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index bb821a924049..8ec6f88b7a37 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2232,12 +2232,11 @@ int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group,
2232 sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)]; 2232 sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)];
2233 i = group & (EXT4_DESC_PER_BLOCK(sb) - 1); 2233 i = group & (EXT4_DESC_PER_BLOCK(sb) - 1);
2234 2234
2235 meta_group_info[i] = kmem_cache_alloc(cachep, GFP_KERNEL); 2235 meta_group_info[i] = kmem_cache_zalloc(cachep, GFP_KERNEL);
2236 if (meta_group_info[i] == NULL) { 2236 if (meta_group_info[i] == NULL) {
2237 ext4_msg(sb, KERN_ERR, "can't allocate buddy mem"); 2237 ext4_msg(sb, KERN_ERR, "can't allocate buddy mem");
2238 goto exit_group_info; 2238 goto exit_group_info;
2239 } 2239 }
2240 memset(meta_group_info[i], 0, kmem_cache_size(cachep));
2241 set_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, 2240 set_bit(EXT4_GROUP_INFO_NEED_INIT_BIT,
2242 &(meta_group_info[i]->bb_state)); 2241 &(meta_group_info[i]->bb_state));
2243 2242
@@ -4010,7 +4009,6 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
4010 ext4_get_group_no_and_offset(sb, goal, &group, &block); 4009 ext4_get_group_no_and_offset(sb, goal, &group, &block);
4011 4010
4012 /* set up allocation goals */ 4011 /* set up allocation goals */
4013 memset(ac, 0, sizeof(struct ext4_allocation_context));
4014 ac->ac_b_ex.fe_logical = ar->logical & ~(sbi->s_cluster_ratio - 1); 4012 ac->ac_b_ex.fe_logical = ar->logical & ~(sbi->s_cluster_ratio - 1);
4015 ac->ac_status = AC_STATUS_CONTINUE; 4013 ac->ac_status = AC_STATUS_CONTINUE;
4016 ac->ac_sb = sb; 4014 ac->ac_sb = sb;
@@ -4293,7 +4291,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
4293 } 4291 }
4294 } 4292 }
4295 4293
4296 ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); 4294 ac = kmem_cache_zalloc(ext4_ac_cachep, GFP_NOFS);
4297 if (!ac) { 4295 if (!ac) {
4298 ar->len = 0; 4296 ar->len = 0;
4299 *errp = -ENOMEM; 4297 *errp = -ENOMEM;