Skip to content

Commit 558feb0

Browse files
JoePerchesJiri Kosina
authored andcommitted
fs: Convert vmalloc/memset to vzalloc
Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Alex Elder <aelder@sgi.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 1ac4594 commit 558feb0

4 files changed

Lines changed: 7 additions & 18 deletions

File tree

‎fs/coda/coda_linux.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ void coda_sysctl_clean(void);
5959

6060
#define CODA_ALLOC(ptr, cast, size) do { \
6161
if (size < PAGE_SIZE) \
62-
ptr = kmalloc((unsigned long) size, GFP_KERNEL); \
62+
ptr = kzalloc((unsigned long) size, GFP_KERNEL); \
6363
else \
64-
ptr = (cast)vmalloc((unsigned long) size); \
64+
ptr = (cast)vzalloc((unsigned long) size); \
6565
if (!ptr) \
6666
printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
67-
else memset( ptr, 0, size ); \
6867
} while (0)
6968

7069

‎fs/reiserfs/journal.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,13 @@ int reiserfs_allocate_list_bitmaps(struct super_block *sb,
291291
for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
292292
jb = jb_array + i;
293293
jb->journal_list = NULL;
294-
jb->bitmaps = vmalloc(mem);
294+
jb->bitmaps = vzalloc(mem);
295295
if (!jb->bitmaps) {
296296
reiserfs_warning(sb, "clm-2000", "unable to "
297297
"allocate bitmaps for journal lists");
298298
failed = 1;
299299
break;
300300
}
301-
memset(jb->bitmaps, 0, mem);
302301
}
303302
if (failed) {
304303
free_list_bitmaps(sb, jb_array);
@@ -353,11 +352,10 @@ static struct reiserfs_journal_cnode *allocate_cnodes(int num_cnodes)
353352
if (num_cnodes <= 0) {
354353
return NULL;
355354
}
356-
head = vmalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode));
355+
head = vzalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode));
357356
if (!head) {
358357
return NULL;
359358
}
360-
memset(head, 0, num_cnodes * sizeof(struct reiserfs_journal_cnode));
361359
head[0].prev = NULL;
362360
head[0].next = head + 1;
363361
for (i = 1; i < num_cnodes; i++) {
@@ -2685,14 +2683,13 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
26852683
* dependency inversion warnings.
26862684
*/
26872685
reiserfs_write_unlock(sb);
2688-
journal = SB_JOURNAL(sb) = vmalloc(sizeof(struct reiserfs_journal));
2686+
journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal));
26892687
if (!journal) {
26902688
reiserfs_warning(sb, "journal-1256",
26912689
"unable to get memory for journal structure");
26922690
reiserfs_write_lock(sb);
26932691
return 1;
26942692
}
2695-
memset(journal, 0, sizeof(struct reiserfs_journal));
26962693
INIT_LIST_HEAD(&journal->j_bitmap_nodes);
26972694
INIT_LIST_HEAD(&journal->j_prealloc_list);
26982695
INIT_LIST_HEAD(&journal->j_working_list);

‎fs/reiserfs/resize.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,13 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
111111
/* allocate additional bitmap blocks, reallocate array of bitmap
112112
* block pointers */
113113
bitmap =
114-
vmalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
114+
vzalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
115115
if (!bitmap) {
116116
/* Journal bitmaps are still supersized, but the memory isn't
117117
* leaked, so I guess it's ok */
118118
printk("reiserfs_resize: unable to allocate memory.\n");
119119
return -ENOMEM;
120120
}
121-
memset(bitmap, 0,
122-
sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
123121
for (i = 0; i < bmap_nr; i++)
124122
bitmap[i] = old_bitmap[i];
125123

‎fs/xfs/linux-2.6/kmem.h‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ extern void kmem_free(const void *);
6161

6262
static inline void *kmem_zalloc_large(size_t size)
6363
{
64-
void *ptr;
65-
66-
ptr = vmalloc(size);
67-
if (ptr)
68-
memset(ptr, 0, size);
69-
return ptr;
64+
return vzalloc(size);
7065
}
7166
static inline void kmem_free_large(void *ptr)
7267
{

0 commit comments

Comments
 (0)