Re: [PATCH] jbd2: JBD replace jbd2_kmalloc with kmalloc

Previous thread: [PATCH] ext4: Convert ext4_extent_idx.ei_leaf to ext4_extent_idx.ei_leaf_lo by Theodore Ts'o on Thursday, October 4, 2007 - 1:50 am. (2 messages)

Next thread: none
To: <linux-kernel@...>
Cc: <linux-ext4@...>
Date: Thursday, October 4, 2007 - 1:50 am

The following ext4 patches are planned for submission to Linus once
the merge window for 2.6.24-rc1 is opened.

- Ted

-

To: <linux-kernel@...>
Cc: <linux-ext4@...>, Mingming Cao <cmm@...>, Christoph Lameter <clameter@...>
Date: Thursday, October 4, 2007 - 1:50 am

From: Mingming Cao <cmm@us.ibm.com>

JBD: Replace slab allocations with page cache allocations

JBD allocate memory for committed_data and frozen_data from slab. However
JBD should not pass slab pages down to the block layer. Use page allocator pages instead. This will also prepare JBD for the large blocksize patchset.

Also this patch cleans up jbd_kmalloc and replace it with kmalloc directly

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
---
fs/jbd/commit.c | 6 +-
fs/jbd/journal.c | 99 ++----------------------------------------------
fs/jbd/transaction.c | 12 +++---
fs/jbd2/commit.c | 6 +-
fs/jbd2/journal.c | 99 ++----------------------------------------------
fs/jbd2/transaction.c | 18 ++++----
include/linux/jbd.h | 18 +++++----
include/linux/jbd2.h | 19 +++++----
8 files changed, 51 insertions(+), 226 deletions(-)

diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c
index a003d50..a263d82 100644
--- a/fs/jbd/commit.c
+++ b/fs/jbd/commit.c
@@ -375,7 +375,7 @@ void journal_commit_transaction(journal_t *journal)
struct buffer_head *bh = jh2bh(jh);

jbd_lock_bh_state(bh);
- jbd_slab_free(jh->b_committed_data, bh->b_size);
+ jbd_free(jh->b_committed_data, bh->b_size);
jh->b_committed_data = NULL;
jbd_unlock_bh_state(bh);
}
@@ -792,14 +792,14 @@ restart_loop:
* Otherwise, we can just throw away the frozen data now.
*/
if (jh->b_committed_data) {
- jbd_slab_free(jh->b_committed_data, bh->b_size);
+ jbd_free(jh->b_committed_data, bh->b_size);
jh->b_committed_data = NULL;
if (jh->b_frozen_data) {
jh->b_committed_data = jh->b_frozen_data;
jh->b_frozen_data = NULL;
}
} else if (jh->b_frozen_data) {
- jbd_slab_free(jh->b_frozen_data, bh->b_size);
+ jbd_free(jh->b_frozen_data, bh->b_size);
jh->b_frozen_data = NULL;
}

d...

To: Theodore Ts'o <tytso@...>
Cc: <linux-kernel@...>, <linux-ext4@...>, Mingming Cao <cmm@...>, Christoph Lameter <clameter@...>
Date: Thursday, October 4, 2007 - 2:52 am

That sounds like it should be a different patch..

-

To: Christoph Hellwig <hch@...>
Cc: Theodore Ts'o <tytso@...>, <linux-kernel@...>, <linux-ext4@...>, Christoph Lameter <clameter@...>
Date: Friday, October 5, 2007 - 6:39 pm

JBD2: JBD2 replace jbd2_kmalloc with kmalloc

From: Mingming Cao <cmm@us.ibm.com>

This patch cleans up jbd_kmalloc and replace it with kmalloc directly

Signed-off-by: Mingming Cao <cmm@us.ibm.com>
---

fs/jbd2/journal.c | 11 +----------
fs/jbd2/transaction.c | 4 ++--
include/linux/jbd2.h | 7 -------
3 files changed, 3 insertions(+), 19 deletions(-)

