diff options
author | Theodore Ts'o <tytso@mit.edu> | 2011-08-01 08:45:38 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-08-01 08:45:38 -0400 |
commit | f18a5f21c25707b4fe64b326e2b4d150565e7300 (patch) | |
tree | b17baa6c8476eb2a3fbc6b1d65c7fd59950a2dcd /fs | |
parent | 9933fc0ac1ac14b795819cd63d05ea92112f690a (diff) |
ext4: use ext4_kvzalloc()/ext4_kvmalloc() for s_group_desc and s_group_info
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/mballoc.c | 6 | ||||
-rw-r--r-- | fs/ext4/resize.c | 13 | ||||
-rw-r--r-- | fs/ext4/super.c | 9 |
3 files changed, 15 insertions, 13 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index fa716c9b2455..d5021e82f8cc 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -2331,7 +2331,7 @@ static int ext4_mb_init_backend(struct super_block *sb) | |||
2331 | /* An 8TB filesystem with 64-bit pointers requires a 4096 byte | 2331 | /* An 8TB filesystem with 64-bit pointers requires a 4096 byte |
2332 | * kmalloc. A 128kb malloc should suffice for a 256TB filesystem. | 2332 | * kmalloc. A 128kb malloc should suffice for a 256TB filesystem. |
2333 | * So a two level scheme suffices for now. */ | 2333 | * So a two level scheme suffices for now. */ |
2334 | sbi->s_group_info = kzalloc(array_size, GFP_KERNEL); | 2334 | sbi->s_group_info = ext4_kvzalloc(array_size, GFP_KERNEL); |
2335 | if (sbi->s_group_info == NULL) { | 2335 | if (sbi->s_group_info == NULL) { |
2336 | printk(KERN_ERR "EXT4-fs: can't allocate buddy meta group\n"); | 2336 | printk(KERN_ERR "EXT4-fs: can't allocate buddy meta group\n"); |
2337 | return -ENOMEM; | 2337 | return -ENOMEM; |
@@ -2365,7 +2365,7 @@ err_freebuddy: | |||
2365 | kfree(sbi->s_group_info[i]); | 2365 | kfree(sbi->s_group_info[i]); |
2366 | iput(sbi->s_buddy_cache); | 2366 | iput(sbi->s_buddy_cache); |
2367 | err_freesgi: | 2367 | err_freesgi: |
2368 | kfree(sbi->s_group_info); | 2368 | ext4_kvfree(sbi->s_group_info); |
2369 | return -ENOMEM; | 2369 | return -ENOMEM; |
2370 | } | 2370 | } |
2371 | 2371 | ||
@@ -2559,7 +2559,7 @@ int ext4_mb_release(struct super_block *sb) | |||
2559 | EXT4_DESC_PER_BLOCK_BITS(sb); | 2559 | EXT4_DESC_PER_BLOCK_BITS(sb); |
2560 | for (i = 0; i < num_meta_group_infos; i++) | 2560 | for (i = 0; i < num_meta_group_infos; i++) |
2561 | kfree(sbi->s_group_info[i]); | 2561 | kfree(sbi->s_group_info[i]); |
2562 | kfree(sbi->s_group_info); | 2562 | ext4_kvfree(sbi->s_group_info); |
2563 | } | 2563 | } |
2564 | kfree(sbi->s_mb_offsets); | 2564 | kfree(sbi->s_mb_offsets); |
2565 | kfree(sbi->s_mb_maxs); | 2565 | kfree(sbi->s_mb_maxs); |
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 71085df97bbd..707d3f16f7ce 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
@@ -467,12 +467,13 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, | |||
467 | if (unlikely(err)) | 467 | if (unlikely(err)) |
468 | goto exit_dindj; | 468 | goto exit_dindj; |
469 | 469 | ||
470 | n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *), | 470 | n_group_desc = ext4_kvmalloc((gdb_num + 1) * |
471 | GFP_NOFS); | 471 | sizeof(struct buffer_head *), |
472 | GFP_NOFS); | ||
472 | if (!n_group_desc) { | 473 | if (!n_group_desc) { |
473 | err = -ENOMEM; | 474 | err = -ENOMEM; |
474 | ext4_warning(sb, | 475 | ext4_warning(sb, "not enough memory for %lu groups", |
475 | "not enough memory for %lu groups", gdb_num + 1); | 476 | gdb_num + 1); |
476 | goto exit_inode; | 477 | goto exit_inode; |
477 | } | 478 | } |
478 | 479 | ||
@@ -507,7 +508,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, | |||
507 | n_group_desc[gdb_num] = gdb_bh; | 508 | n_group_desc[gdb_num] = gdb_bh; |
508 | EXT4_SB(sb)->s_group_desc = n_group_desc; | 509 | EXT4_SB(sb)->s_group_desc = n_group_desc; |
509 | EXT4_SB(sb)->s_gdb_count++; | 510 | EXT4_SB(sb)->s_gdb_count++; |
510 | kfree(o_group_desc); | 511 | ext4_kvfree(o_group_desc); |
511 | 512 | ||
512 | le16_add_cpu(&es->s_reserved_gdt_blocks, -1); | 513 | le16_add_cpu(&es->s_reserved_gdt_blocks, -1); |
513 | err = ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); | 514 | err = ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); |
@@ -517,7 +518,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, | |||
517 | return err; | 518 | return err; |
518 | 519 | ||
519 | exit_inode: | 520 | exit_inode: |
520 | kfree(n_group_desc); | 521 | ext4_kvfree(n_group_desc); |
521 | /* ext4_handle_release_buffer(handle, iloc.bh); */ | 522 | /* ext4_handle_release_buffer(handle, iloc.bh); */ |
522 | brelse(iloc.bh); | 523 | brelse(iloc.bh); |
523 | exit_dindj: | 524 | exit_dindj: |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 658f5864e9cf..e2d88baf91d3 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -819,7 +819,7 @@ static void ext4_put_super(struct super_block *sb) | |||
819 | 819 | ||
820 | for (i = 0; i < sbi->s_gdb_count; i++) | 820 | for (i = 0; i < sbi->s_gdb_count; i++) |
821 | brelse(sbi->s_group_desc[i]); | 821 | brelse(sbi->s_group_desc[i]); |
822 | kfree(sbi->s_group_desc); | 822 | ext4_kvfree(sbi->s_group_desc); |
823 | ext4_kvfree(sbi->s_flex_groups); | 823 | ext4_kvfree(sbi->s_flex_groups); |
824 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | 824 | percpu_counter_destroy(&sbi->s_freeblocks_counter); |
825 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | 825 | percpu_counter_destroy(&sbi->s_freeinodes_counter); |
@@ -3439,8 +3439,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3439 | (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb))); | 3439 | (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb))); |
3440 | db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / | 3440 | db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / |
3441 | EXT4_DESC_PER_BLOCK(sb); | 3441 | EXT4_DESC_PER_BLOCK(sb); |
3442 | sbi->s_group_desc = kmalloc(db_count * sizeof(struct buffer_head *), | 3442 | sbi->s_group_desc = ext4_kvmalloc(db_count * |
3443 | GFP_KERNEL); | 3443 | sizeof(struct buffer_head *), |
3444 | GFP_KERNEL); | ||
3444 | if (sbi->s_group_desc == NULL) { | 3445 | if (sbi->s_group_desc == NULL) { |
3445 | ext4_msg(sb, KERN_ERR, "not enough memory"); | 3446 | ext4_msg(sb, KERN_ERR, "not enough memory"); |
3446 | goto failed_mount; | 3447 | goto failed_mount; |
@@ -3783,7 +3784,7 @@ failed_mount3: | |||
3783 | failed_mount2: | 3784 | failed_mount2: |
3784 | for (i = 0; i < db_count; i++) | 3785 | for (i = 0; i < db_count; i++) |
3785 | brelse(sbi->s_group_desc[i]); | 3786 | brelse(sbi->s_group_desc[i]); |
3786 | kfree(sbi->s_group_desc); | 3787 | ext4_kvfree(sbi->s_group_desc); |
3787 | failed_mount: | 3788 | failed_mount: |
3788 | if (sbi->s_proc) { | 3789 | if (sbi->s_proc) { |
3789 | remove_proc_entry(sb->s_id, ext4_proc_root); | 3790 | remove_proc_entry(sb->s_id, ext4_proc_root); |