Remove #include of linux/jbd.h from mballoc-core so it will compile
[ext4-patch-queue.git] / jbd_kmalloc_kzalloc.patch
blob8ca0469c096b61ff6c0a7e832c9dcc0dd798188e
1 JBD/JBD2/Ext34: Convert kmalloc to kzalloc in jbd/jbd2/ext3/ext4
3 From: Mingming Cao <cmm@us.ibm.com>
5 Convert kmalloc to kzalloc() and get rid of the memset().
7 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
8 ---
9 fs/ext3/xattr.c | 3 +--
10 fs/ext4/xattr.c | 3 +--
11 fs/jbd/journal.c | 3 +--
12 fs/jbd/transaction.c | 2 +-
13 fs/jbd2/journal.c | 3 +--
14 fs/jbd2/transaction.c | 2 +-
15 6 files changed, 6 insertions(+), 10 deletions(-)
17 Index: linux-2.6.23-rc6/fs/jbd/journal.c
18 ===================================================================
19 --- linux-2.6.23-rc6.orig/fs/jbd/journal.c 2007-09-21 09:08:02.000000000 -0700
20 +++ linux-2.6.23-rc6/fs/jbd/journal.c 2007-09-21 09:10:37.000000000 -0700
21 @@ -653,10 +653,9 @@ static journal_t * journal_init_common (
22 journal_t *journal;
23 int err;
25 - journal = kmalloc(sizeof(*journal), GFP_KERNEL);
26 + journal = kzalloc(sizeof(*journal), GFP_KERNEL|__GFP_NOFAIL);
27 if (!journal)
28 goto fail;
29 - memset(journal, 0, sizeof(*journal));
31 init_waitqueue_head(&journal->j_wait_transaction_locked);
32 init_waitqueue_head(&journal->j_wait_logspace);
33 Index: linux-2.6.23-rc6/fs/jbd/transaction.c
34 ===================================================================
35 --- linux-2.6.23-rc6.orig/fs/jbd/transaction.c 2007-09-21 09:13:11.000000000 -0700
36 +++ linux-2.6.23-rc6/fs/jbd/transaction.c 2007-09-21 09:13:24.000000000 -0700
37 @@ -96,7 +96,7 @@ static int start_this_handle(journal_t *
39 alloc_transaction:
40 if (!journal->j_running_transaction) {
41 - new_transaction = kmalloc(sizeof(*new_transaction),
42 + new_transaction = kzalloc(sizeof(*new_transaction),
43 GFP_NOFS|__GFP_NOFAIL);
44 if (!new_transaction) {
45 ret = -ENOMEM;
46 Index: linux-2.6.23-rc6/fs/jbd2/journal.c
47 ===================================================================
48 --- linux-2.6.23-rc6.orig/fs/jbd2/journal.c 2007-09-21 09:10:53.000000000 -0700
49 +++ linux-2.6.23-rc6/fs/jbd2/journal.c 2007-09-21 09:11:13.000000000 -0700
50 @@ -654,10 +654,9 @@ static journal_t * journal_init_common (
51 journal_t *journal;
52 int err;
54 - journal = kmalloc(sizeof(*journal), GFP_KERNEL);
55 + journal = kzalloc(sizeof(*journal), GFP_KERNEL|__GFP_NOFAIL);
56 if (!journal)
57 goto fail;
58 - memset(journal, 0, sizeof(*journal));
60 init_waitqueue_head(&journal->j_wait_transaction_locked);
61 init_waitqueue_head(&journal->j_wait_logspace);
62 Index: linux-2.6.23-rc6/fs/jbd2/transaction.c
63 ===================================================================
64 --- linux-2.6.23-rc6.orig/fs/jbd2/transaction.c 2007-09-21 09:12:46.000000000 -0700
65 +++ linux-2.6.23-rc6/fs/jbd2/transaction.c 2007-09-21 09:12:59.000000000 -0700
66 @@ -96,7 +96,7 @@ static int start_this_handle(journal_t *
68 alloc_transaction:
69 if (!journal->j_running_transaction) {
70 - new_transaction = kmalloc(sizeof(*new_transaction),
71 + new_transaction = kzalloc(sizeof(*new_transaction),
72 GFP_NOFS|__GFP_NOFAIL);
73 if (!new_transaction) {
74 ret = -ENOMEM;
75 Index: linux-2.6.23-rc6/fs/ext3/xattr.c
76 ===================================================================
77 --- linux-2.6.23-rc6.orig/fs/ext3/xattr.c 2007-09-21 10:22:24.000000000 -0700
78 +++ linux-2.6.23-rc6/fs/ext3/xattr.c 2007-09-21 10:24:19.000000000 -0700
79 @@ -741,12 +741,11 @@ ext3_xattr_block_set(handle_t *handle, s
81 } else {
82 /* Allocate a buffer where we construct the new block. */
83 - s->base = kmalloc(sb->s_blocksize, GFP_KERNEL);
84 + s->base = kzalloc(sb->s_blocksize, GFP_KERNEL);
85 /* assert(header == s->base) */
86 error = -ENOMEM;
87 if (s->base == NULL)
88 goto cleanup;
89 - memset(s->base, 0, sb->s_blocksize);
90 header(s->base)->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC);
91 header(s->base)->h_blocks = cpu_to_le32(1);
92 header(s->base)->h_refcount = cpu_to_le32(1);
93 Index: linux-2.6.23-rc6/fs/ext4/xattr.c
94 ===================================================================
95 --- linux-2.6.23-rc6.orig/fs/ext4/xattr.c 2007-09-21 10:20:21.000000000 -0700
96 +++ linux-2.6.23-rc6/fs/ext4/xattr.c 2007-09-21 10:21:00.000000000 -0700
97 @@ -750,12 +750,11 @@ ext4_xattr_block_set(handle_t *handle, s
99 } else {
100 /* Allocate a buffer where we construct the new block. */
101 - s->base = kmalloc(sb->s_blocksize, GFP_KERNEL);
102 + s->base = kzalloc(sb->s_blocksize, GFP_KERNEL);
103 /* assert(header == s->base) */
104 error = -ENOMEM;
105 if (s->base == NULL)
106 goto cleanup;
107 - memset(s->base, 0, sb->s_blocksize);
108 header(s->base)->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
109 header(s->base)->h_blocks = cpu_to_le32(1);
110 header(s->base)->h_refcount = cpu_to_le32(1);