aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid1.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/raid1.c')
-rw-r--r--drivers/md/raid1.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index bbe0b817572b..c42ef1c99fa0 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -61,10 +61,8 @@ static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data)
61 int size = offsetof(r1bio_t, bios[pi->raid_disks]); 61 int size = offsetof(r1bio_t, bios[pi->raid_disks]);
62 62
63 /* allocate a r1bio with room for raid_disks entries in the bios array */ 63 /* allocate a r1bio with room for raid_disks entries in the bios array */
64 r1_bio = kmalloc(size, gfp_flags); 64 r1_bio = kzalloc(size, gfp_flags);
65 if (r1_bio) 65 if (!r1_bio)
66 memset(r1_bio, 0, size);
67 else
68 unplug_slaves(pi->mddev); 66 unplug_slaves(pi->mddev);
69 67
70 return r1_bio; 68 return r1_bio;
@@ -711,13 +709,11 @@ static struct page **alloc_behind_pages(struct bio *bio)
711{ 709{
712 int i; 710 int i;
713 struct bio_vec *bvec; 711 struct bio_vec *bvec;
714 struct page **pages = kmalloc(bio->bi_vcnt * sizeof(struct page *), 712 struct page **pages = kzalloc(bio->bi_vcnt * sizeof(struct page *),
715 GFP_NOIO); 713 GFP_NOIO);
716 if (unlikely(!pages)) 714 if (unlikely(!pages))
717 goto do_sync_io; 715 goto do_sync_io;
718 716
719 memset(pages, 0, bio->bi_vcnt * sizeof(struct page *));
720
721 bio_for_each_segment(bvec, bio, i) { 717 bio_for_each_segment(bvec, bio, i) {
722 pages[i] = alloc_page(GFP_NOIO); 718 pages[i] = alloc_page(GFP_NOIO);
723 if (unlikely(!pages[i])) 719 if (unlikely(!pages[i]))
@@ -1770,19 +1766,16 @@ static int run(mddev_t *mddev)
1770 * bookkeeping area. [whatever we allocate in run(), 1766 * bookkeeping area. [whatever we allocate in run(),
1771 * should be freed in stop()] 1767 * should be freed in stop()]
1772 */ 1768 */
1773 conf = kmalloc(sizeof(conf_t), GFP_KERNEL); 1769 conf = kzalloc(sizeof(conf_t), GFP_KERNEL);
1774 mddev->private = conf; 1770 mddev->private = conf;
1775 if (!conf) 1771 if (!conf)
1776 goto out_no_mem; 1772 goto out_no_mem;
1777 1773
1778 memset(conf, 0, sizeof(*conf)); 1774 conf->mirrors = kzalloc(sizeof(struct mirror_info)*mddev->raid_disks,
1779 conf->mirrors = kmalloc(sizeof(struct mirror_info)*mddev->raid_disks,
1780 GFP_KERNEL); 1775 GFP_KERNEL);
1781 if (!conf->mirrors) 1776 if (!conf->mirrors)
1782 goto out_no_mem; 1777 goto out_no_mem;
1783 1778
1784 memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks);
1785
1786 conf->tmppage = alloc_page(GFP_KERNEL); 1779 conf->tmppage = alloc_page(GFP_KERNEL);
1787 if (!conf->tmppage) 1780 if (!conf->tmppage)
1788 goto out_no_mem; 1781 goto out_no_mem;
@@ -1992,13 +1985,12 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks)
1992 kfree(newpoolinfo); 1985 kfree(newpoolinfo);
1993 return -ENOMEM; 1986 return -ENOMEM;
1994 } 1987 }
1995 newmirrors = kmalloc(sizeof(struct mirror_info) * raid_disks, GFP_KERNEL); 1988 newmirrors = kzalloc(sizeof(struct mirror_info) * raid_disks, GFP_KERNEL);
1996 if (!newmirrors) { 1989 if (!newmirrors) {
1997 kfree(newpoolinfo); 1990 kfree(newpoolinfo);
1998 mempool_destroy(newpool); 1991 mempool_destroy(newpool);
1999 return -ENOMEM; 1992 return -ENOMEM;
2000 } 1993 }
2001 memset(newmirrors, 0, sizeof(struct mirror_info)*raid_disks);
2002 1994
2003 raise_barrier(conf); 1995 raise_barrier(conf);
2004 1996