Index: linux-2.6.23-rc9/fs/jbd2/journal.c
===================================================================
--- linux-2.6.23-rc9.orig/fs/jbd2/journal.c 2007-10-05 12:08:26.000000000 -0700
+++ linux-2.6.23-rc9/fs/jbd2/journal.c 2007-10-05 12:08:32.000000000 -0700
@@ -654,7 +654,7 @@ static journal_t * journal_init_common (
journal_t *journal;
int err;

- journal = jbd_kmalloc(sizeof(*journal), GFP_KERNEL);
+ journal = kmalloc(sizeof(*journal), GFP_KERNEL);
if (!journal)
goto fail;
memset(journal, 0, sizeof(*journal));
@@ -1619,15 +1619,6 @@ size_t journal_tag_bytes(journal_t *jour
}

/*
- * Simple support for retrying memory allocations. Introduced to help to
- * debug different VM deadlock avoidance strategies.
- */
-void * __jbd2_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
-{
- return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0));
-}
-
-/*
* Journal_head storage management
*/
static struct kmem_cache *jbd2_journal_head_cache;
Index: linux-2.6.23-rc9/fs/jbd2/transaction.c
===================================================================
--- linux-2.6.23-rc9.orig/fs/jbd2/transaction.c 2007-10-05 12:08:26.000000000 -0700
+++ linux-2.6.23-rc9/fs/jbd2/transaction.c 2007-10-05 12:08:32.000000000 -0700
@@ -96,8 +96,8 @@ static int start_this_handle(journal_t *

alloc_transaction:
if (!journal->j_running_transaction) {
- new_transaction = jbd_kmalloc(sizeof(*new_transaction),
- GFP_NOFS);
+ new_transaction = kmalloc(sizeof(*new_transaction),
+ GFP_NOFS|__GFP_NOFAIL);
if (!new_transaction) {
ret = -ENOMEM;
go...

To: Mingming Cao <cmm@...>
Cc: Christoph Hellwig <hch@...>, Theodore Ts'o <tytso@...>, <linux-kernel@...>, <linux-ext4@...>
Date: Monday, October 8, 2007 - 2:37 pm

Acked-by: Christoph Lameter <clameter@sgi.com>

-

To: Christoph Hellwig <hch@...>
Cc: Theodore Ts'o <tytso@...>, <linux-kernel@...>, <linux-ext4@...>, Christoph Lameter <clameter@...>
Date: Friday, October 5, 2007 - 6:38 pm

JBD: JBD replace jbd_kmalloc with kmalloc

From: Mingming Cao <cmm@us.ibm.com>

This patch cleans up jbd_kmalloc and replace it with kmalloc directly

Signed-off-by: Mingming Cao <cmm@us.ibm.com>
---

fs/jbd/journal.c | 11 +----------
fs/jbd/transaction.c | 4 ++--
include/linux/jbd.h | 6 ------
3 files changed, 3 insertions(+), 18 deletions(-)

Index: linux-2.6.23-rc9/fs/jbd/journal.c
===================================================================
--- linux-2.6.23-rc9.orig/fs/jbd/journal.c 2007-10-05 12:08:08.000000000 -0700
+++ linux-2.6.23-rc9/fs/jbd/journal.c 2007-10-05 12:08:29.000000000 -0700
@@ -653,7 +653,7 @@ static journal_t * journal_init_common (
journal_t *journal;
int err;

- journal = jbd_kmalloc(sizeof(*journal), GFP_KERNEL);
+ journal = kmalloc(sizeof(*journal), GFP_KERNEL);
if (!journal)
goto fail;
memset(journal, 0, sizeof(*journal));
@@ -1607,15 +1607,6 @@ int journal_blocks_per_page(struct inode
}

/*
- * Simple support for retrying memory allocations. Introduced to help to
- * debug different VM deadlock avoidance strategies.
- */
-void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
-{
- return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0));
-}
-
-/*
* Journal_head storage management
*/
static struct kmem_cache *journal_head_cache;
Index: linux-2.6.23-rc9/fs/jbd/transaction.c
===================================================================
--- linux-2.6.23-rc9.orig/fs/jbd/transaction.c 2007-10-05 12:08:08.000000000 -0700
+++ linux-2.6.23-rc9/fs/jbd/transaction.c 2007-10-05 12:08:29.000000000 -0700
@@ -96,8 +96,8 @@ static int start_this_handle(journal_t *

alloc_transaction:
if (!journal->j_running_transaction) {
- new_transaction = jbd_kmalloc(sizeof(*new_transaction),
- GFP_NOFS);
+ new_transaction = kmalloc(sizeof(*new_transaction),
+ GFP_NOFS|__GFP_NOFAIL);
if (!new_transaction) {
ret = -ENOMEM;
goto out;
Index: lin...

To: Mingming Cao <cmm@...>
Cc: Christoph Hellwig <hch@...>, Theodore Ts'o <tytso@...>, <linux-kernel@...>, <linux-ext4@...>
Date: Monday, October 8, 2007 - 1:46 pm

journal_oom_retry is no longer used?
-

To: Christoph Lameter <clameter@...>
Cc: Christoph Hellwig <hch@...>, Theodore Ts'o <tytso@...>, <linux-kernel@...>, <linux-ext4@...>
Date: Monday, October 8, 2007 - 2:26 pm

journal_oom_retry (which is defined as 1 currently) is still being used
in revoke.c, the cleanup patch doesn't remove the define of
journal_oom_retry.

Since journal_oom_retry is always 1 to __jbd_kmalloc,

void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int
retry)
{
return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0));
}

So we replace jbd_kmalloc() to kmalloc() with __GFP_NOFAIL flag on in
start_this_handle(). Other two places replacing to kmalloc() is part of
the init process, so no need for __GFP_NOFAIL flag there.

-

To: Mingming Cao <cmm@...>
Cc: Christoph Hellwig <hch@...>, Theodore Ts'o <tytso@...>, <linux-kernel@...>, <linux-ext4@...>
Date: Monday, October 8, 2007 - 2:34 pm

Acked-by: Christoph Lameter <clameter@sgi.com>

-

To: Christoph Hellwig <hch@...>
Cc: Theodore Ts'o <tytso@...>, <linux-kernel@...>, <linux-ext4@...>, Christoph Lameter <clameter@...>
Date: Friday, October 5, 2007 - 6:36 pm

JBD2: jbd2 slab allocation cleanups

From: Mingming Cao <cmm@us.ibm.com>

JBD2: Replace slab allocations with page allocations

JBD2 allocate memory for committed_data and frozen_data from slab. However
JBD2 should not pass slab pages down to the block layer. Use page allocator
pages instead. This will also prepare JBD for the large blocksize patchset.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
---

fs/jbd2/commit.c | 6 +--
fs/jbd2/journal.c | 88 ++------------------------------------------------
fs/jbd2/transaction.c | 14 +++----
include/linux/jbd2.h | 18 +++++++---
4 files changed, 27 insertions(+), 99 deletions(-)

Index: linux-2.6.23-rc9/fs/jbd2/commit.c
===================================================================
--- linux-2.6.23-rc9.orig/fs/jbd2/commit.c 2007-10-05 12:03:43.000000000 -0700
+++ linux-2.6.23-rc9/fs/jbd2/commit.c 2007-10-05 12:08:26.000000000 -0700
@@ -384,7 +384,7 @@ void jbd2_journal_commit_transaction(jou
struct buffer_head *bh = jh2bh(jh);

jbd_lock_bh_state(bh);
- jbd2_slab_free(jh->b_committed_data, bh->b_size);
+ jbd2_free(jh->b_committed_data, bh->b_size);
jh->b_committed_data = NULL;
jbd_unlock_bh_state(bh);
}
@@ -801,14 +801,14 @@ restart_loop:
* Otherwise, we can just throw away the frozen data now.
*/
if (jh->b_committed_data) {
- jbd2_slab_free(jh->b_committed_data, bh->b_size);
+ jbd2_free(jh->b_committed_data, bh->b_size);
jh->b_committed_data = NULL;
if (jh->b_frozen_data) {
jh->b_committed_data = jh->b_frozen_data;
jh->b_frozen_data = NULL;
}
} else if (jh->b_frozen_data) {
- jbd2_slab_free(jh->b_frozen_data, bh->b_size);
+ jbd2_free(jh->b_frozen_data, bh->b_size);
jh->b_frozen_data = NULL;
}

Index: linux-2.6.23-rc9/fs/jbd2/journal.c
====================================================...

To: Christoph Hellwig <hch@...>
Cc: Theodore Ts'o <tytso@...>, <linux-kernel@...>, <linux-ext4@...>, Christoph Lameter <clameter@...>
Date: Friday, October 5, 2007 - 6:35 pm

JBD: JBD slab allocation cleanups

From: Mingming Cao <cmm@us.ibm.com>

JBD: Replace slab allocations with page allocations

JBD allocate memory for committed_data and frozen_data from slab. However
JBD should not pass slab pages down to the block layer. Use page allocator pages instead. This will also prepare JBD for the large blocksize patchset.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
---

fs/jbd/commit.c | 6 +--
fs/jbd/journal.c | 88 ++-------------------------------------------------
fs/jbd/transaction.c | 8 ++--
include/linux/jbd.h | 13 +++++--
4 files changed, 21 insertions(+), 94 deletions(-)

Index: linux-2.6.23-rc9/fs/jbd/commit.c
===================================================================
--- linux-2.6.23-rc9.orig/fs/jbd/commit.c 2007-10-05 12:03:43.000000000 -0700
+++ linux-2.6.23-rc9/fs/jbd/commit.c 2007-10-05 12:08:08.000000000 -0700
@@ -375,7 +375,7 @@ void journal_commit_transaction(journal_
struct buffer_head *bh = jh2bh(jh);

jbd_lock_bh_state(bh);
- jbd_slab_free(jh->b_committed_data, bh->b_size);
+ jbd_free(jh->b_committed_data, bh->b_size);
jh->b_committed_data = NULL;
jbd_unlock_bh_state(bh);
}
@@ -792,14 +792,14 @@ restart_loop:
* Otherwise, we can just throw away the frozen data now.
*/
if (jh->b_committed_data) {
- jbd_slab_free(jh->b_committed_data, bh->b_size);
+ jbd_free(jh->b_committed_data, bh->b_size);
jh->b_committed_data = NULL;
if (jh->b_frozen_data) {
jh->b_committed_data = jh->b_frozen_data;
jh->b_frozen_data = NULL;
}
} else if (jh->b_frozen_data) {
- jbd_slab_free(jh->b_frozen_data, bh->b_size);
+ jbd_free(jh->b_frozen_data, bh->b_size);
jh->b_frozen_data = NULL;
}

Index: linux-2.6.23-rc9/fs/jbd/journal.c
===================================================================
--- linu...

To: Christoph Hellwig <hch@...>
Cc: Theodore Ts'o <tytso@...>, <linux-kernel@...>, <linux-ext4@...>, Christoph Lameter <clameter@...>
Date: Friday, October 5, 2007 - 6:33 pm

Okay. Will sent the patches, that also separate JBD2 changes to a
different patch.

-

To: <linux-kernel@...>
Cc: <linux-ext4@...>, Aneesh Kumar K.V <aneesh.kumar@...>, Mingming Cao <cmm@...>, Theodore Ts'o <tytso@...>
Date: Thursday, October 4, 2007 - 1:50 am

From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
fs/jbd/journal.c | 2 +-
fs/jbd2/journal.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index ae2c25d..8d6d475 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -653,7 +653,7 @@ static journal_t * journal_init_common (void)
journal_t *journal;
int err;

- journal = kmalloc(sizeof(*journal), GFP_KERNEL|__GFP_NOFAIL);
+ journal = kmalloc(sizeof(*journal), GFP_KERNEL);
if (!journal)
goto fail;
memset(journal, 0, sizeof(*journal));
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 4281244..0e329a3 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -654,7 +654,7 @@ static journal_t * journal_init_common (void)
journal_t *journal;
int err;

- journal = kmalloc(sizeof(*journal), GFP_KERNEL|__GFP_NOFAIL);
+ journal = kmalloc(sizeof(*journal), GFP_KERNEL);
if (!journal)
goto fail;
memset(journal, 0, sizeof(*journal));
--
1.5.3.2.81.g17ed

-

To: <linux-kernel@...>
Cc: <linux-ext4@...>, Mingming Cao <cmm@...>
Date: Thursday, October 4, 2007 - 1:50 am

From: Mingming Cao <cmm@us.ibm.com>

Convert kmalloc to kzalloc() and get rid of the memset().

Signed-off-by: Mingming Cao <cmm@us.ibm.com>
---
fs/ext4/xattr.c | 3 +--
fs/jbd2/journal.c | 3 +--
fs/jbd2/transaction.c | 3 +--
3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index b10d68f..12c7d65 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -750,12 +750,11 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
}
} else {
/* Allocate a buffer where we construct the new block. */
- s->base = kmalloc(sb->s_blocksize, GFP_KERNEL);
+ s->base = kzalloc(sb->s_blocksize, GFP_KERNEL);
/* assert(header == s->base) */
error = -ENOMEM;
if (s->base == NULL)
goto cleanup;
- memset(s->base, 0, sb->s_blocksize);
header(s->base)->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC);
header(s->base)->h_blocks = cpu_to_le32(1);
header(s->base)->h_refcount = cpu_to_le32(1);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 0e329a3..f12c65b 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -654,10 +654,9 @@ static journal_t * journal_init_common (void)
journal_t *journal;
int err;

- journal = kmalloc(sizeof(*journal), GFP_KERNEL);
+ journal = kzalloc(sizeof(*journal), GFP_KERNEL|__GFP_NOFAIL);
if (!journal)
goto fail;
- memset(journal, 0, sizeof(*journal));

init_waitqueue_head(&journal->j_wait_transaction_locked);
init_waitqueue_head(&journal->j_wait_logspace);
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index a5fb70f..b1fcf2b 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -96,13 +96,12 @@ static int start_this_handle(journal_t *journal, handle_t *handle)

alloc_transaction:
if (!journal->j_running_transaction) {
- new_transaction = kmalloc(sizeof(*new_transaction),
+ new_transaction = kzalloc(sizeof(*new_transaction),
GFP_NOFS...

Previous thread: [PATCH] ext4: Convert ext4_extent_idx.ei_leaf to ext4_extent_idx.ei_leaf_lo by Theodore Ts'o on Thursday, October 4, 2007 - 1:50 am. (2 messages)

Next thread: none