diff options
author | Namhyung Kim <namhyung@gmail.com> | 2011-07-18 03:38:50 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-07-18 03:38:50 -0400 |
commit | 6ce328462c1145a217ba1f27b882743be1407759 (patch) | |
tree | 53eb00f1fbbb002f4f3d74a0e1ed09131377a70d /drivers | |
parent | c65060ad4274f70048d62e0a86332cd3fd23f28d (diff) |
md/raid5: use kmem_cache_zalloc()
Replace kmem_cache_alloc + memset(,0,) to kmem_cache_zalloc.
I think it's not harmful since @conf->slab_cache already knows
actual size of struct stripe_head.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/raid5.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index b72edf35ec54..0f71aa9a07c5 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -1315,10 +1315,10 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request) | |||
1315 | static int grow_one_stripe(raid5_conf_t *conf) | 1315 | static int grow_one_stripe(raid5_conf_t *conf) |
1316 | { | 1316 | { |
1317 | struct stripe_head *sh; | 1317 | struct stripe_head *sh; |
1318 | sh = kmem_cache_alloc(conf->slab_cache, GFP_KERNEL); | 1318 | sh = kmem_cache_zalloc(conf->slab_cache, GFP_KERNEL); |
1319 | if (!sh) | 1319 | if (!sh) |
1320 | return 0; | 1320 | return 0; |
1321 | memset(sh, 0, sizeof(*sh) + (conf->pool_size-1)*sizeof(struct r5dev)); | 1321 | |
1322 | sh->raid_conf = conf; | 1322 | sh->raid_conf = conf; |
1323 | spin_lock_init(&sh->lock); | 1323 | spin_lock_init(&sh->lock); |
1324 | #ifdef CONFIG_MULTICORE_RAID456 | 1324 | #ifdef CONFIG_MULTICORE_RAID456 |
@@ -1435,12 +1435,10 @@ static int resize_stripes(raid5_conf_t *conf, int newsize) | |||
1435 | return -ENOMEM; | 1435 | return -ENOMEM; |
1436 | 1436 | ||
1437 | for (i = conf->max_nr_stripes; i; i--) { | 1437 | for (i = conf->max_nr_stripes; i; i--) { |
1438 | nsh = kmem_cache_alloc(sc, GFP_KERNEL); | 1438 | nsh = kmem_cache_zalloc(sc, GFP_KERNEL); |
1439 | if (!nsh) | 1439 | if (!nsh) |
1440 | break; | 1440 | break; |
1441 | 1441 | ||
1442 | memset(nsh, 0, sizeof(*nsh) + (newsize-1)*sizeof(struct r5dev)); | ||
1443 | |||
1444 | nsh->raid_conf = conf; | 1442 | nsh->raid_conf = conf; |
1445 | spin_lock_init(&nsh->lock); | 1443 | spin_lock_init(&nsh->lock); |
1446 | #ifdef CONFIG_MULTICORE_RAID456 | 1444 | #ifdef CONFIG_MULTICORE_RAID456 |