Whamcloud - gitweb
LU-8364 ldiskfs: fixes for failover mode.
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel6.3 / ext4-use-ext4_kvzalloc-ext4_kvmalloc-for-s_group_desc-and-s_group_info.patch
1 From f18a5f21c25707b4fe64b326e2b4d150565e7300 Mon Sep 17 00:00:00 2001
2 From: Theodore Ts'o <tytso@mit.edu>
3 Date: Mon, 1 Aug 2011 08:45:38 -0400
4 Subject: ext4: use ext4_kvzalloc()/ext4_kvmalloc() for s_group_desc and s_group_info
5 Git-commit: f18a5f21
6 Patch-mainline: v3.1-rc1
7
8 Upstream-Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
9 Signed-off-by: Jeff Mahoney <jeffm@suse.com>
10 ---
11  fs/ext4/mballoc.c |    6 +++---
12  fs/ext4/resize.c  |   13 +++++++------
13  fs/ext4/super.c   |    9 +++++----
14  3 files changed, 15 insertions(+), 13 deletions(-)
15
16 --- a/fs/ext4/mballoc.c
17 +++ b/fs/ext4/mballoc.c
18 @@ -2307,7 +2307,7 @@ static int ext4_mb_init_backend(struct s
19         /* An 8TB filesystem with 64-bit pointers requires a 4096 byte
20          * kmalloc. A 128kb malloc should suffice for a 256TB filesystem.
21          * So a two level scheme suffices for now. */
22 -       sbi->s_group_info = kmalloc(array_size, GFP_KERNEL);
23 +       sbi->s_group_info = ext4_kvzalloc(array_size, GFP_KERNEL);
24         if (sbi->s_group_info == NULL) {
25                 printk(KERN_ERR "EXT4-fs: can't allocate buddy meta group\n");
26                 return -ENOMEM;
27 @@ -2339,7 +2339,7 @@ err_freebuddy:
28                 kfree(sbi->s_group_info[i]);
29         iput(sbi->s_buddy_cache);
30  err_freesgi:
31 -       kfree(sbi->s_group_info);
32 +       ext4_kvfree(sbi->s_group_info);
33         return -ENOMEM;
34  }
35
36 @@ -2464,7 +2464,7 @@ int ext4_mb_release(struct super_block *
37                         EXT4_DESC_PER_BLOCK_BITS(sb);
38                 for (i = 0; i < num_meta_group_infos; i++)
39                         kfree(sbi->s_group_info[i]);
40 -               kfree(sbi->s_group_info);
41 +               ext4_kvfree(sbi->s_group_info);
42         }
43         kfree(sbi->s_mb_offsets);
44         kfree(sbi->s_mb_maxs);
45 --- a/fs/ext4/resize.c
46 +++ b/fs/ext4/resize.c
47 @@ -435,12 +435,13 @@ static int add_new_gdb(handle_t *handle,
48         if ((err = ext4_reserve_inode_write(handle, inode, &iloc)))
49                 goto exit_dindj;
50
51 -       n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *),
52 -                       GFP_NOFS);
53 +       n_group_desc = ext4_kvmalloc((gdb_num + 1) *
54 +                                    sizeof(struct buffer_head *),
55 +                                    GFP_NOFS);
56         if (!n_group_desc) {
57                 err = -ENOMEM;
58 -               ext4_warning(sb,
59 -                             "not enough memory for %lu groups", gdb_num + 1);
60 +               ext4_warning(sb, "not enough memory for %lu groups",
61 +                            gdb_num + 1);
62                 goto exit_inode;
63         }
64
65 @@ -467,7 +468,7 @@ static int add_new_gdb(handle_t *handle,
66         n_group_desc[gdb_num] = *primary;
67         EXT4_SB(sb)->s_group_desc = n_group_desc;
68         EXT4_SB(sb)->s_gdb_count++;
69 -       kfree(o_group_desc);
70 +       ext4_kvfree(o_group_desc);
71
72         le16_add_cpu(&es->s_reserved_gdt_blocks, -1);
73         ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
74 @@ -475,7 +476,7 @@ static int add_new_gdb(handle_t *handle,
75         return 0;
76
77  exit_inode:
78 -       kfree(n_group_desc);
79 +       ext4_kvfree(n_group_desc);
80         /* ext4_journal_release_buffer(handle, iloc.bh); */
81         brelse(iloc.bh);
82  exit_dindj:
83 --- a/fs/ext4/super.c
84 +++ b/fs/ext4/super.c
85 @@ -705,7 +705,7 @@ static void ext4_put_super(struct super_
86
87         for (i = 0; i < sbi->s_gdb_count; i++)
88                 brelse(sbi->s_group_desc[i]);
89 -       kfree(sbi->s_group_desc);
90 +       ext4_kvfree(sbi->s_group_desc);
91         ext4_kvfree(sbi->s_flex_groups);
92         percpu_counter_destroy(&sbi->s_freeblocks_counter);
93         percpu_counter_destroy(&sbi->s_freeinodes_counter);
94 @@ -3169,8 +3169,9 @@ static int ext4_fill_super(struct super_
95                         (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb)));
96         db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
97                    EXT4_DESC_PER_BLOCK(sb);
98 -       sbi->s_group_desc = kmalloc(db_count * sizeof(struct buffer_head *),
99 -                                   GFP_KERNEL);
100 +       sbi->s_group_desc = ext4_kvmalloc(db_count *
101 +                                         sizeof(struct buffer_head *),
102 +                                         GFP_KERNEL);
103         if (sbi->s_group_desc == NULL) {
104                 ext4_msg(sb, KERN_ERR, "not enough memory");
105                 goto failed_mount;
106 @@ -3495,7 +3496,7 @@ failed_mount3:
107  failed_mount2:
108         for (i = 0; i < db_count; i++)
109                 brelse(sbi->s_group_desc[i]);
110 -       kfree(sbi->s_group_desc);
111 +       ext4_kvfree(sbi->s_group_desc);
112  failed_mount:
113         if (sbi->s_proc) {
114                 remove_proc_entry(sb->s_id, ext4_proc_root);