dm: use vzalloc
authorJoe Perches <joe@perches.com>
Tue, 2 Aug 2011 11:32:02 +0000 (12:32 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Tue, 2 Aug 2011 11:32:02 +0000 (12:32 +0100)
Use vzalloc() instead of vmalloc()+memset().

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm-log.c
drivers/md/dm-snap-persistent.c
drivers/md/dm-table.c

index 306ce123d6b438b4f2b128bddf61d08b195da82c..3b52bb72bd1f0cb8717798c121008a76784b9aa0 100644 (file)
@@ -492,7 +492,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
        memset(lc->sync_bits, (sync == NOSYNC) ? -1 : 0, bitset_size);
        lc->sync_count = (sync == NOSYNC) ? region_count : 0;
 
-       lc->recovering_bits = vmalloc(bitset_size);
+       lc->recovering_bits = vzalloc(bitset_size);
        if (!lc->recovering_bits) {
                DMWARN("couldn't allocate sync bitset");
                vfree(lc->sync_bits);
@@ -504,7 +504,6 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
                kfree(lc);
                return -ENOMEM;
        }
-       memset(lc->recovering_bits, 0, bitset_size);
        lc->sync_search = 0;
        log->context = lc;
 
index 39becbec4dfed6b21c18a3fc3b5c9d4710727b65..1a0acb8abdf67f88d8f51ada6620c581fa878153 100644 (file)
@@ -174,10 +174,9 @@ static int alloc_area(struct pstore *ps)
        if (!ps->area)
                goto err_area;
 
-       ps->zero_area = vmalloc(len);
+       ps->zero_area = vzalloc(len);
        if (!ps->zero_area)
                goto err_zero_area;
-       memset(ps->zero_area, 0, len);
 
        ps->header_area = vmalloc(len);
        if (!ps->header_area)
index 3909fa259f5537035ba63b277cc23a25fee3b1f0..8dc67555e736771912dd0350ebad50267a8a1fb5 100644 (file)
@@ -153,9 +153,7 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size)
                return NULL;
 
        size = nmemb * elem_size;
-       addr = vmalloc(size);
-       if (addr)
-               memset(addr, 0, size);
+       addr = vzalloc(size);
 
        return addr;
 }