aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShen Feng <shen@cn.fujitsu.com>2008-07-11 19:27:31 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-07-11 19:27:31 -0400
commit74767c5a2dca0a60676d60d36377a41f60ca42ba (patch)
tree96f7fa96682be3eb3b3f04c373260762d6a901aa
parentfdf6c7a7683c6272e953a33358920e98a4d93cf0 (diff)
ext4: miscellaneous error checks and coding cleanups for mballoc
ext4_mb_seq_history_open(): check if sbi->s_mb_history is NULL ext4_mb_history_init(): replace kmalloc and memset with kzalloc ext4_mb_init_backend(): remove memset since kzalloc is used ext4_mb_init(): the return value of ext4_mb_init_backend is int, but i is unsigned, replace it with a new int variable. Signed-off-by: Shen Feng <shen@cn.fujitsu.com> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--fs/ext4/mballoc.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index b64600be2066..6d69dd92aadb 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -1985,6 +1985,8 @@ static int ext4_mb_seq_history_open(struct inode *inode, struct file *file)
1985 int rc; 1985 int rc;
1986 int size; 1986 int size;
1987 1987
1988 if (unlikely(sbi->s_mb_history == NULL))
1989 return -ENOMEM;
1988 s = kmalloc(sizeof(*s), GFP_KERNEL); 1990 s = kmalloc(sizeof(*s), GFP_KERNEL);
1989 if (s == NULL) 1991 if (s == NULL)
1990 return -ENOMEM; 1992 return -ENOMEM;
@@ -2187,9 +2189,7 @@ static void ext4_mb_history_init(struct super_block *sb)
2187 sbi->s_mb_history_cur = 0; 2189 sbi->s_mb_history_cur = 0;
2188 spin_lock_init(&sbi->s_mb_history_lock); 2190 spin_lock_init(&sbi->s_mb_history_lock);
2189 i = sbi->s_mb_history_max * sizeof(struct ext4_mb_history); 2191 i = sbi->s_mb_history_max * sizeof(struct ext4_mb_history);
2190 sbi->s_mb_history = kmalloc(i, GFP_KERNEL); 2192 sbi->s_mb_history = kzalloc(i, GFP_KERNEL);
2191 if (likely(sbi->s_mb_history != NULL))
2192 memset(sbi->s_mb_history, 0, i);
2193 /* if we can't allocate history, then we simple won't use it */ 2193 /* if we can't allocate history, then we simple won't use it */
2194} 2194}
2195 2195
@@ -2303,7 +2303,6 @@ static int ext4_mb_init_backend(struct super_block *sb)
2303 i++; 2303 i++;
2304 goto err_freebuddy; 2304 goto err_freebuddy;
2305 } 2305 }
2306 memset(meta_group_info[j], 0, len);
2307 set_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, 2306 set_bit(EXT4_GROUP_INFO_NEED_INIT_BIT,
2308 &(meta_group_info[j]->bb_state)); 2307 &(meta_group_info[j]->bb_state));
2309 2308
@@ -2358,6 +2357,7 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
2358 unsigned i; 2357 unsigned i;
2359 unsigned offset; 2358 unsigned offset;
2360 unsigned max; 2359 unsigned max;
2360 int ret;
2361 2361
2362 if (!test_opt(sb, MBALLOC)) 2362 if (!test_opt(sb, MBALLOC))
2363 return 0; 2363 return 0;
@@ -2392,12 +2392,12 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
2392 } while (i <= sb->s_blocksize_bits + 1); 2392 } while (i <= sb->s_blocksize_bits + 1);
2393 2393
2394 /* init file for buddy data */ 2394 /* init file for buddy data */
2395 i = ext4_mb_init_backend(sb); 2395 ret = ext4_mb_init_backend(sb);
2396 if (i) { 2396 if (ret != 0) {
2397 clear_opt(sbi->s_mount_opt, MBALLOC); 2397 clear_opt(sbi->s_mount_opt, MBALLOC);
2398 kfree(sbi->s_mb_offsets); 2398 kfree(sbi->s_mb_offsets);
2399 kfree(sbi->s_mb_maxs); 2399 kfree(sbi->s_mb_maxs);
2400 return i; 2400 return ret;
2401 } 2401 }
2402 2402
2403 spin_lock_init(&sbi->s_md_lock); 2403 spin_lock_init(&sbi->s_md_lock);