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>
This commit is contained in:
parent
1ac4594d88
commit
558feb0818
4 changed files with 7 additions and 18 deletions
|
@ -59,12 +59,11 @@ void coda_sysctl_clean(void);
|
||||||
|
|
||||||
#define CODA_ALLOC(ptr, cast, size) do { \
|
#define CODA_ALLOC(ptr, cast, size) do { \
|
||||||
if (size < PAGE_SIZE) \
|
if (size < PAGE_SIZE) \
|
||||||
ptr = kmalloc((unsigned long) size, GFP_KERNEL); \
|
ptr = kzalloc((unsigned long) size, GFP_KERNEL); \
|
||||||
else \
|
else \
|
||||||
ptr = (cast)vmalloc((unsigned long) size); \
|
ptr = (cast)vzalloc((unsigned long) size); \
|
||||||
if (!ptr) \
|
if (!ptr) \
|
||||||
printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
|
printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
|
||||||
else memset( ptr, 0, size ); \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -291,14 +291,13 @@ int reiserfs_allocate_list_bitmaps(struct super_block *sb,
|
||||||
for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
|
for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
|
||||||
jb = jb_array + i;
|
jb = jb_array + i;
|
||||||
jb->journal_list = NULL;
|
jb->journal_list = NULL;
|
||||||
jb->bitmaps = vmalloc(mem);
|
jb->bitmaps = vzalloc(mem);
|
||||||
if (!jb->bitmaps) {
|
if (!jb->bitmaps) {
|
||||||
reiserfs_warning(sb, "clm-2000", "unable to "
|
reiserfs_warning(sb, "clm-2000", "unable to "
|
||||||
"allocate bitmaps for journal lists");
|
"allocate bitmaps for journal lists");
|
||||||
failed = 1;
|
failed = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(jb->bitmaps, 0, mem);
|
|
||||||
}
|
}
|
||||||
if (failed) {
|
if (failed) {
|
||||||
free_list_bitmaps(sb, jb_array);
|
free_list_bitmaps(sb, jb_array);
|
||||||
|
@ -353,11 +352,10 @@ static struct reiserfs_journal_cnode *allocate_cnodes(int num_cnodes)
|
||||||
if (num_cnodes <= 0) {
|
if (num_cnodes <= 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
head = vmalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode));
|
head = vzalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode));
|
||||||
if (!head) {
|
if (!head) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(head, 0, num_cnodes * sizeof(struct reiserfs_journal_cnode));
|
|
||||||
head[0].prev = NULL;
|
head[0].prev = NULL;
|
||||||
head[0].next = head + 1;
|
head[0].next = head + 1;
|
||||||
for (i = 1; i < num_cnodes; i++) {
|
for (i = 1; i < num_cnodes; i++) {
|
||||||
|
@ -2685,14 +2683,13 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
|
||||||
* dependency inversion warnings.
|
* dependency inversion warnings.
|
||||||
*/
|
*/
|
||||||
reiserfs_write_unlock(sb);
|
reiserfs_write_unlock(sb);
|
||||||
journal = SB_JOURNAL(sb) = vmalloc(sizeof(struct reiserfs_journal));
|
journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal));
|
||||||
if (!journal) {
|
if (!journal) {
|
||||||
reiserfs_warning(sb, "journal-1256",
|
reiserfs_warning(sb, "journal-1256",
|
||||||
"unable to get memory for journal structure");
|
"unable to get memory for journal structure");
|
||||||
reiserfs_write_lock(sb);
|
reiserfs_write_lock(sb);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
memset(journal, 0, sizeof(struct reiserfs_journal));
|
|
||||||
INIT_LIST_HEAD(&journal->j_bitmap_nodes);
|
INIT_LIST_HEAD(&journal->j_bitmap_nodes);
|
||||||
INIT_LIST_HEAD(&journal->j_prealloc_list);
|
INIT_LIST_HEAD(&journal->j_prealloc_list);
|
||||||
INIT_LIST_HEAD(&journal->j_working_list);
|
INIT_LIST_HEAD(&journal->j_working_list);
|
||||||
|
|
|
@ -111,15 +111,13 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
|
||||||
/* allocate additional bitmap blocks, reallocate array of bitmap
|
/* allocate additional bitmap blocks, reallocate array of bitmap
|
||||||
* block pointers */
|
* block pointers */
|
||||||
bitmap =
|
bitmap =
|
||||||
vmalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
|
vzalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
|
||||||
if (!bitmap) {
|
if (!bitmap) {
|
||||||
/* Journal bitmaps are still supersized, but the memory isn't
|
/* Journal bitmaps are still supersized, but the memory isn't
|
||||||
* leaked, so I guess it's ok */
|
* leaked, so I guess it's ok */
|
||||||
printk("reiserfs_resize: unable to allocate memory.\n");
|
printk("reiserfs_resize: unable to allocate memory.\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memset(bitmap, 0,
|
|
||||||
sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
|
|
||||||
for (i = 0; i < bmap_nr; i++)
|
for (i = 0; i < bmap_nr; i++)
|
||||||
bitmap[i] = old_bitmap[i];
|
bitmap[i] = old_bitmap[i];
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,7 @@ extern void kmem_free(const void *);
|
||||||
|
|
||||||
static inline void *kmem_zalloc_large(size_t size)
|
static inline void *kmem_zalloc_large(size_t size)
|
||||||
{
|
{
|
||||||
void *ptr;
|
return vzalloc(size);
|
||||||
|
|
||||||
ptr = vmalloc(size);
|
|
||||||
if (ptr)
|
|
||||||
memset(ptr, 0, size);
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
static inline void kmem_free_large(void *ptr)
|
static inline void kmem_free_large(void *ptr)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue