aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-01-06 03:20:32 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:34:05 -0500
commit9ffae0cf3ea02f75d163922accfd3e592d87adde (patch)
tree4974727e9f36e1b618b68d2789644ee3a0d7a371
parent2d1f3b5d1b2cd11a162eb29645df749ec0036413 (diff)
[PATCH] md: convert md to use kzalloc throughout
Replace multiple kmalloc/memset pairs with kzalloc calls. Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/md/bitmap.c11
-rw-r--r--drivers/md/linear.c3
-rw-r--r--drivers/md/md.c10
-rw-r--r--drivers/md/multipath.c10
-rw-r--r--drivers/md/raid0.c9
-rw-r--r--drivers/md/raid1.c20
-rw-r--r--drivers/md/raid10.c6
-rw-r--r--drivers/md/raid5.c8
8 files changed, 24 insertions, 53 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index fc05d1205aa0..c3faa6a43de1 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -887,12 +887,10 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
887 if (!bitmap->filemap) 887 if (!bitmap->filemap)
888 goto out; 888 goto out;
889 889
890 bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL); 890 bitmap->filemap_attr = kzalloc(sizeof(long) * num_pages, GFP_KERNEL);
891 if (!bitmap->filemap_attr) 891 if (!bitmap->filemap_attr)
892 goto out; 892 goto out;
893 893
894 memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages);
895
896 oldindex = ~0L; 894 oldindex = ~0L;
897 895
898 for (i = 0; i < chunks; i++) { 896 for (i = 0; i < chunks; i++) {
@@ -1557,12 +1555,10 @@ int bitmap_create(mddev_t *mddev)
1557 1555
1558 BUG_ON(file && mddev->bitmap_offset); 1556 BUG_ON(file && mddev->bitmap_offset);
1559 1557
1560 bitmap = kmalloc(sizeof(*bitmap), GFP_KERNEL); 1558 bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL);
1561 if (!bitmap) 1559 if (!bitmap)
1562 return -ENOMEM; 1560 return -ENOMEM;
1563 1561
1564 memset(bitmap, 0, sizeof(*bitmap));
1565
1566 spin_lock_init(&bitmap->lock); 1562 spin_lock_init(&bitmap->lock);
1567 bitmap->mddev = mddev; 1563 bitmap->mddev = mddev;
1568 1564
@@ -1603,12 +1599,11 @@ int bitmap_create(mddev_t *mddev)
1603#ifdef INJECT_FATAL_FAULT_1 1599#ifdef INJECT_FATAL_FAULT_1
1604 bitmap->bp = NULL; 1600 bitmap->bp = NULL;
1605#else 1601#else
1606 bitmap->bp = kmalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL); 1602 bitmap->bp = kzalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL);
1607#endif 1603#endif
1608 err = -ENOMEM; 1604 err = -ENOMEM;
1609 if (!bitmap->bp) 1605 if (!bitmap->bp)
1610 goto error; 1606 goto error;
1611 memset(bitmap->bp, 0, pages * sizeof(*bitmap->bp));
1612 1607
1613 bitmap->flags |= BITMAP_ACTIVE; 1608 bitmap->flags |= BITMAP_ACTIVE;
1614 1609
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 946efef3a8f5..f46c98d05b44 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -121,11 +121,10 @@ static int linear_run (mddev_t *mddev)
121 sector_t curr_offset; 121 sector_t curr_offset;
122 struct list_head *tmp; 122 struct list_head *tmp;
123 123
124 conf = kmalloc (sizeof (*conf) + mddev->raid_disks*sizeof(dev_info_t), 124 conf = kzalloc (sizeof (*conf) + mddev->raid_disks*sizeof(dev_info_t),
125 GFP_KERNEL); 125 GFP_KERNEL);
126 if (!conf) 126 if (!conf)
127 goto out; 127 goto out;
128 memset(conf, 0, sizeof(*conf) + mddev->raid_disks*sizeof(dev_info_t));
129 mddev->private = conf; 128 mddev->private = conf;
130 129
131 cnt = 0; 130 cnt = 0;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c3ac67cffe62..8c378b62a676 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -228,12 +228,10 @@ static mddev_t * mddev_find(dev_t unit)
228 } 228 }
229 spin_unlock(&all_mddevs_lock); 229 spin_unlock(&all_mddevs_lock);
230 230
231 new = (mddev_t *) kmalloc(sizeof(*new), GFP_KERNEL); 231 new = kzalloc(sizeof(*new), GFP_KERNEL);
232 if (!new) 232 if (!new)
233 return NULL; 233 return NULL;
234 234
235 memset(new, 0, sizeof(*new));
236
237 new->unit = unit; 235 new->unit = unit;
238 if (MAJOR(unit) == MD_MAJOR) 236 if (MAJOR(unit) == MD_MAJOR)
239 new->md_minor = MINOR(unit); 237 new->md_minor = MINOR(unit);
@@ -1620,12 +1618,11 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi
1620 mdk_rdev_t *rdev; 1618 mdk_rdev_t *rdev;
1621 sector_t size; 1619 sector_t size;
1622 1620
1623 rdev = (mdk_rdev_t *) kmalloc(sizeof(*rdev), GFP_KERNEL); 1621 rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
1624 if (!rdev) { 1622 if (!rdev) {
1625 printk(KERN_ERR "md: could not alloc mem for new device!\n"); 1623 printk(KERN_ERR "md: could not alloc mem for new device!\n");
1626 return ERR_PTR(-ENOMEM); 1624 return ERR_PTR(-ENOMEM);
1627 } 1625 }
1628 memset(rdev, 0, sizeof(*rdev));
1629 1626
1630 if ((err = alloc_disk_sb(rdev))) 1627 if ((err = alloc_disk_sb(rdev)))
1631 goto abort_free; 1628 goto abort_free;
@@ -3505,11 +3502,10 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev,
3505{ 3502{
3506 mdk_thread_t *thread; 3503 mdk_thread_t *thread;
3507 3504
3508 thread = kmalloc(sizeof(mdk_thread_t), GFP_KERNEL); 3505 thread = kzalloc(sizeof(mdk_thread_t), GFP_KERNEL);
3509 if (!thread) 3506 if (!thread)
3510 return NULL; 3507 return NULL;
3511 3508
3512 memset(thread, 0, sizeof(mdk_thread_t));
3513 init_waitqueue_head(&thread->wqueue); 3509 init_waitqueue_head(&thread->wqueue);
3514 3510
3515 thread->run = run; 3511 thread->run = run;
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 145cdc5ad008..97a56aaaef6d 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -41,9 +41,7 @@ static mdk_personality_t multipath_personality;
41static void *mp_pool_alloc(gfp_t gfp_flags, void *data) 41static void *mp_pool_alloc(gfp_t gfp_flags, void *data)
42{ 42{
43 struct multipath_bh *mpb; 43 struct multipath_bh *mpb;
44 mpb = kmalloc(sizeof(*mpb), gfp_flags); 44 mpb = kzalloc(sizeof(*mpb), gfp_flags);
45 if (mpb)
46 memset(mpb, 0, sizeof(*mpb));
47 return mpb; 45 return mpb;
48} 46}
49 47
@@ -444,7 +442,7 @@ static int multipath_run (mddev_t *mddev)
444 * should be freed in multipath_stop()] 442 * should be freed in multipath_stop()]
445 */ 443 */
446 444
447 conf = kmalloc(sizeof(multipath_conf_t), GFP_KERNEL); 445 conf = kzalloc(sizeof(multipath_conf_t), GFP_KERNEL);
448 mddev->private = conf; 446 mddev->private = conf;
449 if (!conf) { 447 if (!conf) {
450 printk(KERN_ERR 448 printk(KERN_ERR
@@ -452,9 +450,8 @@ static int multipath_run (mddev_t *mddev)
452 mdname(mddev)); 450 mdname(mddev));
453 goto out; 451 goto out;
454 } 452 }
455 memset(conf, 0, sizeof(*conf));
456 453
457 conf->multipaths = kmalloc(sizeof(struct multipath_info)*mddev->raid_disks, 454 conf->multipaths = kzalloc(sizeof(struct multipath_info)*mddev->raid_disks,
458 GFP_KERNEL); 455 GFP_KERNEL);
459 if (!conf->multipaths) { 456 if (!conf->multipaths) {
460 printk(KERN_ERR 457 printk(KERN_ERR
@@ -462,7 +459,6 @@ static int multipath_run (mddev_t *mddev)
462 mdname(mddev)); 459 mdname(mddev));
463 goto out_free_conf; 460 goto out_free_conf;
464 } 461 }
465 memset(conf->multipaths, 0, sizeof(struct multipath_info)*mddev->raid_disks);
466 462
467 conf->working_disks = 0; 463 conf->working_disks = 0;
468 ITERATE_RDEV(mddev,rdev,tmp) { 464 ITERATE_RDEV(mddev,rdev,tmp) {
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index a2c2e184c0ac..b4eaa67fabde 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -113,21 +113,16 @@ static int create_strip_zones (mddev_t *mddev)
113 } 113 }
114 printk("raid0: FINAL %d zones\n", conf->nr_strip_zones); 114 printk("raid0: FINAL %d zones\n", conf->nr_strip_zones);
115 115
116 conf->strip_zone = kmalloc(sizeof(struct strip_zone)* 116 conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
117 conf->nr_strip_zones, GFP_KERNEL); 117 conf->nr_strip_zones, GFP_KERNEL);
118 if (!conf->strip_zone)